1

I have the following function defined in my dot-Emacs:

(defun call-shell-refresh-browser ()
  ;; When pressing 'sf', save the content and refresh the browser
  (interactive)
    (save-buffer)
    (shell-command "python ~/Dropbox/Sys/Linux/chrome-refresh-back-emacs.py")))

It saves the buffer in Emacs, then switching to Chrome, reload the webpage and gets back to Emacs. This worked like a charm.

Until now, I use TRAMP to edit files on a remote machine. When I save it, and call the function call-shell-refresh-browser, it looks in the remote shell for the script chrome-refresh-back-emacs.py which don't exists on the remote machine.

How could I tell Emacs/Tramp to switch to the local shell on my machine, when editing a remote file? This is without terminating the current TRAMP session.

4

You must change default-directory to be a local file name. Like this:

(let ((default-directory temporary-file-directory))
  (shell-command "python ~/Dropbox/Sys/Linux/chrome-refresh-back-emacs.py"))
  • Thanks for your help! Will let you know if it turned out to be working tommorow! – ReneFroger Feb 22 '16 at 20:28
  • it worked right out of the box! Thanks for that, it's appreciated! – ReneFroger Feb 23 '16 at 23:03

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.