File: server.el.html

This library allows Emacs to operate as a server for other processes.

Load this library and do M-x server-start to enable Emacs as a server. Emacs opens up a socket for communication with clients. If there are no client buffers to edit, server-edit acts like (switch-to-buffer
(other-buffer))

When some other program runs "the editor" to edit a file,
"the editor" can be the Emacs client program ../lib-src/emacsclient.
This program transmits the file names to Emacs through the server subprocess, and Emacs visits them and lets you edit them.

Note that any number of clients may dispatch files to Emacs to be edited.

When you finish editing a Server buffer, again call server-edit to mark that buffer as done for the client and switch to the next Server buffer. When all the buffers for a client have been edited and exited with server-edit, the client "editor" will return to the program that invoked it.

Your editing commands and Emacs's display output go to and from the terminal in the usual way. Thus, server operation is possible only when Emacs can talk to the terminal at the time you invoke the client. This is possible in four cases:

1. On a window system, where Emacs runs in one window and the
   program that wants to use "the editor" runs in another.

2. On a multi-terminal system, where Emacs runs on one terminal and
   the program that wants to use "the editor" runs on another.

3. When the program that wants to use "the editor" is running as a
   subprocess of Emacs.

4. On a system with job control, when Emacs is suspended, the
   program that wants to use "the editor" will stop and display
   "Waiting for Emacs...". It can then be suspended, and Emacs can
   be brought into the foreground for editing. When done editing,
   Emacs is suspended again, and the client program is brought into
   the foreground.

The buffer local variable server-buffer-clients lists the clients who are waiting for this buffer to be edited. The global variable server-clients lists all the waiting clients, and which files are yet to be edited for each.

Defined variables (28)

server--external-socket-initializedWhen an external socket is passed into Emacs, we need to call
server-after-make-frame-hookHook run when the Emacs server creates a client frame.
server-auth-dirDirectory for server authentication files.
server-auth-keyServer authentication key.
server-bufferBuffer used internally by Emacs’s server.
server-buffer-clientsList of client processes requesting editing of current buffer.
server-client-instructionsIf non-nil, display instructions on how to exit the client on connection.
server-clientsList of current server clients.
server-done-hookHook run when done editing a buffer for the Emacs server.
server-existing-bufferNon-nil means the buffer existed before the server was asked to visit it.
server-hostThe name or IP address to use as host address of the server process.
server-kill-buffer-runningNon-nil while ‘server-kill-buffer’ or ‘server-buffer-done’ is running.
server-kill-new-buffersWhether to kill buffers when done with them.
server-logIf non-nil, log the server’s inputs and outputs in the ‘server-buffer’.
server-log-time-functionFunction to generate timestamps for ‘server-buffer’.
server-modeNon-nil if Server mode is enabled.
server-mode-hookHook run after entering or leaving ‘server-mode’.
server-msg-sizeMaximum size of a message sent to a client.
server-nameThe name of the Emacs server, if this Emacs process creates one.
server-portThe port number that the server process should listen on.
server-processThe current server process.
server-raise-frameIf non-nil, raise frame when switching to a buffer.
server-socket-dirThe directory in which to place the server socket.
server-switch-hookHook run when switching to a buffer for the Emacs server.
server-temp-file-regexpRegexp matching names of temporary files.
server-use-tcpIf non-nil, use TCP sockets instead of local sockets.
server-visit-hookHook run when visiting a file for the Emacs server.
server-windowSpecification of the window to use for selecting Emacs server buffers.

Defined functions (46)

server--create-frame(NOWAIT PROC PARAMETERS)
server--on-display-p(FRAME DISPLAY)
server-add-client(PROC)
server-buffer-done(BUFFER &optional FOR-KILLING)
server-clients-with(PROPERTY VALUE)
server-create-dumb-terminal-frame(NOWAIT PROC &optional PARAMETERS)
server-create-tty-frame(TTY TYPE PROC &optional PARAMETERS)
server-create-window-system-frame(DISPLAY NOWAIT PROC PARENT-ID &optional PARAMETERS)
server-delete-client(PROC &optional NOFRAME)
server-done()
server-edit(&optional ARG)
server-edit-abort()
server-ensure-safe-dir(DIR)
server-eval-and-print(EXPR PROC)
server-eval-at(SERVER FORM)
server-execute(PROC FILES NOWAIT COMMANDS DONTKILL FRAME TTY-NAME)
server-execute-continuation(PROC)
server-force-delete(&optional NAME)
server-force-stop()
server-generate-key()
server-get-auth-key()
server-goto-line-column(LINE-COL)
server-goto-toplevel(PROC)
server-handle-delete-frame(FRAME)
server-handle-suspend-tty(TERMINAL)
server-kill-buffer()
server-kill-emacs-query-function()
server-log(STRING &optional CLIENT)
server-mode(&optional ARG)
server-process-filter(PROC STRING)
server-quote-arg(ARG)
server-reply-print(QTEXT PROC)
server-return-error(PROC ERR)
server-running-p(&optional NAME)
server-save-buffers-kill-terminal(ARG)
server-select-display(DISPLAY)
server-send-string(PROC STRING)
server-sentinel(PROC MSG)
server-start(&optional LEAVE-DEAD INHIBIT-PROMPT)
server-switch-buffer(&optional NEXT-BUFFER KILLED-ONE FILEPOS THIS-FRAME-ONLY)
server-temp-file-p(&optional BUFFER)
server-unload-function()
server-unquote-arg(ARG)
server-unselect-display(FRAME)
server-visit-files(FILES PROC &optional NOWAIT)
server-with-environment(ENV VARS &rest BODY)

Defined faces (0)