From 4d680281947ad05399c9b3fc9274ef33c07d3855 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Sun, 10 Jun 2018 07:16:41 +0100 Subject: [PATCH] Simplify jsonrpc status setting * 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 | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 13413ab07fc..f8bd32cd97a 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -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)) + ;;; 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 -- 2.39.2