Skip to content

Commit

Permalink
Optionally shutdown after killing last buffer of managed project ()
Browse files Browse the repository at this point in the history
This should close issue joaotavora/eglot#217, also cf. joaotavora/eglot#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 <[email protected]>
GitHub-reference: joaotavora/eglot#309
  • Loading branch information
ilohmar and joaotavora committed Oct 5, 2019
1 parent 14f69da commit ad1cc3b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lisp/progmodes/eglot.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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."
Expand Down

0 comments on commit ad1cc3b

Please sign in to comment.