]> git.eshelyaron.com Git - emacs.git/commitdiff
Jsonrpc: allow method identifiers to be simply strings
authorJoão Távora <joaotavora@gmail.com>
Wed, 8 Nov 2023 14:22:23 +0000 (08:22 -0600)
committerEshel Yaron <me@eshelyaron.com>
Thu, 14 Dec 2023 12:11:26 +0000 (13:11 +0100)
* lisp/jsonrpc.el (jsonrpc-connection-send): Support string methods.

(cherry picked from commit 8de749faa14f6a1566a5a92b84a6f834944eb22f)

lisp/jsonrpc.el

index 7726712d0566c435493174030935ead5c7fa8371..f7ccc8d274529f4acbcb9d8299b229a2daa54475 100644 (file)
@@ -443,7 +443,9 @@ connection object, called when the process dies.")
   (when method
     (plist-put args :method
                (cond ((keywordp method) (substring (symbol-name method) 1))
-                     ((and method (symbolp method)) (symbol-name method)))))
+                     ((symbolp method) (symbol-name method))
+                     ((stringp method) method)
+                     (t (error "[jsonrpc] invalid method %s" method)))))
   (let* ( (message `(:jsonrpc "2.0" ,@args))
           (json (jsonrpc--json-encode message))
           (headers