From: Felicián Németh Date: Fri, 22 Nov 2019 15:55:04 +0000 (+0100) Subject: Add public hook eglot-managed-mode-hook X-Git-Tag: emacs-29.0.90~1616^2~524^2~4^2~251 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=fbc29353667b88c208b2796a4e1e120edb708673;p=emacs.git Add public hook eglot-managed-mode-hook Per https://github.com/joaotavora/eglot/issues/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 https://github.com/joaotavora/eglot/issues/182 --- diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 7f506c8c9ff..4c65af0a24c 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -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 @@ -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."