emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/eglot 8d8c90d 45/54: Fix #182: add public hook eglot-ma


From: João Távora
Subject: [elpa] externals/eglot 8d8c90d 45/54: Fix #182: add public hook eglot-managed-mode-hook
Date: Thu, 16 Apr 2020 05:31:52 -0400 (EDT)

branch: externals/eglot
commit 8d8c90d0d654d262e0ff43f45444ec6a512b8185
Author: Felicián Németh <address@hidden>
Commit: Felicián Németh <address@hidden>

    Fix #182: add public hook eglot-managed-mode-hook
    
    Per #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.
---
 README.md |  4 ++++
 eglot.el  | 15 ++++++++++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index fc20623..70f5837 100644
--- a/README.md
+++ b/README.md
@@ -290,6 +290,10 @@ lisp:
 - `eglot-server-initialized-hook`: Hook run after server is
   successfully initialized;
 
+- `eglot-managed-mode-hook`: Hook run after Eglot started or stopped
+  managing a buffer.  Use `eglot-managed-p` to tell if current buffer
+  is still being managed.
+
 # How does Eglot work?
 
 `M-x eglot` starts a server via a shell-command guessed from
diff --git a/eglot.el b/eglot.el
index 7f506c8..4c65af0 100644
--- a/eglot.el
+++ b/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."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]