1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-05-07 13:53:19 -07:00

; Improve documentation of Emacs server-client protocol

* lib-src/emacsclient.c (main):
* lisp/server.el (server-process-filter): Document the protocol
requirements regarding the terminating newline.  (Bug#80807)
This commit is contained in:
Eli Zaretskii 2026-05-02 12:35:48 +03:00
parent 2207a58899
commit e575817e8f
2 changed files with 14 additions and 4 deletions

View file

@ -2257,6 +2257,11 @@ main (int argc, char **argv)
char *p = recv_buf;
for (char *end_p = p; end_p < recv_buf + nrecv; p = end_p)
{
/* An unquoted newline ends a server command. Keep reading,
possibly growing the buffer, until a buffer with a newline
is received. This handles commands with arbitrary-long
arguments (actually needed in 'print' and 'error' commands,
which are followed by strings). */
end_p = memchr (p, '\n', recv_buf + nrecv - p);
if (!end_p)
break;
@ -2288,7 +2293,8 @@ main (int argc, char **argv)
}
else if (strprefix ("-print ", p))
{
/* -print STRING: Print STRING on the terminal. */
/* -print STRING: Print STRING, preceeded by a newline, on
the terminal. */
if (!suppress_output)
{
char *str = unquote_argument (p + strlen ("-print "));
@ -2299,8 +2305,10 @@ main (int argc, char **argv)
}
else if (strprefix ("-print-nonl ", p))
{
/* -print-nonl STRING: Print STRING on the terminal.
Used to continue a preceding -print command. */
/* -print-nonl STRING: Print STRING on the terminal
without a preceding newlin. Used to continue a
preceding -print command. Nowadays used only for
servers in Emacs versions before 31. */
if (!suppress_output)
{
char *str = unquote_argument (p + strlen ("-print-nonl "));

View file

@ -1143,7 +1143,9 @@ The following commands are accepted by the client:
`-print-nonl STRING'
Print STRING on stdout. Used to continue a
preceding -print command that would be too big to send
in a single message.
in a single message. Unused in the server since Emacs 31;
mentioned here only for completeness, because the client
needs to support it when it connects to older Emacsen.
`-error DESCRIPTION'
Signal an error and delete process PROC.