diff options
author | Daniel Mendler <mail@daniel-mendler.de> | 2025-03-22 10:29:45 +0100 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2025-03-29 13:50:26 +0300 |
commit | ab71699e5f2502aff6c65dd195611cfbbe2f2255 (patch) | |
tree | 3e295dda9c52f8d0d92be4cba8c9ac36b88af5e9 /lisp/emacs-lisp/eldoc.el | |
parent | b832d37410c955b30adfb89e17339e406eeefa01 (diff) | |
download | emacs-ab71699e5f2502aff6c65dd195611cfbbe2f2255.tar.gz emacs-ab71699e5f2502aff6c65dd195611cfbbe2f2255.tar.bz2 emacs-ab71699e5f2502aff6c65dd195611cfbbe2f2255.zip |
New Eldoc function `eldoc-show-help-at-pt'
Show `help-at-pt' string via Eldoc as an alternative to the
`help-at-pt-display-when-idle' timer. The help-at-pt timer
competes with Eldoc for the echo area, such that the two
mechanisms do not work well together. Therefore when using
Eldoc, the setting `eldoc-help-at-pt' may be preferable.
* lisp/emacs-lisp/eldoc.el (eldoc-help-at-pt): New customization option.
(eldoc-show-help-at-pt): New Eldoc function.
(eldoc-documentation-functions): Register the new function.
* lisp/help-at-pt.el (help-at-pt-display-when-idle): Mention
`eldoc-help-at-pt' in the docstring.
* doc/emacs/help.texi: Document `eldoc-help-at-pt'.
* etc/NEWS: Announce the change. (Bug#77169)
Diffstat (limited to 'lisp/emacs-lisp/eldoc.el')
-rw-r--r-- | lisp/emacs-lisp/eldoc.el | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el index 85fb6c780e2..2b5d5cc0c8d 100644 --- a/lisp/emacs-lisp/eldoc.el +++ b/lisp/emacs-lisp/eldoc.el @@ -138,6 +138,13 @@ is only skipped if the documentation needs to be truncated there." (const :tag "Skip echo area if truncating" maybe)) :version "28.1") +(defcustom eldoc-help-at-pt nil + "If non-nil, show `help-at-pt-kbd-string' at point via Eldoc. +This setting is an alternative to `help-at-pt-display-when-idle'. If +the value is non-nil, `eldoc-show-help-at-pt' will show help-at-point +via Eldoc." + :type 'boolean) + (defface eldoc-highlight-function-argument '((t (:inherit bold))) "Face used for the argument at point in a function's argument list. @@ -410,7 +417,7 @@ Also store it in `eldoc-last-message' and return that value." (overlay-end show-paren--overlay))))))) -(defvar eldoc-documentation-functions nil +(defvar eldoc-documentation-functions (list #'eldoc-show-help-at-pt) "Hook of functions that produce doc strings. A doc string is typically relevant if point is on a function-like @@ -957,6 +964,12 @@ the docstrings eventually produced, using (setq eldoc--last-request-state token) (eldoc--invoke-strategy nil)))))) +(defun eldoc-show-help-at-pt (&rest _) + "Show help at point via Eldoc if `eldoc-help-at-pt' is non-nil. +Intended for `eldoc-documentation-functions' (which see)." + (when-let* ((help (and eldoc-help-at-pt (help-at-pt-kbd-string)))) + (format "Help: %s" (substitute-command-keys help)))) + ;; This section only affects ElDoc output to the echo area, as in ;; `eldoc-display-in-echo-area'. |