From: João Távora Date: Sun, 20 May 2018 14:24:55 +0000 (+0100) Subject: Get rid of jsonrpc.el customization group and timeout X-Git-Tag: emacs-29.0.90~1616^2~524^2~4^2~489^2~15 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=3a127eed7b76ec02f4f408cbb03ab46ed2ac48b8;p=emacs.git 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. --- diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 41e57b4bb53..020e352c440 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/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."