emacs-diffs
[Top][All Lists]
Advanced

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

master e9258a882a9: Eglot: Replace eglot-execute-command with new eglot-


From: João Távora
Subject: master e9258a882a9: Eglot: Replace eglot-execute-command with new eglot-execute
Date: Tue, 9 May 2023 05:37:45 -0400 (EDT)

branch: master
commit e9258a882a9b54f2992ae8ffd73e3da6bb3c4556
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>

    Eglot: Replace eglot-execute-command with new eglot-execute
    
    Hopefully helps with https://github.com/joaotavora/eglot/discussions/1070 
and
    https://github.com/emacs-sideline/sideline/issues/5
    
    * lisp/progmodes/eglot.el (eglot-execute-command): Obsolete.
    (eglot-execute): New generic.
    (eglot--read-execute-code-action): Use eglot-execute.
---
 lisp/progmodes/eglot.el | 35 ++++++++++++++++++-----------------
 1 file changed, 18 insertions(+), 17 deletions(-)

diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index dc8d4674425..66d893a14b5 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -724,8 +724,23 @@ treated as in `eglot--dbind'."
 (cl-defgeneric eglot-handle-notification (server method &rest params)
   "Handle SERVER's METHOD notification with PARAMS.")
 
-(cl-defgeneric eglot-execute-command (server command arguments)
-  "Ask SERVER to execute COMMAND with ARGUMENTS.")
+(cl-defgeneric eglot-execute-command (_ _ _)
+  (declare (obsolete eglot-execute "30.1"))
+  (:method
+   (server command arguments)
+   (eglot--request server :workspace/executeCommand
+                   `(:command ,(format "%s" command) :arguments ,arguments))))
+
+(cl-defgeneric eglot-execute (server action)
+  "Ask SERVER to execute ACTION.
+ACTION is an LSP object of either `CodeAction' or `Command' type."
+  (:method
+   (server action) "Default implementation."
+   (eglot--dcase action
+     (((Command)) (eglot--request server :workspace/executeCommand action))
+     (((CodeAction) edit command)
+      (when edit (eglot--apply-workspace-edit edit))
+      (when command (eglot--request server :workspace/executeCommand 
action))))))
 
 (cl-defgeneric eglot-initialization-options (server)
   "JSON object to send under `initializationOptions'."
@@ -2181,13 +2196,6 @@ still unanswered LSP requests to the server\n")))
   (when (memq 'disallow-unknown-methods eglot-strict-mode)
     (jsonrpc-error "Unknown request method `%s'" method)))
 
-(cl-defmethod eglot-execute-command
-  (server command arguments)
-  "Execute COMMAND on SERVER with `:workspace/executeCommand'.
-COMMAND is a symbol naming the command."
-  (eglot--request server :workspace/executeCommand
-                  `(:command ,(format "%s" command) :arguments ,arguments)))
-
 (cl-defmethod eglot-handle-notification
   (_server (_method (eql window/showMessage)) &key type message)
   "Handle notification window/showMessage."
@@ -3465,14 +3473,7 @@ at point.  With prefix argument, prompt for ACTION-KIND."
                                           default-action)
                                   menu-items nil t nil nil default-action)
                                  menu-items))))))
-    (eglot--dcase chosen
-      (((Command) command arguments)
-       (eglot-execute-command server (intern command) arguments))
-      (((CodeAction) edit command)
-       (when edit (eglot--apply-workspace-edit edit))
-       (when command
-         (eglot--dbind ((Command) command arguments) command
-           (eglot-execute-command server (intern command) arguments)))))))
+    (eglot-execute server chosen)))
 
 (defmacro eglot--code-action (name kind)
   "Define NAME to execute KIND code action."



reply via email to

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