]> git.eshelyaron.com Git - emacs.git/commitdiff
Optionally shutdown after killing last buffer of managed project ()
authorIngo Lohmar <ingo.lohmar@posteo.net>
Wed, 2 Oct 2019 16:05:15 +0000 (18:05 +0200)
committerJoão Távora <joaotavora@gmail.com>
Sat, 5 Oct 2019 08:50:50 +0000 (09:50 +0100)
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 <joaotavora@gmail.com>
GitHub-reference: https://github.com/joaotavora/eglot/issues/309

lisp/progmodes/eglot.el

index 279fbeedad7f1d8ee96b65d4053cc5cae20284d4..cf2f371accd26406b5a6ea4f80a264e491f4bb99 100644 (file)
@@ -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."