From: Ingo Lohmar Date: Wed, 2 Oct 2019 16:05:15 +0000 (+0200) Subject: Optionally shutdown after killing last buffer of managed project () X-Git-Tag: emacs-29.0.90~1616^2~524^2~4^2~314 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ad1cc3b1c21188c5fe3264d6b4e2b1f93a9161b6;p=emacs.git Optionally shutdown after killing last buffer of managed project () 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 --- 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."