From 194ff4136ac463bd79ca8d35b72851248372b89a Mon Sep 17 00:00:00 2001 From: Yuan Fu Date: Tue, 11 Dec 2018 11:16:02 -0500 Subject: [PATCH] Add option to leave message in minibuffer when there's only one line --- README.org | 10 +++++----- eldoc-box.el | 8 +++++++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/README.org b/README.org index 5d48ee6..aeff704 100644 --- a/README.org +++ b/README.org @@ -7,11 +7,11 @@ Get the file, add to load path, and #+END_SRC * Usage -Show the documentation of the symbol at point: =eldoc-box-help-at-point= - -Show documentation upon hover: =eldoc-box-hover-mode=. Note that you need to enable ElDoc mode for this to work. - -Adjust =:background= of =eldoc-box-border= face for border color. Adjust =:background= of =eldoc-box-body= face for background color of childframe. +- =eldoc-box-help-at-point= :: Show the documentation of the symbol at point. +- =eldoc-box-hover-mode= :: Show documentation upon hover. Note that you need to enable ElDoc mode for this to work. +- =eldoc-box-border= :: Adjust =:background= of this face for border color. +- =eldoc-box-body= :: Adjust =:background= of this face for background color of childframe. +- =eldoc-box-only-multi-line= :: Set this to non-nil and eldoc-box only display multi-line message in childframe. One line messages are left in minibuffer. ** Use with eglot As of writing this README, eglot doesn't have a public mode hook, use this hook: diff --git a/eldoc-box.el b/eldoc-box.el index cdc862c..b22d378 100644 --- a/eldoc-box.el +++ b/eldoc-box.el @@ -39,6 +39,9 @@ (defface eldoc-box-body '((t . (:background nil))) "Body face used in eglot doc childframe. Only :background is used.") +(defvar eldoc-box-only-multi-line nil + "If non-nil, only use childframe when there are more than one line.") + (defvar eldoc-box-frame-parameters '( ;; (left . -1) @@ -169,7 +172,10 @@ Checkout `lsp-ui-doc--make-frame', `lsp-ui-doc--move-frame'." "Frontend for eldoc. Display STR in childframe and ARGS works like `message'." (when str (eldoc-box-quit-frame) - (eldoc-box--display (apply #'format str args)))) + (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) + (eldoc-box--display (apply #'format str args)))))) (define-minor-mode eldoc-box-hover-mode "Displays hover documentations in a childframe. This mode is buffer local."