The Emacs client

I know that for most Emacs users out there this is not worth writing about, but I have been using Emacs for less than two years and I cannot help hiding my awe everytime I discover something like this. This time is the emacsclient program.

Unfortunately at work I am stuck with Windows. I am a long-time Vim user so I have it installed, which adds an “Open with vim…” entry to the Explorer shell. This opens a new Vim instance everytime it’s used. A similar approach won’t tempt Emacs users because you do not open Emacs everytime you open a file. You open Emacs once a week or once a month and keep it running. So enter emacsclient.

It acts as an independent program for an external caller. When started, this program looks for an already running instance of Emacs and connects to it, which then acts as a server and edits the requested file (to accept connections, server-start must have been run in Emacs. I have it in my .emacs file). When the user is done, he types C-x # in the server buffer. Then emacsclient exits and the external caller assumes the editing application has quit.

This is very useful, for instance, for writing commit log messages. My EDITOR environment variable points to emacsclient. Everytime I need to commit code in Subversion or Monotone, the log message appears as a new buffer in my running Emacs. It is also useful for the Firefox extension It’s All Text!, which allows one to use an external text editor to edit web forms. And, of course, I have added an “Edit with Emacs…” entry to my Explorer shell, so I can open any file into a running Emacs very quickly.

Instructions about how to add the shell shortcut can be found in the Emacs wiki.

One Comment

  1. Websites tagged "shotcut" on Postsaver:

    [...] - The Emacs client saved by powstash2008-10-24 - Shortcut keys firefox saved by Mellomel2008-10-19 - Do you know to [...]

Leave a comment