emacs-diffs
[Top][All Lists]
Advanced

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

emacs-29 28ed0d1840f 1/2: Eglot: run eglot-managed-mode-hook after LSP d


From: João Távora
Subject: emacs-29 28ed0d1840f 1/2: Eglot: run eglot-managed-mode-hook after LSP didOpen
Date: Wed, 22 Feb 2023 14:17:49 -0500 (EST)

branch: emacs-29
commit 28ed0d1840f94ba52b8b60bfbf222493fee2a3ea
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>

    Eglot: run eglot-managed-mode-hook after LSP didOpen
    
    This allows using the hook for interacting with the LSP server using
    the current buffer as the subject of that interaction ("document" in
    LSP parlance).
    
    * lisp/progmodes/eglot.el (eglot--maybe-activate-editing-mode):
    Run eglot-managed-mode-hook here.
    (eglot--managed-mode): Not here.
---
 lisp/progmodes/eglot.el | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index 3daca24a586..8b0caf41ad7 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -1814,9 +1814,7 @@ Use `eglot-managed-p' to determine if current buffer is 
managed.")
               (delq (current-buffer) (eglot--managed-buffers server)))
         (when (and eglot-autoshutdown
                    (null (eglot--managed-buffers server)))
-          (eglot-shutdown server))))))
-  ;; Note: the public hook runs before the internal eglot--managed-mode-hook.
-  (run-hooks 'eglot-managed-mode-hook))
+          (eglot-shutdown server)))))))
 
 (defun eglot--managed-mode-off ()
   "Turn off `eglot--managed-mode' unconditionally."
@@ -1858,7 +1856,10 @@ If it is activated, also signal textDocument/didOpen."
     (when (and buffer-file-name (eglot-current-server))
       (setq eglot--diagnostics nil)
       (eglot--managed-mode)
-      (eglot--signal-textDocument/didOpen))))
+      (eglot--signal-textDocument/didOpen)
+      ;; Run user hook after 'textDocument/didOpen' so server knows
+      ;; about the buffer.
+      (run-hooks 'eglot-managed-mode-hook))))
 
 (add-hook 'find-file-hook 'eglot--maybe-activate-editing-mode)
 (add-hook 'after-change-major-mode-hook 'eglot--maybe-activate-editing-mode)



reply via email to

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