aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoão Távora2023-12-05 15:40:49 -0600
committerJoão Távora2023-12-05 15:53:43 -0600
commitdc744fe6f3cd185bd9d29f61b08cd4c524e3969e (patch)
tree060fe470f79a4a7b587c996d002b732765b39c62
parentdf842a737d6cb2b70d9672a64826e04bb8249167 (diff)
downloademacs-dc744fe6f3cd185bd9d29f61b08cd4c524e3969e.tar.gz
emacs-dc744fe6f3cd185bd9d29f61b08cd4c524e3969e.zip
ElDoc: make eldoc-display-in-echo-are useful from M-x eldoc
M-x eldoc is ElDoc's interactive entry point for on-demand documentation for users that don't want the behind-the-scenes idle timer behaviour. However, eldoc-display-in-echo-area, a member of eldoc-display-functions, refused to do anything because it thought it didn't have permission to use the echo area, which isn't true in interactive use cases. Fix that. See also: https://github.com/joaotavora/eglot/discussions/1328 * lisp/emacs-lisp/eldoc.el (eldoc-display-in-echo-area): Use INTERACTIVE argument. Rework comments. (Version): Bump to 1.15.0
-rw-r--r--lisp/emacs-lisp/eldoc.el32
1 files changed, 18 insertions, 14 deletions
diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el
index 22144ed7c18..e28d73c3555 100644
--- a/lisp/emacs-lisp/eldoc.el
+++ b/lisp/emacs-lisp/eldoc.el
@@ -5,7 +5,7 @@
5;; Author: Noah Friedman <friedman@splode.com> 5;; Author: Noah Friedman <friedman@splode.com>
6;; Keywords: extensions 6;; Keywords: extensions
7;; Created: 1995-10-06 7;; Created: 1995-10-06
8;; Version: 1.14.0 8;; Version: 1.15.0
9;; Package-Requires: ((emacs "26.3")) 9;; Package-Requires: ((emacs "26.3"))
10 10
11;; This is a GNU ELPA :core package. Avoid functionality that is not 11;; This is a GNU ELPA :core package. Avoid functionality that is not
@@ -605,25 +605,29 @@ known to be truncated."
605 'maybe))) 605 'maybe)))
606 (get-buffer-window eldoc--doc-buffer t))) 606 (get-buffer-window eldoc--doc-buffer t)))
607 607
608(defun eldoc-display-in-echo-area (docs _interactive) 608(defun eldoc-display-in-echo-area (docs interactive)
609 "Display DOCS in echo area. 609 "Display DOCS in echo area.
610Honor `eldoc-echo-area-use-multiline-p' and 610INTERACTIVE is non-nil if user explictly invoked ElDoc. Honor
611`eldoc-echo-area-use-multiline-p' and
611`eldoc-echo-area-prefer-doc-buffer'." 612`eldoc-echo-area-prefer-doc-buffer'."
612 (cond 613 (cond
613 (;; Check if we have permission to mess with echo area at all. For 614 ((and (not interactive)
614 ;; example, if this-command is non-nil while running via an idle 615 ;; When called non-interactively, check if we have permission
615 ;; timer, we're still in the middle of executing a command, e.g. a 616 ;; to mess with echo area at all. For example, if
616 ;; query-replace where it would be annoying to overwrite the echo 617 ;; this-command is non-nil while running via an idle timer,
617 ;; area. 618 ;; we're still in the middle of executing a command, e.g. a
618 (or 619 ;; query-replace where it would be annoying to overwrite the
619 (not (eldoc-display-message-no-interference-p)) 620 ;; echo area.
620 this-command 621 (or
621 (not (eldoc--message-command-p last-command)))) 622 (not (eldoc-display-message-no-interference-p))
622 (;; If we do but nothing to report, clear the echo area. 623 this-command
624 (not (eldoc--message-command-p last-command)))))
625 (;; If nothing to report, clear the echo area.
623 (null docs) 626 (null docs)
624 (eldoc--message nil)) 627 (eldoc--message nil))
625 (t 628 (t
626 ;; Otherwise, establish some parameters. 629 ;; Otherwise, proceed to change the echo area. Start by
630 ;; establishing some parameters.
627 (let* 631 (let*
628 ((width (1- (window-width (minibuffer-window)))) 632 ((width (1- (window-width (minibuffer-window))))
629 (val (if (and (symbolp eldoc-echo-area-use-multiline-p) 633 (val (if (and (symbolp eldoc-echo-area-use-multiline-p)