summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/eldoc.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/emacs-lisp/eldoc.el')
-rw-r--r--lisp/emacs-lisp/eldoc.el38
1 files changed, 27 insertions, 11 deletions
diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el
index 37db28f2a50..2892faae21d 100644
--- a/lisp/emacs-lisp/eldoc.el
+++ b/lisp/emacs-lisp/eldoc.el
@@ -3,7 +3,6 @@
;; Copyright (C) 1996-2019 Free Software Foundation, Inc.
;; Author: Noah Friedman <friedman@splode.com>
-;; Maintainer: friedman@splode.com
;; Keywords: extensions
;; Created: 1995-10-06
@@ -177,9 +176,6 @@ printed after commands contained in this obarray."
;;;###autoload
(define-minor-mode eldoc-mode
"Toggle echo area display of Lisp objects at point (ElDoc mode).
-With a prefix argument ARG, enable ElDoc mode if ARG is positive,
-and disable it otherwise. If called from Lisp, enable ElDoc mode
-if ARG is omitted or nil.
ElDoc mode is a buffer-local minor mode. When enabled, the echo
area displays information about a function or variable in the
@@ -211,7 +207,24 @@ expression point is on."
(define-globalized-minor-mode global-eldoc-mode eldoc-mode turn-on-eldoc-mode
:group 'eldoc
:initialize 'custom-initialize-delay
- :init-value t)
+ :init-value t
+ ;; For `read--expression', the usual global mode mechanism of
+ ;; `change-major-mode-hook' runs in the minibuffer before
+ ;; `eldoc-documentation-function' is set, so `turn-on-eldoc-mode'
+ ;; does nothing. Configure and enable eldoc from
+ ;; `eval-expression-minibuffer-setup-hook' instead.
+ (if global-eldoc-mode
+ (add-hook 'eval-expression-minibuffer-setup-hook
+ #'eldoc--eval-expression-setup)
+ (remove-hook 'eval-expression-minibuffer-setup-hook
+ #'eldoc--eval-expression-setup)))
+
+(defun eldoc--eval-expression-setup ()
+ ;; Setup `eldoc', similar to `emacs-lisp-mode'. FIXME: Call
+ ;; `emacs-lisp-mode' itself?
+ (add-function :before-until (local 'eldoc-documentation-function)
+ #'elisp-eldoc-documentation-function)
+ (eldoc-mode +1))
;;;###autoload
(defun turn-on-eldoc-mode ()
@@ -360,12 +373,15 @@ return any documentation.")
;; This is run from post-command-hook or some idle timer thing,
;; so we need to be careful that errors aren't ignored.
(with-demoted-errors "eldoc error: %s"
- (and (or (eldoc-display-message-p)
- ;; Erase the last message if we won't display a new one.
- (when eldoc-last-message
- (eldoc-message nil)
- nil))
- (eldoc-message (funcall eldoc-documentation-function)))))
+ (if (not (eldoc-display-message-p))
+ ;; Erase the last message if we won't display a new one.
+ (when eldoc-last-message
+ (eldoc-message nil))
+ (let ((non-essential t))
+ ;; Only keep looking for the info as long as the user hasn't
+ ;; requested our attention. This also locally disables inhibit-quit.
+ (while-no-input
+ (eldoc-message (funcall eldoc-documentation-function)))))))
;; If the entire line cannot fit in the echo area, the symbol name may be
;; truncated or eliminated entirely from the output to make room for the