]> git.eshelyaron.com Git - emacs.git/commitdiff
Eglot: always call ElDoc callbacks in correct buffer (bug#78530)
authorYuan Fu <casouri@gmail.com>
Wed, 21 May 2025 07:23:15 +0000 (00:23 -0700)
committerEshel Yaron <me@eshelyaron.com>
Tue, 27 May 2025 14:29:53 +0000 (16:29 +0200)
Some minor modes adds their own eldoc display function to
'eldoc-display-functions' hook buffer-locally.  So when eldoc
uses 'eldoc-display-functions' to display docs, it should use
the buffer-local value of the hook.

But that's not always the case. In 'eldoc--invoke-strategy', the
code that runs 'eldoc-display-functions' hook is wrapped in a
callback function that eventually gets passed to each
documentation function in 'eldoc-documentation-functions'. So
now it's the documentation functions' responsibility to call the
eldoc callback in the original buffer.

All the eglot documentation functions indeed do that, using
'eglot--when-buffer-window' to switch to the original buffer
when calling the eldoc callback. But
'eglot-code-action-suggestion' is the exception, the callback is
called outside of the 'eglot--when-buffer-window' form.

This patch fixes that.

This bug was originally reported on eldoc-box [1]. The user
found that eldoc-box's display function are rarely called, even
though the minor mode is turned on. This patch fixes the issue.

[1] https://github.com/casouri/eldoc-box/issues/126#issuecomment-2896611278

* lisp/progmodes/eglot.el (eglot-code-action-suggestion): Move
the funcall form into the eglot--when-buffer-window form.

(cherry picked from commit 0b2ba13c978544317d1df18e7fe701c055a6419f)

lisp/progmodes/eglot.el

index 840714a60b74616208d2041d903c8879777a7fea..401ce217a159cbd02e8907b9a7f7241c73b0cfd5 100644 (file)
@@ -4218,8 +4218,8 @@ at point.  With prefix argument, prompt for ACTION-KIND."
                                      'display
                                      `((margin left-margin)
                                        ,tooltip)))))
-                 (setq eglot--suggestion-overlay ov)))))
-         (when use-text-p (funcall cb blurb)))
+                 (setq eglot--suggestion-overlay ov))))
+           (when use-text-p (funcall cb blurb))))
        :hint :textDocument/codeAction)
       (and use-text-p t))))