Department of Engineering

IT Services


Many other editors are designed to be started afresh each time you want to edit. You edit one file and then exit the editor. The next time you want to edit either another file or the same one, you must run the editor again. With these editors, it makes sense to use a command line argument to say which file to edit.

But starting a new emacs each time you want to edit a different file would be annoyingly slow and would fail to take advantage of emacs' ability to visit more than one file in a single editing session. If you

  1. start emacs with the emacsserver running (this can be done by adding (server-start) to your .emacs file, or by typing M-x server-start from within emacs)
  2. use emacsclient where you'd normally use emacs (as your editor in pine, as the value of the EDITOR environmental variable, etc)

you'll cause pine, etc to use the existing emacs rather than start a new one.

This facility goes wrong if you're in a windowless environment. Get round that by adding this to your ~/.profile

# Sort out the terminal.
[ $TERM = network ] && TERM=xterm
# Set your default TERM here ^^^^^^^
if [ $TERM = "xterm" ] 
     export EDITOR=emacsclient
     export EDITOR=emacs

(thanks to itc10@eng for this tip)