]> git.eshelyaron.com Git - emacs.git/commitdiff
Simplify jsonrpc status setting
authorJoão Távora <joaotavora@gmail.com>
Sun, 10 Jun 2018 06:16:41 +0000 (07:16 +0100)
committerJoão Távora <joaotavora@gmail.com>
Sun, 10 Jun 2018 06:16:41 +0000 (07:16 +0100)
* eglot.el (eglot--connect): Don't set jsonrpc-status.
(eglot-clear-status): New interactive command.
(eglot--mode-line-format): Simplify.

* jsonrpc.el (jsonrpc--async-request-1): Simplify.
(jsonrpc-connection): Replace status with last-error.
(jsonrpc-clear-status): Delete.
(jsonrpc--connection-receive): Set last-error.

lisp/progmodes/eglot.el

index 13413ab07fcbd24a2e237cc87af8a9ec6dbac770..f8bd32cd97a9863c077cfc89d87ba38bda445b90 100644 (file)
@@ -423,7 +423,6 @@ appeases checkdoc, that's all."
                    :initializationOptions (eglot-initialization-options server)
                    :capabilities (eglot-client-capabilities server)))
           (setf (eglot--capabilities server) capabilities)
-          (setf (jsonrpc-status server) nil)
           (dolist (buffer (buffer-list))
             (with-current-buffer buffer
               (eglot--maybe-activate-editing-mode server)))
@@ -613,6 +612,11 @@ that case, also signal textDocument/didOpen."
 
 (add-hook 'find-file-hook 'eglot--maybe-activate-editing-mode)
 
+(defun eglot-clear-status (server)
+  "Clear the last JSONRPC error for SERVER."
+  (interactive (list (jsonrpc-current-connection-or-lose)))
+  (setf (jsonrpc-last-error server) nil))
+
 \f
 ;;; Mode-line, menu and other sugar
 ;;;
@@ -652,7 +656,7 @@ Uses THING, FACE, DEFS and PREPEND."
                (pending (and server (hash-table-count
                                      (jsonrpc--request-continuations server))))
                (`(,_id ,doing ,done-p ,detail) (and server (eglot--spinner server)))
-               (`(,status ,serious-p) (and server (jsonrpc-status server))))
+               (last-error (and server (jsonrpc-last-error server))))
     (append
      `(,(eglot--mode-line-props "eglot" 'eglot-mode-line nil))
      (when nick
@@ -662,11 +666,12 @@ Uses THING, FACE, DEFS and PREPEND."
                  (mouse-1 eglot-events-buffer "go to events buffer")
                  (mouse-2 eglot-shutdown      "quit server")
                  (mouse-3 eglot-reconnect     "reconnect to server")))
-         ,@(when serious-p
+         ,@(when last-error
              `("/" ,(eglot--mode-line-props
                      "error" 'compilation-mode-line-fail
-                     '((mouse-3 jsonrpc-clear-status  "clear this status"))
-                     (format "An error occured: %s\n" status))))
+                     '((mouse-3 eglot-clear-status  "clear this status"))
+                     (format "An error occured: %s\n" (plist-get last-error
+                                                                 :message)))))
          ,@(when (and doing (not done-p))
              `("/" ,(eglot--mode-line-props
                      (format "%s%s" doing