0

Having a remote directory open in Emacs (... via TRAMP), I can run remote commands on remote files (using !). I can also view them locally (... even if they're image files) with builtin Emacs viewers (just "Enter"), resulting in the file being copied over to the local disk transparently.

Is there a way to run a non-Emacs command that's only available on the local machine (... on which Emacs is running; e.g. an X11 pdf viewer), with the input being the remote file, in a way that's simpler than copying over the remote file manually first?

  • I don't know of a default command for that, although you could write one by binding default-directory to a local path before calling shell-command. However, given that you would need to specify the remote file path using a non-tramp syntax -- and what that syntax was (if it existed at all) would be dependent on the command you were running -- it doesn't seem to me like an obvious thing to try to do. – phils Jun 26 '18 at 2:01
  • You could, however, have an Emacs command which copied the remote file to a local temporary file, and invoked the local shell command on the local temporary file. file-local-copy is a function which does the copy-to-a-local-temp-file part of that approach. – phils Jun 26 '18 at 2:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.