Revert "Extend emacs server protocol for empty arguments"

This reverts this change:

  Author:     Andreas Schwab <schwab@linux-m68k.org>
  AuthorDate: Sun Feb 8 12:34:02 2026 +0100

    Extend emacs server protocol for empty arguments

    An empty argument is represented by &0.  On the receiving side, &0 is
    replaced by nothing.

    * lisp/server.el (server-unquote-arg): Replace "&0" by nothing.
    (server-quote-arg): Produce "&0" for an empty string.
    * lib-src/emacsclient.c (quote_argument): Produce "&0" for an
    empty string.
    (unquote_argument): Replace "&0" by nothing.   (Bug#80356)

The bug in question was already fixed by this change:

  Author:     Sean Whitton <spwhitton@spwhitton.name>
  AuthorDate: Fri Nov 7 12:33:21 2025 +0000

    Don't discard empty string arguments from emacsclient

    * lisp/server.el (server--process-filter-1): Don't discard empty
    string arguments from emacsclient.
    (server-eval-args-left):
    * doc/emacs/misc.texi (emacsclient Options):
    * etc/NEWS: Document the change.
This commit is contained in:
Sean Whitton 2026-02-08 16:52:12 +00:00
parent 01d8abea04
commit 7fd6fa4a8b
2 changed files with 9 additions and 17 deletions

View file

@ -867,10 +867,8 @@ send_to_emacs (HSOCKET s, const char *data)
static void static void
quote_argument (HSOCKET s, const char *str) quote_argument (HSOCKET s, const char *str)
{ {
char *copy = xmalloc (strlen (str) * 2 + 3); char *copy = xmalloc (strlen (str) * 2 + 1);
char *q = copy; char *q = copy;
if (*str == '\0')
*q++ = '&', *q++ = '0';
if (*str == '-') if (*str == '-')
*q++ = '&', *q++ = *str++; *q++ = '&', *q++ = *str++;
for (; *str; str++) for (; *str; str++)
@ -912,8 +910,6 @@ unquote_argument (char *str)
c = ' '; c = ' ';
else if (c == 'n') else if (c == 'n')
c = '\n'; c = '\n';
else if (c == '0')
continue;
} }
*q++ = c; *q++ = c;
} }

View file

@ -531,7 +531,6 @@ See `server-quote-arg' and `server-process-filter'."
(?& "&") (?& "&")
(?- "-") (?- "-")
(?n "\n") (?n "\n")
(?0 "")
(_ " "))) (_ " ")))
arg t t)) arg t t))
@ -539,19 +538,16 @@ See `server-quote-arg' and `server-process-filter'."
"In ARG, insert a & before each &, each space, each newline, and -. "In ARG, insert a & before each &, each space, each newline, and -.
Change spaces to underscores, too, so that the return value never Change spaces to underscores, too, so that the return value never
contains a space. contains a space.
An empty ARG is represented by &0.
See `server-unquote-arg' and `server-process-filter'." See `server-unquote-arg' and `server-process-filter'."
(if (equal arg "") (replace-regexp-in-string
"&0" "[-&\n ]" (lambda (s)
(replace-regexp-in-string (pcase (aref s 0)
"[-&\n ]" (lambda (s) (?& "&&")
(pcase (aref s 0) (?- "&-")
(?& "&&") (?\n "&n")
(?- "&-") (?\s "&_")))
(?\n "&n") arg t t))
(?\s "&_")))
arg t t)))
(defun server-send-string (proc string) (defun server-send-string (proc string)
"A wrapper around `process-send-string' for logging." "A wrapper around `process-send-string' for logging."