[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 83b5e9cd24d 3/3: Eldoc: don't overdisplay if using eldoc-document
From: |
João Távora |
Subject: |
master 83b5e9cd24d 3/3: Eldoc: don't overdisplay if using eldoc-documentation-compose |
Date: |
Thu, 13 Apr 2023 12:41:53 -0400 (EDT) |
branch: master
commit 83b5e9cd24ddcbb04dbd5db9a07248ff7fa301ab
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>
Eldoc: don't overdisplay if using eldoc-documentation-compose
bug#62816
This is about a particular value for 'eldoc-documentation-strategy',
'eldoc-documentation-compose'. Its helper
'eldoc--documentation-compose-1' was buggy. It created the callback
for all the backends in 'eldoc-documentation-functions', but arranged
so that it could potentially be invoked immediately and trigger
display, half-defeating the purpose of the "patience" and causing
blinking in the echo area.
Now it creates all the callbacks beforehand and only then passes them
to the corresponding members of eldoc-documentation-functions. This
sets up the correct state in eldoc--invoke-strategy.
* lisp/emacs-lisp/eldoc.el (eldoc--documentation-compose-1):
Delete.
(eldoc-documentation-compose)
(eldoc-documentation-compose-eagerly): Rework.
---
lisp/emacs-lisp/eldoc.el | 37 +++++++++++++++++++++----------------
1 file changed, 21 insertions(+), 16 deletions(-)
diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el
index 1eb0d38c5ce..18d3eb37af3 100644
--- a/lisp/emacs-lisp/eldoc.el
+++ b/lisp/emacs-lisp/eldoc.el
@@ -681,29 +681,34 @@ This is the default value for
`eldoc-documentation-strategy'."
(lambda (f)
(funcall f (eldoc--make-callback :eager f)))))
-(defun eldoc--documentation-compose-1 (eagerlyp)
- "Helper function for composing multiple doc strings.
-If EAGERLYP is non-nil show documentation as soon as possible,
-else wait for all doc strings."
- (run-hook-wrapped 'eldoc-documentation-functions
- (lambda (f)
- (let* ((callback (eldoc--make-callback
- (if eagerlyp :eager :patient)
- f))
- (str (funcall f callback)))
- (if (or (null str) (stringp str)) (funcall callback
str))
- nil)))
- t)
-
(defun eldoc-documentation-compose ()
"Show multiple documentation strings together after waiting for all of them.
This is meant to be used as a value for `eldoc-documentation-strategy'."
- (eldoc--documentation-compose-1 nil))
+ (let (fns-and-callbacks)
+ ;; Make all the callbacks, setting up state inside
+ ;; `eldoc--invoke-strategy' to know how many callbacks to wait for
+ ;; before displaying the result (bug#62816).
+ (run-hook-wrapped 'eldoc-documentation-functions
+ (lambda (f)
+ (push (cons f (eldoc--make-callback :patient f))
+ fns-and-callbacks)
+ nil))
+ ;; Now call them. The last one will trigger the display.
+ (cl-loop for (f . callback) in fns-and-callbacks
+ for str = (funcall f callback)
+ when (or (null str) (stringp str)) do (funcall callback str)))
+ t)
(defun eldoc-documentation-compose-eagerly ()
"Show multiple documentation strings one by one as soon as possible.
This is meant to be used as a value for `eldoc-documentation-strategy'."
- (eldoc--documentation-compose-1 t))
+ (run-hook-wrapped 'eldoc-documentation-functions
+ (lambda (f)
+ (let* ((callback (eldoc--make-callback :eager f))
+ (str (funcall f callback)))
+ (if (or (null str) (stringp str)) (funcall callback
str))
+ nil)))
+ t)
(defun eldoc-documentation-enthusiast ()
"Show most important documentation string produced so far.