Persistent emacs server sessions
2010-09-05 Victor Chudnovsky 0 Comments
In my spare time, I’ve been working on two tools to make emacs more useful to me by leveraging two key features: the ability to save the desktop state and the ability to have emacs clients connect to an emacs server.
For the former, I wrote an emacs-lisp package called
initiated, the package will periodically save the desktop under the
name of your choice. The benefit of this is that you do not have to
remember to save the desktop explictly yourself before you exit emacs
or before you experience an emacs or system crash. Moreover, the next
time you start
desktop-autosave with that same name, the
corresponding desktop is automatically loaded into your emacs
For the latter, I wrote a bash shell script called
ee that will allow you to connect
to a named emacs server (bringing up the server if it is not already
running). The value of this package is that you can now invoke
wherever you would normally have invoked emacs, and by just specifying
the name of the desired server, you can easily set up as many emacs
sessions as you have concurrent projects.
The real benefit comes when you use both packages together. In this
case, you can use
ee to bring up a named emacs server, and that
server will save its desktop to disk periodically. As long as emacs
stays running, you can keep connecting to the same server from as many
clients as you wish. After your emacs server terminates (by exiting
normally, by crashing, or by the machine being reset), you can use
ee to once again bring up a server with the same name. In this case,
emacs will load the automatically-saved desktop file from disk and you
will have in memory all the files that you were working on previously
on that particular emacs server. Nifty, no?
Feel fry to try these packages out. They are available on GitHub. If you find them useful or if you find bugs, let me know. Enjoy!
UPDATE 020120.02.11: desktop-autosave now saves shell-mode buffer contents, directory, and command history.