From 84234b25ba59dd593e0f77bb4a54c03281519567 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Sun, 6 Jan 2019 12:55:21 +0000 Subject: [PATCH] Fix test failure introduced by previous commit Remove the hack of unsetting eldoc-last-message in eglot--eldoc-message. This allows any subsequent eglot-eldoc-function calls (prompted by simple cursor movement) to return it immediately, thus refreshing the help buffer with the same contents. For this to work, we also have to set eglot--eldoc-hint globally in eglot-eldoc-function. An alternative to making the test pass would be to keep the hack of unsetting eldoc-last-message only in the case that we actually get to display the help buffer. This would actually be more efficient, but potentially more hacky. The bottom line here is that eldoc doesn't have a good API to deal with asynchronous docstring fetching. See this thread: https://lists.gnu.org/archive/html/emacs-devel/2018-05/msg00151.html * eglot.el (eglot--eldoc-message): Don't unset eldoc-last-message. (eglot-eldoc-function): Set eglot--eldoc-hint for synchronous operation too. --- lisp/progmodes/eglot.el | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index fb002b85a8e..a7740e56904 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -2068,12 +2068,12 @@ Buffer is displayed with `display-buffer', which obeys (erase-buffer) (insert string) (goto-char (point-min)) - (setq eldoc-last-message nil) - (if eglot-auto-display-eldoc-extra-buffer - (display-buffer (current-buffer)) - (unless (get-buffer-window (current-buffer)) - (eglot--message "Help for %s in in %s buffer" eglot--eldoc-hint - (buffer-name eglot--help-buffer)))) + (cond (eglot-auto-display-eldoc-extra-buffer + (display-buffer (current-buffer))) + (t + (unless (get-buffer-window (current-buffer)) + (eglot--message "Help for %s is in %s buffer" eglot--eldoc-hint + (buffer-name eglot--help-buffer))))) (help-mode) t))))) @@ -2085,6 +2085,7 @@ If SKIP-SIGNATURE, don't try to send textDocument/signatureHelp." (position-params (eglot--TextDocumentPositionParams)) sig-showing (thing-at-point (thing-at-point 'symbol))) + (setq eglot--eldoc-hint thing-at-point) (cl-macrolet ((when-buffer-window (&body body) ; notice the exception when testing with `ert' `(when (or (get-buffer-window buffer) (ert-running-test)) -- 2.39.2