Handle empty docs in the new Emacs 28 protocol (issue#64)

* eldoc-box.el (eldoc-box--eldoc-message-function): Check the final
doc rather than the STR argument.
This commit is contained in:
Yuan Fu 2023-03-09 15:47:15 -08:00
parent eec688c1fc
commit 150ed26880
No known key found for this signature in database
GPG Key ID: 56E19BC57664A442

View File

@ -516,22 +516,27 @@ Trailing newlines doesnt count."
(defun eldoc-box--eldoc-message-function (str &rest args)
"Front-end for eldoc.
Display STR in childframe and ARGS works like `message'."
(when (and (stringp str) (not (equal str "")))
(when (stringp str)
(let* ((doc (string-trim-right (apply #'format str args)))
(single-line-p (and eldoc-box-only-multi-line
(eq (eldoc-box--count-newlines doc) 0))))
(unless single-line-p
(when (and (not (equal doc ""))
(not single-line-p))
(eldoc-box--display doc)
(setq eldoc-box--last-point (point))
;; Why a timer? ElDoc is mainly used in minibuffer,
;; where the text is constantly being flushed by other commands
;; so ElDoc doesn't try very hard to cleanup
(when eldoc-box--cleanup-timer (cancel-timer eldoc-box--cleanup-timer))
;; this function is also called by `eldoc-pre-command-refresh-echo-area'
;; in `pre-command-hook', which means the timer is reset before every
;; command if `eldoc-box-hover-mode' is on and `eldoc-last-message' is not nil.
(when eldoc-box--cleanup-timer
(cancel-timer eldoc-box--cleanup-timer))
;; This function is also called by
;; `eldoc-pre-command-refresh-echo-area' in
;; `pre-command-hook', which means the timer is reset before
;; every command if `eldoc-box-hover-mode' is on and
;; `eldoc-last-message' is not nil.
(setq eldoc-box--cleanup-timer
(run-with-timer eldoc-box-cleanup-interval nil #'eldoc-box--maybe-cleanup)))
(run-with-timer eldoc-box-cleanup-interval
nil #'eldoc-box--maybe-cleanup)))
;; Return nil to stop eldoc--message from running, because
;; this function is added as a :before-while advice.
single-line-p)))