[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

AC.17 Invoking emacsclient

To run the emacsclient program, specify file names as arguments, and optionally line numbers as well. Do it like this:

 
emacsclient {[+line[column]] filename}...

This tells Emacs to visit each of the specified files; if you specify a line number for a certain file, Emacs moves to that line in the file. If you specify a column number as well, Emacs puts point on that column in the line.

Ordinarily, emacsclient does not return until you use the C-x # command on each of these buffers. When that happens, Emacs sends a message to the emacsclient program telling it to return.

But if you use the option `-n' or `--no-wait' when running emacsclient, then it returns immediately. (You can take as long as you like to edit the files in Emacs.)

The option `--alternate-editor=command' is useful when running emacsclient in a script. It specifies a command to run if emacsclient fails to contact Emacs. For example, the following setting for the EDITOR environment variable will always give an editor, even if Emacs is not running:

 
EDITOR="emacsclient --alternate-editor vi +%d %s"

The environment variable ALTERNATE_EDITOR has the same effect, but the value of the `--alternate-editor' takes precedence.

Alternatively, the file `etc/emacs.bash' defines a bash function which will communicate with a running Emacs server, or start one if none exists.



This document was generated on April 2, 2002 using texi2html