From d4574ee392b9a8c537bec895be37468b600c25ac Mon Sep 17 00:00:00 2001 From: sm2n Date: Fri, 12 Mar 2021 00:48:14 -0500 Subject: [PATCH] Fix eldoc-box-only-multi-line behavior Prior to this change, single line eldoc messages were just ignored completely when eldoc-box-only-multi-line was non-nil, though they should have been displayed in the minibuffer. * eldoc-box.el (eldoc-box--enable): Change :before-until to :before-while. (eldoc-box--eldoc-message-function): Return nil if the message is not multi-line, so that the default eldoc message function picks up the message. --- eldoc-box.el | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/eldoc-box.el b/eldoc-box.el index 984afd2..d83f8f1 100644 --- a/eldoc-box.el +++ b/eldoc-box.el @@ -145,7 +145,7 @@ See `eldoc-box-inhibit-display-when-moving'.") (defun eldoc-box--enable () "Enable eldoc-box hover. Intended for internal use." - (add-function :before-until (local 'eldoc-message-function) + (add-function :before-while (local 'eldoc-message-function) #'eldoc-box--eldoc-message-function) (when eldoc-box-clear-with-C-g (advice-add #'keyboard-quit :before #'eldoc-box-quit-frame))) @@ -405,8 +405,10 @@ Checkout `lsp-ui-doc--make-frame', `lsp-ui-doc--move-frame'." (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 ""))) - (let ((doc (apply #'format str args))) - (unless (and eldoc-box-only-multi-line (eq (cl-count ?\n doc) 0)) + (let* ((doc (apply #'format str args)) + (multi-line-p (and eldoc-box-only-multi-line + (eq (cl-count ?\n doc) 0)))) + (unless multi-line-p (eldoc-box--display doc) (setq eldoc-box--last-point (point)) ;; Why a timer? ElDoc is mainly used in minibuffer, @@ -417,8 +419,8 @@ Checkout `lsp-ui-doc--make-frame', `lsp-ui-doc--move-frame'." ;; 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)))) - t)) + (run-with-timer eldoc-box-cleanup-interval nil #'eldoc-box--maybe-cleanup))) + multi-line-p))) ;;;; Eglot helper