Skip to content

Commit

Permalink
Add public hook eglot-managed-mode-hook
Browse files Browse the repository at this point in the history
Per joaotavora/eglot#354.

* eglot.el (eglot-managed-p): New function.
(eglot--managed-mode-hook): Obsolete it.
(eglot-managed-mode-hook): New hook variable.
(eglot--managed-mode): Run the new hook.

* README.md (Customization): Mention the new hook.

GitHub-reference: fix joaotavora/eglot#182
  • Loading branch information
nemethf committed Jan 13, 2020
1 parent f6a72c5 commit fbc2935
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lisp/progmodes/eglot.el
Original file line number Diff line number Diff line change
Expand Up @@ -1234,6 +1234,17 @@ For example, to keep your Company customization use
(defvar-local eglot--cached-server nil
"A cached reference to the current EGLOT server.")

(defun eglot-managed-p ()
"Tell if current buffer is managed by EGLOT."
eglot--managed-mode)

(make-obsolete-variable
'eglot--managed-mode-hook 'eglot-managed-mode-hook "1.6")

(defvar eglot-managed-mode-hook nil
"A hook run by EGLOT after it started/stopped managing a buffer.
Use `eglot-managed-p' to determine if current buffer is managed.")

(define-minor-mode eglot--managed-mode
"Mode for source buffers managed by some EGLOT project."
nil nil eglot-mode-map
Expand Down Expand Up @@ -1289,7 +1300,9 @@ For example, to keep your Company customization use
(delq (current-buffer) (eglot--managed-buffers server)))
(when (and eglot-autoshutdown
(null (eglot--managed-buffers server)))
(eglot-shutdown server)))))))
(eglot-shutdown server))))))
;; Note: the public hook runs before the internal eglot--managed-mode-hook.
(run-hooks 'eglot-managed-mode-hook))

(defun eglot--managed-mode-off ()
"Turn off `eglot--managed-mode' unconditionally."
Expand Down

0 comments on commit fbc2935

Please sign in to comment.