You can pass some optional arguments to the emacsclient program, such as:
emacsclient -c +12 file1 +4:3 file2
The ‘+line’ or ‘+line:column’ arguments specify line numbers, or line and column numbers, for the next file argument. These behave like the command line arguments for Emacs itself. See Action Arguments.
The other optional arguments recognized by emacsclient are listed below:
emacsclientfails to contact Emacs. This is useful when running
emacsclientin a script.
As a special exception, if command is the empty string, then
emacsclient starts Emacs in daemon mode (as emacs
--daemon) and then tries connecting again.
The environment variable ALTERNATE_EDITOR has the same effect as the ‘-a’ option. If both are present, the latter takes precedence.
On MS-Windows, a single Emacs session cannot display frames on both graphical and text terminals, nor on multiple text terminals. Thus, if the Emacs server is running on a text terminal, the ‘-c’ option, like the ‘-t’ option, creates a new frame in the server's current text terminal. See Windows Startup.
If you omit a filename argument while supplying the ‘-c’ option,
the new frame displays the *scratch* buffer by default. You
can customize this behavior with the variable
(see Entering Emacs).
An Emacs server usually uses an operating system feature called a “local socket” to listen for connections. Some operating systems, such as Microsoft Windows, do not support local sockets; in that case, the server communicates with emacsclient via TCP.
When you start a TCP Emacs server, Emacs creates a server file
containing the TCP information to be used by emacsclient to
connect to the server. The variable
the directory containing the server file; by default, this is
~/.emacs.d/server/. To tell emacsclient to connect
to the server over TCP with a specific server file, use the ‘-f’
or ‘--server-file’ option, or set the EMACS_SERVER_FILE
server-nameon the Emacs server. If this option is omitted, emacsclient connects to the first server it finds. (This option is not supported on MS-Windows.)
On MS-Windows, ‘-t’ behaves just like ‘-c’ if the Emacs server is using the graphical display, but if the Emacs server is running on a text terminal, it creates a new frame in the current text terminal.
The new graphical or text terminal frames created by the ‘-c’
or ‘-t’ options are considered client frames. Any new
frame that you create from a client frame is also considered a client
frame. If you type C-x C-c (
in a client frame, that command does not kill the Emacs session as it
normally does (see Exiting). Instead, Emacs deletes the client
frame; furthermore, if the client frame has an emacsclient
waiting to regain control (i.e., if you did not supply the ‘-n’
option), Emacs deletes all other frames of the same client, and marks
the client's server buffers as finished, as though you had typed
C-x # in all of them. If it so happens that there are no
remaining frames after the client frame(s) are deleted, the Emacs
As an exception, when Emacs is started as a daemon, all frames are considered client frames, and C-x C-c never kills Emacs. To kill a daemon session, type M-x kill-emacs.
Note that the ‘-t’ and ‘-n’ options are contradictory: ‘-t’ says to take control of the current text terminal to create a new client frame, while ‘-n’ says not to take control of the text terminal. If you supply both options, Emacs visits the specified files(s) in an existing frame rather than a new client frame, negating the effect of ‘-t’.