Next: How do I make Emacs recognize my compiler’s funny error messages?, Previous: How do I change load-path
?, Up: Common requests [Contents][Index]
emacsclient
, which comes with Emacs, is for editing a file using
an already running Emacs rather than starting up a new Emacs. It does
this by sending a request to the already running Emacs, which must be
expecting the request.
Emacs must have executed the server-start
function for
‘emacsclient’ to work. This can be done either by a command line
option:
emacs -f server-start
or by invoking server-start
from init file (see How do I set up an init file properly?):
(if (some conditions are met) (server-start))
To get your news reader, mail reader, etc., to invoke
‘emacsclient’, try setting the environment variable EDITOR
(or sometimes VISUAL
) to the value ‘emacsclient’. You may
have to specify the full pathname of the ‘emacsclient’ program
instead. Examples:
# csh commands: setenv EDITOR emacsclient # using full pathname setenv EDITOR /usr/local/emacs/etc/emacsclient # sh command: EDITOR=emacsclient ; export EDITOR
When ‘emacsclient’ is run, it connects to the socket and passes its
command line options to Emacs, which at the next opportunity will visit
the files specified. (Line numbers can be specified just like with
Emacs.) The user will have to switch to the Emacs window by hand. When
the user is done editing a file, the user can type C-x # (or
M-x server-edit) to indicate this. If there is another buffer
requested by emacsclient
, Emacs will switch to it; otherwise
emacsclient
will exit, signaling the calling program to continue.
For more information, See Emacs Server in The GNU Emacs Manual.