From c9693eddb01c80cd25919b8f45a074235cb02897 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Wed, 12 Dec 2018 13:53:33 +0000 Subject: [PATCH] Play nice with further customizations of eldoc-message-function Uses a :before-until advice on the local value of eldoc-message-function instead of setting it directly. Thus, when we give up because of eldoc-box-only-multi-line (or some other future criteria), other :before-until handlers can kick in. * eldoc-box.el (eldoc-box--eldoc-message-function): Control return of t or nil. (eldoc-box-hover-mode): Use add-function and remove-function. --- eldoc-box.el | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/eldoc-box.el b/eldoc-box.el index 806d4d1..7fbb356 100644 --- a/eldoc-box.el +++ b/eldoc-box.el @@ -212,10 +212,10 @@ Checkout `lsp-ui-doc--make-frame', `lsp-ui-doc--move-frame'." "Frontend for eldoc. Display STR in childframe and ARGS works like `message'." (if (stringp str) (let ((doc (apply #'format str args))) - (if (and eldoc-box-only-multi-line (eq (cl-count ?\n doc) 0)) - (apply #'eldoc-minibuffer-message str args) + (unless (and eldoc-box-only-multi-line (eq (cl-count ?\n doc) 0)) (eldoc-box--display (apply #'format str args)))) - (eldoc-box-quit-frame))) + (eldoc-box-quit-frame) + t)) (define-minor-mode eldoc-box-hover-mode "Displays hover documentations in a childframe. This mode is buffer local." @@ -228,8 +228,9 @@ Checkout `lsp-ui-doc--make-frame', `lsp-ui-doc--move-frame'." (unless eldoc-box--cleanup-timer (setq eldoc-box--cleanup-timer (run-with-idle-timer 1 t #'eldoc-box--maybe-cleanup))) (add-to-list 'eldoc-box--enabled-buffer-list (current-buffer)) - (setq-local eldoc-message-function #'eldoc-box--eldoc-message-function)) - (setq-local eldoc-message-function #'eldoc-minibuffer-message) + (add-function :before-until (local 'eldoc-message-function) + #'eldoc-box--eldoc-message-function)) + (remove-function (local 'eldoc-message-function) #'eldoc-box--eldoc-message-function) (delete (current-buffer) eldoc-box--enabled-buffer-list) ;; this function has to be called after the current buffer is ;; removed from buffer list