[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/elpa 889ef20 085/139: Tweak the async request engine.
From: |
João Távora |
Subject: |
[elpa] externals/elpa 889ef20 085/139: Tweak the async request engine. |
Date: |
Mon, 14 May 2018 09:53:41 -0400 (EDT) |
branch: externals/elpa
commit 889ef20069d7d6511ce7f8f5b13928f3e7100eb5
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Tweak the async request engine.
* eglot.el (eglot--request): Return the continuation id.
(eglot--lambda): Move up in the file.
(eglot--sync-request): Use a catch-tag.
---
eglot.el | 44 ++++++++++++++++++++++++++------------------
1 file changed, 26 insertions(+), 18 deletions(-)
diff --git a/eglot.el b/eglot.el
index 068e2ca..3bed8d9 100644
--- a/eglot.el
+++ b/eglot.el
@@ -593,7 +593,9 @@ is a symbol saying if this is a client or server
originated."
method
params
&key success-fn error-fn timeout-fn (async-p t))
- "Make a request to PROCESS, expecting a reply."
+ "Make a request to PROCESS, expecting a reply.
+Return the ID of this request, unless ASYNC-P is nil, in which
+case never returns locally."
(let* ((id (eglot--next-request-id))
(timeout-fn
(or timeout-fn
@@ -658,22 +660,34 @@ is a symbol saying if this is a client or server
originated."
(when (memq timeout-timer timer-list)
(eglot--message
"(request) Last-change cancelling timer for continuation %s" id)
- (cancel-timer timeout-timer))))))))
+ (cancel-timer timeout-timer))))))
+ ;; Finally, return the id.
+ id))
+
+(cl-defmacro eglot--lambda (cl-lambda-list &body body)
+ (declare (indent 1) (debug (sexp &rest form)))
+ `(cl-function
+ (lambda ,cl-lambda-list
+ ,@body)))
(defun eglot--sync-request (proc method params)
"Like `eglot--request' for PROC, METHOD and PARAMS, but synchronous.
Meaning only return locally if successful, otherwise exit non-locally."
(let* ((timeout-error-sym (cl-gensym))
- (retval (eglot--request proc method params
- :success-fn (lambda (&rest args)
- (if (vectorp (car args))
- (car args)
- args))
- :error-fn (cl-function
- (lambda (&key code message
&allow-other-keys)
- (eglot--error "Oops: %s: %s"
code message)))
- :timeout-fn (lambda () timeout-error-sym)
- :async-p nil)))
+ (catch-tag (make-symbol "eglot--sync-request-catch-tag"))
+ (retval
+ (catch catch-tag
+ (eglot--request proc method params
+ :success-fn (lambda (&rest args)
+ (throw catch-tag (if (vectorp (car
args))
+ (car args)
+ args)))
+ :error-fn (eglot--lambda
+ (&key code message &allow-other-keys)
+ (eglot--error "Oops: %s: %s" code
message))
+ :timeout-fn (lambda ()
+ (throw catch-tag timeout-error-sym))
+ :async-p nil))))
;; FIXME: There's maybe an emacs bug here. Because timeout-fn runs
;; in a timer, the better and obvious choice of throwing the erro
;; in the lambda is not quitting the `accept-process-output'
@@ -741,12 +755,6 @@ Meaning only return locally if successful, otherwise exit
non-locally."
"Apply FUN to every element of SEQ."
(mapcar (lambda (e) (apply fun e)) seq))
-(cl-defmacro eglot--lambda (cl-lambda-list &body body)
- (declare (indent 1) (debug (sexp &rest form)))
- `(cl-function
- (lambda ,cl-lambda-list
- ,@body)))
-
(defun eglot--path-to-uri (path)
"Urify PATH."
(url-hexify-string
- [elpa] externals/elpa f76f04e 057/139: More correctly keep track of didOpen/didClose per buffer, (continued)
- [elpa] externals/elpa f76f04e 057/139: More correctly keep track of didOpen/didClose per buffer, João Távora, 2018/05/14
- [elpa] externals/elpa a199c8e 070/139: Honour textDocumentSync, João Távora, 2018/05/14
- [elpa] externals/elpa 79a2a1e 069/139: Be quite explicit about our lack of capabilities right now, João Távora, 2018/05/14
- [elpa] externals/elpa ff5a03d 074/139: Very basic xref support, João Távora, 2018/05/14
- [elpa] externals/elpa b1554fc 055/139: * eglot.el (eglot--process-receive): Skip null method notifs., João Távora, 2018/05/14
- [elpa] externals/elpa 9882bf2 072/139: Cleanup mistake with TextDocumentItem and TextDocumentIdentifier, João Távora, 2018/05/14
- [elpa] externals/elpa fc6879f 084/139: Explain why didOpen on after-revert-hook is a bad idea, João Távora, 2018/05/14
- [elpa] externals/elpa fdb4de1 039/139: Simplify flymake integration, João Távora, 2018/05/14
- [elpa] externals/elpa 39e8b9e 081/139: Add (dummy) tests and Travis CI integration, João Távora, 2018/05/14
- [elpa] externals/elpa 1356844 097/139: Fix odd bugs, João Távora, 2018/05/14
- [elpa] externals/elpa 889ef20 085/139: Tweak the async request engine.,
João Távora <=
- [elpa] externals/elpa 1add335 078/139: Workaround two suspected Emacs bugs, João Távora, 2018/05/14
- [elpa] externals/elpa 9d404c9 054/139: Update README.md, João Távora, 2018/05/14
- [elpa] externals/elpa c417eb4 009/139: Cancel timeouts when process dies unexpectedly, João Távora, 2018/05/14
- [elpa] externals/elpa 6689a15 026/139: Add eglot-clear-status interactive command, João Távora, 2018/05/14
- [elpa] externals/elpa 63f2208 030/139: Less obstrusive flymake stuff for now, João Távora, 2018/05/14
- [elpa] externals/elpa 3403f86 027/139: Correctly report what we currently are capable of, João Távora, 2018/05/14
- [elpa] externals/elpa 92bf3a0 038/139: Signal textDocument/didClose, João Távora, 2018/05/14
- [elpa] externals/elpa 7ec0dcf 029/139: Events buffer uses eglot-mode, source buffers use eglot-editing-mode, João Távora, 2018/05/14
- [elpa] externals/elpa 17e0ca4 047/139: Fix Flymake diagnostic positions, João Távora, 2018/05/14
- [elpa] externals/elpa 0e95167 042/139: Watch for files opened under umbrella of existing process, João Távora, 2018/05/14