From ad1cc3b1c21188c5fe3264d6b4e2b1f93a9161b6 Mon Sep 17 00:00:00 2001 From: Ingo Lohmar Date: Wed, 2 Oct 2019 18:05:15 +0200 Subject: [PATCH] Optionally shutdown after killing last buffer of managed project () MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This should close issue https://github.com/joaotavora/eglot/issues/217, also cf. https://github.com/joaotavora/eglot/issues/270. * eglot.el (eglot-autoshutdown): New defcustom. (eglot--managed-mode-onoff): Shutdown if so configured and no managed buffers left. Co-authored-by: João Távora GitHub-reference: https://github.com/joaotavora/eglot/issues/309 --- lisp/progmodes/eglot.el | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 279fbeedad7..cf2f371accd 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -170,6 +170,10 @@ as 0, i.e. don't block at all." :type '(choice (boolean :tag "Whether to inhibit autoreconnection") (integer :tag "Number of seconds"))) +(defcustom eglot-autoshutdown nil + "If non-nil, shut down server after killing last managed buffer." + :type 'boolean) + (defcustom eglot-events-buffer-size 2000000 "Control the size of the Eglot events buffer. If a number, don't let the buffer grow larger than that many @@ -1224,7 +1228,11 @@ Reset in `eglot--managed-mode-onoff'.") (setq eglot--cached-current-server nil) (when server (setf (eglot--managed-buffers server) - (delq buf (eglot--managed-buffers server))))))))) + (delq buf (eglot--managed-buffers server))) + (when (and eglot-autoshutdown + (not (eglot--shutdown-requested server)) + (not (eglot--managed-buffers server))) + (eglot-shutdown server)))))))) (defun eglot--current-server () "Find the current logical EGLOT server." -- 2.39.2