Question

I have different work-specific .emacs configuration files on servers where I do work for various companies. These are packages that, for various reasons, I don't want to store locally on my machine. Is there any way to start up emacs using one of those remote directories as if it were local?

Tramp is great for actually editing remote files as if they were local -- now I'd like to be able to start up a whole emacs editor in the same way.

Was it helpful?

Solution

start up emacs using one of those remote directories as if it were local

If the servers are unix/linux servers and you have ssh access, then you could try SSH Filesystem. Then you can mount the servers to local directories, e.g.:

> sshfs server1: ~/remote/server1 
> sshfs server2: ~/remote/server2

Then you could start emacs with emacs --no-init-file --load ~/remote/servers2/.emacs and so on.

packages that, for various reasons, I don't want to store locally

If packages are installed in .emacs.d on the remote machines you could create scripts like the following on your local machine:

;; .emacs.server1.el
(add-to-list 'load-path (expand-file-name "~/remote/server1/.emacs.d"))
(add-to-list 'load-path (expand-file-name "~/remote/server1/.emacs.d/package1"))
(load (expand-file-name "~/remote/server1/.emacs"))

And then start emacs like this: emacs --no-init-file --load ~/.emacs.server1.el

Obvious this script depends on the mounts above.

OTHER TIPS

Out of curiosity I just gave this a go:

emacs -q --load "/ssh:USER@HOSTNAME:.emacs.d/init.el"

That worked, however the remote init.el is setting load paths like "~/.emacs.d/vendor/", so really an init file needs to be aware that the paths and filenames it sets need to be relative to a common base. This base could be set by a common variable, so try:

emacs -q --eval '(setq init-base "/ssh:USER@HOSTNAME:") (load (concat init-base ".emacs.d/init.el"))'

Then in the remote config, prepend init-base to any path or filename it sets that should be remote.

You may find the SO question Originate edit of remote file using emacs tramp from ssh session is asking for a solution to a related problem. Perhaps the answers there might give you what you want, namely, you can attach to an emacs running on the remote machine.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top