emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master da4f1fa550f: server-eval-at: Signal more specific condition on un


From: Sean Whitton
Subject: master da4f1fa550f: server-eval-at: Signal more specific condition on unreadable result
Date: Wed, 8 Mar 2023 19:09:23 -0500 (EST)

branch: master
commit da4f1fa550f753e76c611b313d4f00987daed5ad
Author: Sean Whitton <spwhitton@spwhitton.name>
Commit: Sean Whitton <spwhitton@spwhitton.name>

    server-eval-at: Signal more specific condition on unreadable result
    
    * lisp/server.el (server-return-invalid-read-syntax): New error
    signal.
    (server-eval-at): Re-signal invalid-read-syntax as
    server-return-invalid-read-syntax (bug#61658).
---
 lisp/server.el | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/lisp/server.el b/lisp/server.el
index 35b38ef8fa6..89aedc72d52 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -1929,12 +1929,22 @@ This sets the variable `server-stop-automatically' 
(which see)."
   ;; continue standard unloading
   nil)
 
+(define-error 'server-return-invalid-read-syntax
+              "Emacs server returned unreadable result of evaluation"
+              'invalid-read-syntax)
+
 (defun server-eval-at (server form)
   "Contact the Emacs server named SERVER and evaluate FORM there.
-Returns the result of the evaluation, or signals an error if it
-cannot contact the specified server.  For example:
+Returns the result of the evaluation.  For example:
   (server-eval-at \"server\" \\='(emacs-pid))
-returns the process ID of the Emacs instance running \"server\"."
+returns the process ID of the Emacs instance running \"server\".
+
+This function signals `error' if it could not contact the server.
+
+This function signals `server-return-invalid-read-syntax' if it
+couldn't read the result of evaluation printed by the server.
+This will occur whenever the result of evaluating FORM is something
+not readably printable."
   (let* ((server-dir (if server-use-tcp server-auth-dir server-socket-dir))
          (server-file (expand-file-name server server-dir))
          (coding-system-for-read 'binary)
@@ -1980,8 +1990,14 @@ returns the process ID of the Emacs instance running 
\"server\"."
                                          (progn (skip-chars-forward "^\n")
                                                 (point))))))
        (if (not (equal answer ""))
-           (read (decode-coding-string (server-unquote-arg answer)
-                                       'emacs-internal)))))))
+            (condition-case err
+               (read
+                 (decode-coding-string (server-unquote-arg answer)
+                                      'emacs-internal))
+              ;; Re-signal with a more specific condition.
+              (invalid-read-syntax
+               (signal 'server-return-invalid-read-syntax
+                       (cdr err)))))))))
 
 
 (provide 'server)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]