mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2026-09-10 07:46:51 -04:00
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)
This commit is contained in:
parent
78fc5e2833
commit
7586a5474c
|
|
@ -867,8 +867,10 @@ send_to_emacs (HSOCKET s, const char *data)
|
|||
static void
|
||||
quote_argument (HSOCKET s, const char *str)
|
||||
{
|
||||
char *copy = xmalloc (strlen (str) * 2 + 1);
|
||||
char *copy = xmalloc (strlen (str) * 2 + 3);
|
||||
char *q = copy;
|
||||
if (*str == '\0')
|
||||
*q++ = '&', *q++ = '0';
|
||||
if (*str == '-')
|
||||
*q++ = '&', *q++ = *str++;
|
||||
for (; *str; str++)
|
||||
|
|
@ -910,6 +912,8 @@ unquote_argument (char *str)
|
|||
c = ' ';
|
||||
else if (c == 'n')
|
||||
c = '\n';
|
||||
else if (c == '0')
|
||||
continue;
|
||||
}
|
||||
*q++ = c;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -531,6 +531,7 @@ See `server-quote-arg' and `server-process-filter'."
|
|||
(?& "&")
|
||||
(?- "-")
|
||||
(?n "\n")
|
||||
(?0 "")
|
||||
(_ " ")))
|
||||
arg t t))
|
||||
|
||||
|
|
@ -538,16 +539,19 @@ See `server-quote-arg' and `server-process-filter'."
|
|||
"In ARG, insert a & before each &, each space, each newline, and -.
|
||||
Change spaces to underscores, too, so that the return value never
|
||||
contains a space.
|
||||
An empty ARG is represented by &0.
|
||||
|
||||
See `server-unquote-arg' and `server-process-filter'."
|
||||
(replace-regexp-in-string
|
||||
"[-&\n ]" (lambda (s)
|
||||
(pcase (aref s 0)
|
||||
(?& "&&")
|
||||
(?- "&-")
|
||||
(?\n "&n")
|
||||
(?\s "&_")))
|
||||
arg t t))
|
||||
(if (equal arg "")
|
||||
"&0"
|
||||
(replace-regexp-in-string
|
||||
"[-&\n ]" (lambda (s)
|
||||
(pcase (aref s 0)
|
||||
(?& "&&")
|
||||
(?- "&-")
|
||||
(?\n "&n")
|
||||
(?\s "&_")))
|
||||
arg t t)))
|
||||
|
||||
(defun server-send-string (proc string)
|
||||
"A wrapper around `process-send-string' for logging."
|
||||
|
|
|
|||
Loading…
Reference in a new issue