[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/eglot 2da7d92 50/69: Simplify JSONRPC status setting
From: |
Jo�o T�vora |
Subject: |
[elpa] externals/eglot 2da7d92 50/69: Simplify JSONRPC status setting |
Date: |
Fri, 22 Jun 2018 11:55:02 -0400 (EDT) |
branch: externals/eglot
commit 2da7d9285d6edc271d7619f8be6e0d6e5c4e5d2c
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
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.
---
eglot.el | 15 ++++++++++-----
jsonrpc.el | 24 +++++++++++-------------
2 files changed, 21 insertions(+), 18 deletions(-)
diff --git a/eglot.el b/eglot.el
index 13413ab..f8bd32c 100644
--- a/eglot.el
+++ b/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
diff --git a/jsonrpc.el b/jsonrpc.el
index 36f45ef..094b353 100644
--- a/jsonrpc.el
+++ b/jsonrpc.el
@@ -171,9 +171,9 @@ object, using the keywords `:code', `:message' and `:data'."
:initform #'ignore
:initarg :notification-dispatcher
:documentation "Dispatcher for remotely invoked notifications.")
- (status
- :initform `(:unknown nil) :accessor jsonrpc-status
- :documentation "Status (WHAT SERIOUS-P) as declared by the server.")
+ (last-error
+ :accessor jsonrpc-last-error
+ :documentation "Last JSONRPC error message received from endpoint.")
(-request-continuations
:initform (make-hash-table)
:accessor jsonrpc--request-continuations
@@ -429,7 +429,7 @@ originated."
message
(let (continuations)
(jsonrpc-log-event connection message 'server)
- (when error (setf (jsonrpc-status connection) `(,error t)))
+ (setf (jsonrpc-last-error connection) error)
(cond
(;; A remote request
(and method id)
@@ -516,11 +516,6 @@ originated."
(interactive (list (jsonrpc-current-connection-or-lose)))
(clrhash (jsonrpc--request-continuations connection)))
-(defun jsonrpc-clear-status (connection)
- "Clear most recent error message from CONNECTION."
- (interactive (list (jsonrpc-current-connection-or-lose)))
- (setf (jsonrpc-status connection) nil))
-
(defun jsonrpc--call-deferred (connection)
"Call CONNECTION's deferred actions, who may again defer themselves."
(when-let ((actions (hash-table-values (jsonrpc--deferred-actions
connection))))
@@ -631,13 +626,16 @@ TIMEOUT is nil)."
(list (or success-fn
(jsonrpc-lambda (&rest _ignored)
(jsonrpc--debug
- connection (jsonrpc-obj :message "success ignored"
:id id))))
+ connection (jsonrpc-obj :message "success ignored"
+ :id id))))
(or error-fn
(jsonrpc-lambda (&key code message &allow-other-keys)
- (setf (jsonrpc-status connection) `(,message t))
(jsonrpc--debug
- connection (jsonrpc-obj :message "error ignored,
status set"
- :id id :error code))))
+ connection (jsonrpc-obj
+ :message
+ (format "error ignored, status set (%s)"
+ message)
+ :id id :error code))))
(setq timer (funcall make-timer)))
(jsonrpc--request-continuations connection))
(list id timer)))
- [elpa] externals/eglot 44e9647 46/69: Simplify JSONRPC connection shutdown, (continued)
- [elpa] externals/eglot 44e9647 46/69: Simplify JSONRPC connection shutdown, Jo�o T�vora, 2018/06/22
- [elpa] externals/eglot 47b957d 65/69: Let's not send Content-type for now., Jo�o T�vora, 2018/06/22
- [elpa] externals/eglot 61d1276 66/69: Fix another bug in jsonrpc-connection-send, Jo�o T�vora, 2018/06/22
- [elpa] externals/eglot 2917214 47/69: Merge master into jsonrpc-refactor, Jo�o T�vora, 2018/06/22
- [elpa] externals/eglot f730fff 48/69: Merge branch 'master' into jsonrpc-refactor, Jo�o T�vora, 2018/06/22
- [elpa] externals/eglot aaca7de 60/69: Fix ridiculous bug, Jo�o T�vora, 2018/06/22
- [elpa] externals/eglot d87f4bf 55/69: jsonrpc--log-event should also be private, Jo�o T�vora, 2018/06/22
- [elpa] externals/eglot a65d3f4 53/69: Make message and warning helpers private, Jo�o T�vora, 2018/06/22
- [elpa] externals/eglot 9e9dc57 30/69: Merge branch 'master' into jsonrpc-refactor (using regular merge), Jo�o T�vora, 2018/06/22
- [elpa] externals/eglot 6c9d41e 38/69: Add reasonably sophisticated deferred action tests, Jo�o T�vora, 2018/06/22
- [elpa] externals/eglot 2da7d92 50/69: Simplify JSONRPC status setting,
Jo�o T�vora <=
- [elpa] externals/eglot 69a622a 64/69: Fix some typos, Jo�o T�vora, 2018/06/22
- [elpa] externals/eglot 7371f68 57/69: * jsonrpc.el: Rewrite commentary., Jo�o T�vora, 2018/06/22
- [elpa] externals/eglot 6531c8b 58/69: Merge branch 'master' into jsonrpc-refactor, Jo�o T�vora, 2018/06/22
- [elpa] externals/eglot 59cc3fb 61/69: jsonrpc-connection-receive is now a public convenience function, Jo�o T�vora, 2018/06/22
- [elpa] externals/eglot d371f05 49/69: Request dispatcher's return value determines response, Jo�o T�vora, 2018/06/22
- [elpa] externals/eglot 0f20fdf 68/69: Tiny README.md change, Jo�o T�vora, 2018/06/22
- [elpa] externals/eglot cef3c29 22/69: Heroically merge master into jsonrpc-refactor (using imerge), Jo�o T�vora, 2018/06/22
- [elpa] externals/eglot a4441c6 37/69: Merge master into jsonrpc-refactor (using imerge), Jo�o T�vora, 2018/06/22
- [elpa] externals/eglot 0e44b27 27/69: jsonrpc.el uses classes and generic functions, Jo�o T�vora, 2018/06/22
- [elpa] externals/eglot 856a224 62/69: Simplify jsonrpc-connection-send, Jo�o T�vora, 2018/06/22