summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorJoão Távora <joaotavora@gmail.com>2020-11-20 01:18:16 +0000
committerJoão Tãvora <joaotavora@gmail.com>2020-11-20 01:19:39 +0000
commit59b340c1e6c9fc8b30123fbfecd50f58adc3bf6b (patch)
treec167f7b2e5a6310309a9a1ec7d3b9423b7b28bad /lisp
parentbc951000b35fc48edfe1f643998d201b971f0d30 (diff)
downloademacs-59b340c1e6c9fc8b30123fbfecd50f58adc3bf6b.tar.gz
emacs-59b340c1e6c9fc8b30123fbfecd50f58adc3bf6b.tar.bz2
emacs-59b340c1e6c9fc8b30123fbfecd50f58adc3bf6b.zip
Fix default timeout handling in jsonrpc-request
* lisp/jsonrpc.el (jsonrpc-request): Use default timeout if not passed. (Version): Bump to 1.0.13
Diffstat (limited to 'lisp')
-rw-r--r--lisp/jsonrpc.el18
1 files changed, 10 insertions, 8 deletions
diff --git a/lisp/jsonrpc.el b/lisp/jsonrpc.el
index 7de6baeb00a..d28cf7a91fa 100644
--- a/lisp/jsonrpc.el
+++ b/lisp/jsonrpc.el
@@ -4,7 +4,7 @@
;; Author: João Távora <joaotavora@gmail.com>
;; Keywords: processes, languages, extensions
-;; Version: 1.0.12
+;; Version: 1.0.13
;; Package-Requires: ((emacs "25.2"))
;; This is a GNU ELPA :core package. Avoid functionality that is not
@@ -271,7 +271,7 @@ it only exits locally (returning the JSONRPC result object) if
the request is successful, otherwise it exits non-locally with an
error of type `jsonrpc-error'.
-DEFERRED is passed to `jsonrpc-async-request', which see.
+DEFERRED and TIMEOUT as in `jsonrpc-async-request', which see.
If CANCEL-ON-INPUT is non-nil and the user inputs something while
the function is waiting, then it exits immediately, returning
@@ -284,7 +284,8 @@ ignored."
(catch tag
(setq
id-and-timer
- (jsonrpc--async-request-1
+ (apply
+ #'jsonrpc--async-request-1
connection method params
:success-fn (lambda (result)
(unless cancelled
@@ -300,13 +301,14 @@ ignored."
(lambda ()
(unless cancelled
(throw tag '(error (jsonrpc-error-message . "Timed out")))))
- :deferred deferred
- :timeout timeout))
+ `(,@(when deferred `(:deferred ,deferred))
+ ,@(when timeout `(:timeout ,timeout)))))
(cond (cancel-on-input
- (while (sit-for 30))
- (setq cancelled t)
+ (unwind-protect
+ (let ((inhibit-quit t)) (while (sit-for 30)))
+ (setq cancelled t))
`(cancelled ,cancel-on-input-retval))
- (t (while t (accept-process-output nil 30)))))
+ (t (while t (sit-for 30)))))
;; In normal operation, cancellation is handled by the
;; timeout function and response filter, but we still have
;; to protect against user-quit (C-g) or the