{
    "mode": "man",
    "parameter": "EMACSCLIENT",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/man/EMACSCLIENT/json",
    "generated": "2026-10-22T12:59:10Z",
    "synopsis": "emacsclient [options] files ...",
    "sections": {
        "NAME": {
            "content": "emacsclient - tells a running Emacs to visit a file\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "emacsclient [options] files ...\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This  manual page documents briefly the emacsclient command.  Full documentation is available\nin the GNU Info format; see below.\n\nemacsclient works in conjunction with the built-in Emacs server.\n\nYou can either call emacsclient directly or let other programs run it for you when necessary.\nOn GNU and Unix systems many programs consult the environment variable EDITOR (sometimes also\nVISUAL) to obtain the command used for editing.  Thus, setting this environment  variable  to\n'emacsclient'  will  allow these programs to use an already running Emacs for editing.  Other\noperating systems might have their own methods for defining the default editor.\n\nFor emacsclient to work, you need an already running Emacs with a server.  Within Emacs, call\nthe functions \"server-start\" or \"server-mode\".  (Your \".emacs\" file can do this automatically\nif you add either \"(server-start)\" or \"(server-mode 1)\" to it.)\n\nWhen you've finished editing the buffer, type \"C-x #\" (\"server-edit\").  This saves  the  file\nand  sends  a  message back to the emacsclient program telling it to exit.  The programs that\nuse EDITOR wait for the \"editor\" (actually, emacsclient) to exit.  \"C-x #\"  also  checks  for\nother pending external requests to edit various files, and selects the next such file.\n\nIf  you  set the variable \"server-window\" to a window or a frame, \"C-x #\" displays the server\nbuffer in that window or in that frame.\n\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "Most options follow the usual GNU command line syntax, with long options  starting  with  two\ndashes (\"-\").\n\n+line[:column]\nGo  to  the specified line and column.  A missing column is treated as column 1.  This\noption applies only to the next file specified.\n",
            "subsections": [
                {
                    "name": "-a, --alternate-editor=COMMAND",
                    "content": "If the Emacs server is not running, run the specified shell command instead.   If  the\nempty string is specified, run \"emacs --daemon\" to start Emacs in daemon mode, and try\nto connect to it.\n\nSee  also  the  ALTERNATEEDITOR  environment  variable,  over which this option takes\nprecedence.\n",
                    "flag": "-a",
                    "long": "--alternate-editor",
                    "arg": "COMMAND"
                },
                {
                    "name": "-c, --create-frame",
                    "content": "Create a new frame instead of trying to use the current Emacs frame.\n",
                    "flag": "-c",
                    "long": "--create-frame"
                },
                {
                    "name": "-r --reuse-frame",
                    "content": "Reuse an existing frame if one exists, otherwise create a new frame.\n",
                    "flag": "-r",
                    "long": "--reuse-frame"
                },
                {
                    "name": "-F, --frame-parameters=ALIST",
                    "content": "Set the parameters of a newly-created frame.\n",
                    "flag": "-F",
                    "long": "--frame-parameters",
                    "arg": "ALIST"
                },
                {
                    "name": "-d, --display=DISPLAY",
                    "content": "Tell the server to display the files on the given display.\n",
                    "flag": "-d",
                    "long": "--display",
                    "arg": "DISPLAY"
                },
                {
                    "name": "-e, --eval",
                    "content": "Do not visit files but instead evaluate the arguments as Emacs Lisp expressions.\n",
                    "flag": "-e",
                    "long": "--eval"
                },
                {
                    "name": "-f, --server-file=FILENAME",
                    "content": "Use TCP configuration file FILENAME for communication.  Relative filenames  are  rela‐\ntive  to  \"~/.emacs.d/server/\" or \"$XDGCONFIGHOME/emacs/server/\", and the default is\n\"server\".\n\nSee also the EMACSSERVERFILE environment variable,  over  which  this  option  takes\nprecedence.\n",
                    "flag": "-f",
                    "long": "--server-file",
                    "arg": "FILENAME"
                },
                {
                    "name": "-n, --no-wait",
                    "content": "Return  immediately  without waiting for you to \"finish\" the buffer in Emacs.  If com‐\nbined with --eval, this option is ignored.\n",
                    "flag": "-n",
                    "long": "--no-wait"
                },
                {
                    "name": "-w, --timeout=N",
                    "content": "How long to wait, in seconds, for Emacs to respond before giving up.  The  default  is\n0, which means to wait forever.\n",
                    "flag": "-w",
                    "long": "--timeout",
                    "arg": "N"
                },
                {
                    "name": "--parent-id=ID",
                    "content": "Open an emacsclient frame as a client frame in the parent X window with id ID.\n",
                    "long": "--parent-id",
                    "arg": "ID"
                },
                {
                    "name": "-q, --quiet",
                    "content": "Do  not  let emacsclient display messages about waiting for Emacs or connecting to re‐\nmote server sockets.\n",
                    "flag": "-q",
                    "long": "--quiet"
                },
                {
                    "name": "-u, --suppress-output",
                    "content": "Do not let emacsclient display results returned from the  server.   Mostly  useful  in\ncombination  with  --eval when the evaluation performed is for side-effect rather than\nresult.\n",
                    "flag": "-u",
                    "long": "--suppress-output"
                },
                {
                    "name": "-s, --socket-name=FILENAME",
                    "content": "Use socket named FILENAME for  communication.   Relative  filenames  are  relative  to\n\"$XDGRUNTIMEDIR/emacs/\" or \"$TMPDIR/\".\n\nSee  also  the  EMACSSOCKETNAME  environment  variable, over which this option takes\nprecedence.\n",
                    "flag": "-s",
                    "long": "--socket-name",
                    "arg": "FILENAME"
                },
                {
                    "name": "-nw, -t, --tty",
                    "content": "Open a new Emacs frame on the current terminal.\n",
                    "flag": "-t",
                    "long": "--tty"
                },
                {
                    "name": "-T, --tramp=PREFIX",
                    "content": "Set PREFIX to add to filenames for Emacs to locate  files  on  remote  machines  using\nTRAMP.   This  is mostly useful in combination with using the Emacs server on a remote\nhost (either using TCP with --server-file, or a socket forwarded over SSH).\n\nSee also the EMACSCLIENTTRAMP environment variable,  over  which  this  option  takes\nprecedence.\n",
                    "flag": "-T",
                    "long": "--tramp",
                    "arg": "PREFIX"
                },
                {
                    "name": "-V, --version",
                    "content": "Print version information and exit.\n",
                    "flag": "-V",
                    "long": "--version"
                },
                {
                    "name": "-H, --help",
                    "content": "Print this usage information message and exit.\n",
                    "flag": "-H",
                    "long": "--help"
                }
            ]
        },
        "EXIT STATUS": {
            "content": "Normally,  the  exit status is 0.  If emacsclient shuts down due to Emacs signaling an error,\nthe exit status is 1.\n",
            "subsections": []
        },
        "ENVIRONMENT": {
            "content": "ALTERNATEEDITOR\nIf the Emacs server is not running, run the shell command in this environment variable\ninstead.  If set to the empty string, run \"emacs --daemon\" to start  Emacs  in  daemon\nmode,  and try to connect to it.  Will be overridden by the --alternate-editor option,\nif present.\n\nEMACSCLIENTTRAMP\nA prefix to add to filenames, intended to allow Emacs to locate files  on  remote  ma‐\nchines using TRAMP.  Will be overridden by the --tramp option, if present.\n\nEMACSSERVERFILE\nLook  in  this  file to discover where to find a TCP Emacs server.  Relative filenames\nare relative to \"~/.emacs.d/server/\" or \"$XDGCONFIGHOME/emacs/server/\", and the  de‐\nfault is \"server\".  Will be overridden by the --server-file option, if present.\n\nEMACSSOCKETNAME\nThe  filename  of the socket to use for communication with the Emacs server.  Relative\nfilenames are relative to \"$XDGRUNTIMEDIR/emacs/\" or \"$TMPDIR/\".  Will be overridden\nby the --socket-name option, if present.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "The program is documented fully in Using Emacs as a Server available via the Info system.\n\nThe XDG environment variables are described in detail in  the  XDG Base Directory Specifica‐\ntion.\n\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "This  manual  page was originally written by Stephane Bortzmeyer <bortzmeyer@debian.org>, for\nthe Debian GNU/Linux system, but is not specific to that system.\n",
            "subsections": []
        },
        "COPYING": {
            "content": "This manual page is in the public domain.\n\n\nGNU Emacs                                    2023-12-23                               EMACSCLIENT(1)",
            "subsections": []
        }
    },
    "summary": "emacsclient - tells a running Emacs to visit a file",
    "flags": [
        {
            "flag": "-a",
            "long": "--alternate-editor",
            "arg": "COMMAND",
            "description": "If the Emacs server is not running, run the specified shell command instead. If the empty string is specified, run \"emacs --daemon\" to start Emacs in daemon mode, and try to connect to it. See also the ALTERNATEEDITOR environment variable, over which this option takes precedence."
        },
        {
            "flag": "-c",
            "long": "--create-frame",
            "arg": null,
            "description": "Create a new frame instead of trying to use the current Emacs frame."
        },
        {
            "flag": "-r",
            "long": "--reuse-frame",
            "arg": null,
            "description": "Reuse an existing frame if one exists, otherwise create a new frame."
        },
        {
            "flag": "-F",
            "long": "--frame-parameters",
            "arg": "ALIST",
            "description": "Set the parameters of a newly-created frame."
        },
        {
            "flag": "-d",
            "long": "--display",
            "arg": "DISPLAY",
            "description": "Tell the server to display the files on the given display."
        },
        {
            "flag": "-e",
            "long": "--eval",
            "arg": null,
            "description": "Do not visit files but instead evaluate the arguments as Emacs Lisp expressions."
        },
        {
            "flag": "-f",
            "long": "--server-file",
            "arg": "FILENAME",
            "description": "Use TCP configuration file FILENAME for communication. Relative filenames are rela‐ tive to \"~/.emacs.d/server/\" or \"$XDGCONFIGHOME/emacs/server/\", and the default is \"server\". See also the EMACSSERVERFILE environment variable, over which this option takes precedence."
        },
        {
            "flag": "-n",
            "long": "--no-wait",
            "arg": null,
            "description": "Return immediately without waiting for you to \"finish\" the buffer in Emacs. If com‐ bined with --eval, this option is ignored."
        },
        {
            "flag": "-w",
            "long": "--timeout",
            "arg": "N",
            "description": "How long to wait, in seconds, for Emacs to respond before giving up. The default is 0, which means to wait forever."
        },
        {
            "flag": "",
            "long": "--parent-id",
            "arg": "ID",
            "description": "Open an emacsclient frame as a client frame in the parent X window with id ID."
        },
        {
            "flag": "-q",
            "long": "--quiet",
            "arg": null,
            "description": "Do not let emacsclient display messages about waiting for Emacs or connecting to re‐ mote server sockets."
        },
        {
            "flag": "-u",
            "long": "--suppress-output",
            "arg": null,
            "description": "Do not let emacsclient display results returned from the server. Mostly useful in combination with --eval when the evaluation performed is for side-effect rather than result."
        },
        {
            "flag": "-s",
            "long": "--socket-name",
            "arg": "FILENAME",
            "description": "Use socket named FILENAME for communication. Relative filenames are relative to \"$XDGRUNTIMEDIR/emacs/\" or \"$TMPDIR/\". See also the EMACSSOCKETNAME environment variable, over which this option takes precedence."
        },
        {
            "flag": "-t",
            "long": "--tty",
            "arg": null,
            "description": "Open a new Emacs frame on the current terminal."
        },
        {
            "flag": "-T",
            "long": "--tramp",
            "arg": "PREFIX",
            "description": "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 the EMACSCLIENTTRAMP environment variable, over which this option takes precedence."
        },
        {
            "flag": "-V",
            "long": "--version",
            "arg": null,
            "description": "Print version information and exit."
        },
        {
            "flag": "-H",
            "long": "--help",
            "arg": null,
            "description": "Print this usage information message and exit."
        }
    ],
    "examples": [],
    "see_also": [],
    "tldr": {
        "source": "official",
        "description": "Open files in an existing Emacs server.",
        "examples": [
            {
                "description": "Open a file in an existing Emacs server (using GUI if available)",
                "command": "emacsclient {{path/to/file}}"
            },
            {
                "description": "Open a file in console mode (without an X window)",
                "command": "emacsclient {{-nw|--no-window-system}} {{path/to/file}}"
            },
            {
                "description": "Open a file in a new Emacs window",
                "command": "emacsclient {{-c|--create-frame}} {{path/to/file}}"
            },
            {
                "description": "Evaluate a command, printing the output to `stdout`, and then quit",
                "command": "emacsclient {{-e|--eval}} '({{command}})'"
            },
            {
                "description": "Specify an alternative editor in case no Emacs server is running",
                "command": "emacsclient {{-a|--alternate-editor}} {{editor}} {{path/to/file}}"
            },
            {
                "description": "Stop a running Emacs server and all its instances, asking for confirmation on unsaved files",
                "command": "emacsclient {{-e|--eval}} '(save-buffers-kill-emacs)'"
            }
        ]
    }
}