From eda9a819ce5cae976062e744ad2f7ee3e08fd3f6 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 16 Apr 2026 23:31:19 -0700 Subject: [PATCH] Append newline to server -error commands MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem reported by Zhengyi Fu (bug#80844). * lisp/server.el (server--process-filter-1, server-return-error) (server-edit-abort): Append newline to -error commands, too. Otherwise emacsclient has no reliable way to find the end of the error command’s argument, except to wait for EOF which is undesirable since the Emacs server keeps the socket open for a while, waiting for emacsclient to exit. --- lisp/server.el | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lisp/server.el b/lisp/server.el index f5dea9c590f..b0f11cf2dd6 100644 --- a/lisp/server.el +++ b/lisp/server.el @@ -1220,7 +1220,7 @@ The following commands are accepted by the client: ;; visible for some reason. (server--message-sit-for 2 "Authentication failed") (server-send-string - proc (concat "-error " (server-quote-arg "Authentication failed"))) + proc (concat "-error " (server-quote-arg "Authentication failed") "\n")) (unless (eq system-type 'windows-nt) (let ((terminal (process-get proc 'terminal))) ;; Only delete the terminal if it is non-nil. @@ -1576,7 +1576,8 @@ invocations of \"emacs\".") (server--message-sit-for 2 (error-message-string err)) (server-send-string proc (concat "-error " (server-quote-arg - (error-message-string err)))) + (error-message-string err)) + "\n")) (server-log (error-message-string err) proc) (unless (eq system-type 'windows-nt) (let ((terminal (process-get proc 'terminal))) @@ -1813,7 +1814,7 @@ To abort an edit instead of saying \"Done\", use \\[server-edit-abort]." (mapc (lambda (proc) (server-send-string proc (concat "-error " - (server-quote-arg "Aborted by the user")))) + (server-quote-arg "Aborted by the user") "\n"))) server-clients) (message "This buffer has no clients")))