[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/eglot c30f0f3 23/69: Get rid of jsonrpc.el customizatio
From: |
João Távora |
Subject: |
[elpa] externals/eglot c30f0f3 23/69: Get rid of jsonrpc.el customization group and timeout |
Date: |
Fri, 22 Jun 2018 11:54:57 -0400 (EDT) |
branch: externals/eglot
commit c30f0f3262c5e6d70934c7c2a9e7d7c23e696360
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Get rid of jsonrpc.el customization group and timeout
* eglot.el (eglot-shutdown, eglot--signal-textDocument/willSave):
Pass :timeout to jsonrpc-request.
(defadvice jsonrpc-request): Add :timeout kwarg
* jsonrpc.el (defgroup jsonrpc, jsonrpc-request-timeout): Remove.
(jrpc-default-request-timeout): New constant.
(jsonrpc-async-request): Use it.
(jsonrpc-request): Accept timeout kwarg and pass it on.
---
eglot.el | 17 ++++++++---------
jsonrpc.el | 20 +++++++-------------
2 files changed, 15 insertions(+), 22 deletions(-)
diff --git a/eglot.el b/eglot.el
index 41e57b4..020e352 100644
--- a/eglot.el
+++ b/eglot.el
@@ -148,9 +148,9 @@ called interactively."
(interactive (list (jsonrpc-current-process-or-lose) t))
(eglot--message "Asking %s politely to terminate" proc)
(unwind-protect
- (let ((jsonrpc-request-timeout 3))
+ (progn
(setf (eglot--moribund proc) t)
- (jsonrpc-request proc :shutdown nil)
+ (jsonrpc-request proc :shutdown nil :timeout 3)
;; this one should always fail, hence ignore-errors
(ignore-errors (jsonrpc-request proc :exit nil)))
;; Turn off `eglot--managed-mode' where appropriate.
@@ -749,7 +749,7 @@ Records START, END and PRE-CHANGE-LENGTH locally."
;; bad idea, since that might lead to the request never having a
;; chance to run, because `jsonrpc-ready-predicates'.
(advice-add #'jsonrpc-request :before
- (cl-function (lambda (_proc _method _params &key deferred)
+ (cl-function (lambda (_proc _method _params &key deferred _timeout)
(when (and eglot--managed-mode deferred)
(eglot--signal-textDocument/didChange))))
'((name . eglot--signal-textDocument/didChange)))
@@ -805,12 +805,11 @@ Records START, END and PRE-CHANGE-LENGTH locally."
(let ((proc (jsonrpc-current-process-or-lose))
(params `(:reason 1 :textDocument ,(eglot--TextDocumentIdentifier))))
(jsonrpc-notify proc :textDocument/willSave params)
- (ignore-errors
- (let ((jsonrpc-request-timeout 0.5))
- (when (plist-get :willSaveWaitUntil
- (eglot--server-capable :textDocumentSync))
- (eglot--apply-text-edits
- (jsonrpc-request proc :textDocument/willSaveWaituntil params)))))))
+ (when (eglot--server-capable :textDocumentSync :willSaveWaitUntil)
+ (ignore-errors
+ (eglot--apply-text-edits
+ (jsonrpc-request proc :textDocument/willSaveWaituntil params
+ :timeout 0.5))))))
(defun eglot--signal-textDocument/didSave ()
"Send textDocument/didSave to server."
diff --git a/jsonrpc.el b/jsonrpc.el
index d5f7745..cda035e 100644
--- a/jsonrpc.el
+++ b/jsonrpc.el
@@ -123,16 +123,6 @@
(require 'pcase)
(require 'array) ; xor
-(defgroup jsonrpc nil
- "Interaction between JSONRPC endpoints"
- :prefix "jsonrpc-"
- :group 'applications)
-
-(defcustom jsonrpc-request-timeout 3
- "How many seconds to wait for a JSONRPC from the server.
-If nil, don't use a timeout (not recommended)."
- :type :integer)
-
(defvar jsonrpc-find-process-functions nil
"Special hook to find an active JSON-RPC process.")
@@ -505,12 +495,15 @@ request and a process object.")
(let ((e (gensym "jsonrpc-lambda-elem")))
`(lambda (,e) (apply (cl-function (lambda ,cl-lambda-list ,@body)) ,e))))
+(defconst jrpc-default-request-timeout 10
+ "Time in seconds before timing out a JSONRPC request.")
+
(cl-defun jsonrpc-async-request (proc
method
params
&rest args
&key success-fn error-fn timeout-fn
- (timeout jsonrpc-request-timeout)
+ (timeout jrpc-default-request-timeout)
(deferred nil))
"Make a request to PROC, expecting a reply, return immediately.
The JSONRPC request is formed by METHOD, a symbol, and PARAMS a
@@ -591,7 +584,7 @@ TIMEOUT is nil)"
(jsonrpc--request-continuations proc))
(list id timer)))
-(cl-defun jsonrpc-request (proc method params &key deferred)
+(cl-defun jsonrpc-request (proc method params &key deferred timeout)
"Make a request to PROC, wait for a reply.
Like `jsonrpc-async-request' for PROC, METHOD and PARAMS, but
synchronous, i.e. doesn't exit until anything
@@ -618,7 +611,8 @@ DEFERRED is passed to `jsonrpc-async-request', which see."
:timeout-fn
(lambda ()
(throw tag '(error (jsonrpc-error-message . "Timed out"))))
- :deferred deferred))
+ :deferred deferred
+ :timeout timeout))
(while t (accept-process-output nil 30)))
(pcase-let ((`(,id ,timer) id-and-timer))
(when id (remhash id (jsonrpc--request-continuations proc)))
- [elpa] externals/eglot a2aa1ed 19/69: Robustify timer handling for jrpc-async-request, (continued)
- [elpa] externals/eglot a2aa1ed 19/69: Robustify timer handling for jrpc-async-request, João Távora, 2018/06/22
- [elpa] externals/eglot 7769c07 16/69: Send message, then establish continuations, João Távora, 2018/06/22
- [elpa] externals/eglot 7f2e894 11/69: Merge branch 'master' into jsonrpc-refactor (using good ol' git merge), João Távora, 2018/06/22
- [elpa] externals/eglot e5ba4f6 18/69: Automatically reply with error if dispatcher doesn't, João Távora, 2018/06/22
- [elpa] externals/eglot 33ae871 09/69: More flexible jrpc.el and improve eglot.el's doc, João Távora, 2018/06/22
- [elpa] externals/eglot 3265c1d 10/69: Simpler callback protocol for JSONRPC parameters and results, João Távora, 2018/06/22
- [elpa] externals/eglot e906d25 14/69: Overhaul JSON and JSRONRPC error handling, João Távora, 2018/06/22
- [elpa] externals/eglot 7cd94b9 12/69: Improve jrpc.el's doc (and change jrpc-request's protocol a tiny bit), João Távora, 2018/06/22
- [elpa] externals/eglot 489182d 24/69: New jsonrpc-error error type, João Távora, 2018/06/22
- [elpa] externals/eglot 5cea412 20/69: Fix typos and phrasing in commentary and docstrings, João Távora, 2018/06/22
- [elpa] externals/eglot c30f0f3 23/69: Get rid of jsonrpc.el customization group and timeout,
João Távora <=
- [elpa] externals/eglot 5e8fe4c 26/69: Add jsonrpc-tests.el, João Távora, 2018/06/22
- [elpa] externals/eglot 05ff697 29/69: Document current API breaches a bit, João Távora, 2018/06/22
- [elpa] externals/eglot 258e3b0 07/69: Merge master into jsonrpc-refactor (using imerge), João Távora, 2018/06/22
- [elpa] externals/eglot 4bbf810 25/69: Don't return implementation details in jsonrpc-async-request, João Távora, 2018/06/22
- [elpa] externals/eglot 5874af9 32/69: Fix deferred actions (forgot the crucial non-local exit), João Távora, 2018/06/22
- [elpa] externals/eglot 481f16e 33/69: * eglot.el (eglot-eldoc-function): Remove spurious log message, João Távora, 2018/06/22
- [elpa] externals/eglot c43dff4 35/69: On request timeout, clear it from the deferred actions, João Távora, 2018/06/22
- [elpa] externals/eglot 870c60a 04/69: Merge master into jsonrpc-refactor (using imerge), João Távora, 2018/06/22
- [elpa] externals/eglot 980f3e7 34/69: Fix another merge-related bug in eglot-eldoc-function, João Távora, 2018/06/22
- [elpa] externals/eglot fab7f8b 44/69: Improve Makefile test targets, João Távora, 2018/06/22