From a3e6b3b86c41c077b0939bc957d362f68f49f748 Mon Sep 17 00:00:00 2001 From: =?utf8?q?bc=C2=B2?= Date: Mon, 15 Mar 2021 06:49:07 -0300 Subject: [PATCH] Add new command eglot-shutdown-all MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Also closes https://github.com/joaotavora/eglot/issues/644 Co-authored-by: João Távora Copyright-paperwork-exempt: yes * NEWS.md: mention new command * README.md (Commands and keybindings): mention new command. Tweak documentation for eglot-shutdown and eglot-reconnect. * eglot.el (eglot-shutdown): Tweak docstring. (eglot-shutdown-all): New command. GitHub-reference: close https://github.com/joaotavora/eglot/issues/643 --- lisp/progmodes/eglot.el | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 79b90886f6c..0341ffdecc6 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -652,11 +652,12 @@ Interactively, read SERVER from the minibuffer unless there is only one and it's managing the current buffer. Forcefully quit it if it doesn't respond within TIMEOUT seconds. -Don't leave this function with the server still running. +TIMEOUT defaults to 1.5 seconds. Don't leave this function with +the server still running. If PRESERVE-BUFFERS is non-nil (interactively, when called with a prefix argument), do not kill events and output buffers of -SERVER. ." +SERVER." (interactive (list (eglot--read-server "Shutdown which server" (eglot-current-server)) t nil current-prefix-arg)) @@ -670,6 +671,13 @@ SERVER. ." (jsonrpc-shutdown server (not preserve-buffers)) (unless preserve-buffers (kill-buffer (jsonrpc-events-buffer server))))) +(defun eglot-shutdown-all (&optional preserve-buffers) + "Politely ask all language servers to quit, in order. +PRESERVE-BUFFERS as in `eglot-shutdown', which see." + (interactive (list current-prefix-arg)) + (cl-loop for ss being the hash-values of eglot--servers-by-project + do (cl-loop for s in ss do (eglot-shutdown s nil preserve-buffers)))) + (defun eglot--on-shutdown (server) "Called by jsonrpc.el when SERVER is already dead." ;; Turn off `eglot--managed-mode' where appropriate. -- 2.39.5