EMACSCLIENT(1)
๐ EMACSCLIENT(1) ๐
okay bestie, welcome to the emacsclient page ๐ this is the GNU one, and yes it's literally the little buddy that walks up to a running Emacs and is like "hey. open this file for me." iconic behaviour, no notes ๐
โจ NAME โจ
emacsclient โ tells a running Emacs to visit a file ๐ธ
โจ SYNOPSIS โจ
emacsclient [options] files ...
โจ DESCRIPTION โจ
so this page is the quick lil overview of emacsclient, okay? the full docs live in the GNU Info format, and there's a pointer down in SEE ALSO for that ๐
emacsclient works in conjunction with the built-in Emacs server. they're a duo. a package deal. ๐ซถ
you can either call emacsclient yourself directly, or just let other programs run it for you whenever they need to. on GNU and Unix systems, a lot of programs check the environment variable EDITOR (and sometimes also VISUAL) to figure out which command they should use for editing. so if you set that environment variable to emacsclient, those programs will get to use an already running Emacs for editing. slay. other operating systems might have their own lil methods for defining the default editor, iykyk.
for emacsclient to work at all, you need an already running Emacs with a server. inside Emacs, call the functions server-start or server-mode. (your .emacs file can totally do this automatically for you if you add either (server-start) or (server-mode 1) to it. one line, main character energy โจ)
when you're done editing the buffer, type C-x # (server-edit). this saves the file and sends a message back to the emacsclient program telling it to exit. the programs that use EDITOR are literally just waiting for the "editor" (which is actually emacsclient, surprise) to exit. C-x # also checks for other pending external requests to edit various files, and selects the next such file. very organised of it ๐
and if you set the variable server-window to a window or a frame, C-x # displays the server buffer in that window or in that frame. cute.
โจ OPTIONS โจ
most options follow the usual GNU command line syntax, with long options starting with two dashes (-). classic.
+line[:column]โ go to the specified line and column. a missing column is treated as column 1. ngl this option applies only to the next file specified, so don't be shocked when it doesn't stick around ๐ธ-a,--alternate-editor=COMMANDโ if the Emacs server isn't running, run the specified shell command instead. if the empty string is specified, runemacs --daemonto start Emacs in daemon mode, and try to connect to it. see also theALTERNATE_EDITORenvironment variable, over which this option takes precedence. ๐-c,--create-frameโ create a new frame instead of trying to use the current Emacs frame. new frame, who dis ๐-r --reuse-frameโ reuse an existing frame if one exists, otherwise create a new frame. (note: that's literally how it's written up there, no comma, I don't make the rules ๐)-F,--frame-parameters=ALISTโ set the parameters of a newly-created frame.-d,--display=DISPLAYโ tell the server to display the files on the given display.-e,--evalโ do not visit files but instead evaluate the arguments as Emacs Lisp expressions. we're doing math now ๐งฎโจ-f,--server-file=FILENAMEโ use TCP configuration file FILENAME for communication. relative filenames are relative to~/.emacs.d/server/or$XDG_CONFIG_HOME/emacs/server/, and the default isserver. see also theEMACS_SERVER_FILEenvironment variable, over which this option takes precedence. ๐-n,--no-waitโ return immediately without waiting for you to "finish" the buffer in Emacs. if combined with--eval, this option is ignored. bye, not waiting โ๏ธ-w,--timeout=Nโ how long to wait, in seconds, for Emacs to respond before giving up. the default is0, which means to wait forever. forever forever? forever forever. ๐ญ--parent-id=IDโ open anemacsclientframe as a client frame in the parent X window with id ID.-q,--quietโ do not letemacsclientdisplay messages about waiting for Emacs or connecting to remote server sockets. shhh ๐คซ-u,--suppress-outputโ do not letemacsclientdisplay results returned from the server. mostly useful in combination with--evalwhen the evaluation performed is for side-effect rather than result.-s,--socket-name=FILENAMEโ use socket named FILENAME for communication. relative filenames are relative to$XDG_RUNTIME_DIR/emacs/or$TMPDIR/. see also theEMACS_SOCKET_NAMEenvironment variable, over which this option takes precedence. ๐-nw,-t,--tty,--no-window-systemโ open a new Emacs frame on the current terminal. terminal girlies rise ๐-T,--tramp=PREFIXโ set PREFIX to add to filenames for Emacs to locate files on remote machines using TRAMP. this is mostly useful in combination with using the Emacs server on a remote host (either using TCP with--server-file, or a socket forwarded over SSH). see also theEMACSCLIENT_TRAMPenvironment variable, over which this option takes precedence. ๐-V,--versionโ print version information and exit.-H,--helpโ print this usage information message and exit.
โจ EXIT STATUS โจ
normally, the exit status is 0 ๐ if emacsclient shuts down due to Emacs signaling an error, the exit status is 1. so basically: chill = 0, drama = 1. ๐
โจ ENVIRONMENT โจ
ALTERNATE_EDITORโ if the Emacs server isn't running, run the shell command in this environment variable instead. if set to the empty string, runemacs --daemonto start Emacs in daemon mode, and try to connect to it. will be overridden by the--alternate-editoroption, if present.EMACSCLIENT_TRAMPโ a prefix to add to filenames, intended to allow Emacs to locate files on remote machines using TRAMP. will be overridden by the--trampoption, if present.EMACS_SERVER_FILEโ look in this file to discover where to find a TCP Emacs server. relative filenames are relative to~/.emacs.d/server/or$XDG_CONFIG_HOME/emacs/server/, and the default isserver. will be overridden by the--server-fileoption, if present.EMACS_SOCKET_NAMEโ the filename of the socket to use for communication with the Emacs server. relative filenames are relative to$XDG_RUNTIME_DIR/emacs/or$TMPDIR/. will be overridden by the--socket-nameoption, if present.
โจ SEE ALSO โจ
- the program is documented fully in Using Emacs as a Server, available via the Info system. go read it, it's giving thorough ๐
- the
XDG_environment variables are described in detail in the XDG Base Directory Specification.
โจ AUTHOR โจ
this manual page was originally written by Stephane Bortzmeyer <bortzmeyer@debian.org>, for the Debian GNU/Linux system, but it is not specific to that system. shoutout to the og ๐ซถ
โจ COPYING โจ
this manual page is in the public domain. do whatever, bestie, it's free ๐โจ
okay that's the whole page!! ๐ this was EMACSCLIENT(1) from GNU Emacs, dated 2024-08-20 โ go forth and let your Emacs server carry you, periodt ๐๐
๐ฆ where this page comes from
- debian trixie: emacs-common 1:30.1+1-6+deb13u1 ยท GPL-3.0-or-later
- ubuntu questing: emacs-common 1:30.1+1-9ubuntu1
- ubuntu resolute: emacs-common 1:30.2+1-2ubuntu1 ยท GPL-3.0-or-later
- ubuntu stonking: emacs-common 1:30.2+1-11ubuntu1 ยท GPL-3.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms