I have two copies of the same project, one local, one on a remote server, and I am editing a project's file locally, while running an inferior ESS process on the remote server. The remote files get synchronized outside Emacs, and I would like to avoid editing files remotely if I can help it.

When I try to load the file (ess-load-file), it obviously sends the command "source()" as expected. The problem is that I would like it to use the file name with the local directories stripped from it because they don't exist on the remote server, just the bare filename.

I know thatess-load-file uses (buffer-file-name) to find out the file name, but I think I just can't replace a buffer's file name with whatever I want. I've been using

(ess-load-file (file-name-nondirectory (buffer-file-name)))

and rebinding the keybinding for ess-load-file to run this instead, but is there some nicer way of doing this?


I don't know. That looks pretty nice to me. You might unify this under one binding if you please. I'm not too sure what your setup is like, so this might not work. Please correct me if I'm wrong.

(defun ess-load-remote-or-local ()
    (if (file-readable-p (buffer-file-name))
      (file-name-nondirectory (buffer-file-name)))))

I don't think the solution is going to get any simpler. It may get smarter and more automated, but that choice is up to you.

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.