aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Mendler2025-03-22 10:29:45 +0100
committerEli Zaretskii2025-03-29 13:50:26 +0300
commitab71699e5f2502aff6c65dd195611cfbbe2f2255 (patch)
tree3e295dda9c52f8d0d92be4cba8c9ac36b88af5e9
parentb832d37410c955b30adfb89e17339e406eeefa01 (diff)
downloademacs-ab71699e5f2502aff6c65dd195611cfbbe2f2255.tar.gz
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)
-rw-r--r--doc/emacs/help.texi4
-rw-r--r--etc/NEWS5
-rw-r--r--lisp/emacs-lisp/eldoc.el15
-rw-r--r--lisp/help-at-pt.el7
4 files changed, 28 insertions, 3 deletions
diff --git a/doc/emacs/help.texi b/doc/emacs/help.texi
index 5c2eabb02d6..6ea7b5783c2 100644
--- a/doc/emacs/help.texi
+++ b/doc/emacs/help.texi
@@ -857,9 +857,11 @@ over the active text displays the help text as a @dfn{tooltip}.
857@kindex C-h . 857@kindex C-h .
858@findex display-local-help 858@findex display-local-help
859@vindex help-at-pt-display-when-idle 859@vindex help-at-pt-display-when-idle
860@vindex eldoc-help-at-pt
860 On terminals that don't support mouse-tracking, you can display the 861 On terminals that don't support mouse-tracking, you can display the
861help text for active buffer text at point by typing @kbd{C-h .} 862help text for active buffer text at point by typing @kbd{C-h .}
862(@code{display-local-help}). This shows the help text in the echo 863(@code{display-local-help}). This shows the help text in the echo
863area. To display help text automatically whenever it is available at 864area. To display help text automatically whenever it is available at
864point, set the variable @code{help-at-pt-display-when-idle} to 865point, set the variable @code{help-at-pt-display-when-idle} to
865@code{t}. 866@code{t}. If you use Eldoc, set the variable @code{eldoc-help-at-pt}
867to @code{t} instead.
diff --git a/etc/NEWS b/etc/NEWS
index fea533d0d20..f9ee001294f 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -429,6 +429,11 @@ need to set it with 'setopt' for it to take an effect. If the docstring
429doesn't already mention 'setopt', the 'describe-variable' command will 429doesn't already mention 'setopt', the 'describe-variable' command will
430now add a note about this automatically. 430now add a note about this automatically.
431 431
432+++
433** New user option 'eldoc-help-at-pt' to show help at point via Eldoc.
434When enabled, display the 'help-at-pt-kbd-string' via Eldoc. This
435setting is an alternative to 'help-at-pt-display-when-idle'.
436
432 437
433* Editing Changes in Emacs 31.1 438* Editing Changes in Emacs 31.1
434 439
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."
138 (const :tag "Skip echo area if truncating" maybe)) 138 (const :tag "Skip echo area if truncating" maybe))
139 :version "28.1") 139 :version "28.1")
140 140
141(defcustom eldoc-help-at-pt nil
142 "If non-nil, show `help-at-pt-kbd-string' at point via Eldoc.
143This setting is an alternative to `help-at-pt-display-when-idle'. If
144the value is non-nil, `eldoc-show-help-at-pt' will show help-at-point
145via Eldoc."
146 :type 'boolean)
147
141(defface eldoc-highlight-function-argument 148(defface eldoc-highlight-function-argument
142 '((t (:inherit bold))) 149 '((t (:inherit bold)))
143 "Face used for the argument at point in a function's argument list. 150 "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."
410 (overlay-end show-paren--overlay))))))) 417 (overlay-end show-paren--overlay)))))))
411 418
412 419
413(defvar eldoc-documentation-functions nil 420(defvar eldoc-documentation-functions (list #'eldoc-show-help-at-pt)
414 "Hook of functions that produce doc strings. 421 "Hook of functions that produce doc strings.
415 422
416A doc string is typically relevant if point is on a function-like 423A doc string is typically relevant if point is on a function-like
@@ -957,6 +964,12 @@ the docstrings eventually produced, using
957 (setq eldoc--last-request-state token) 964 (setq eldoc--last-request-state token)
958 (eldoc--invoke-strategy nil)))))) 965 (eldoc--invoke-strategy nil))))))
959 966
967(defun eldoc-show-help-at-pt (&rest _)
968 "Show help at point via Eldoc if `eldoc-help-at-pt' is non-nil.
969Intended for `eldoc-documentation-functions' (which see)."
970 (when-let* ((help (and eldoc-help-at-pt (help-at-pt-kbd-string))))
971 (format "Help: %s" (substitute-command-keys help))))
972
960 973
961;; This section only affects ElDoc output to the echo area, as in 974;; This section only affects ElDoc output to the echo area, as in
962;; `eldoc-display-in-echo-area'. 975;; `eldoc-display-in-echo-area'.
diff --git a/lisp/help-at-pt.el b/lisp/help-at-pt.el
index 68054016dc5..094f2b788fe 100644
--- a/lisp/help-at-pt.el
+++ b/lisp/help-at-pt.el
@@ -191,7 +191,12 @@ list of properties through Custom will set the timer, thus
191enabling buffer local values. It sets the actual value to nil. 191enabling buffer local values. It sets the actual value to nil.
192Thus, Custom distinguishes between a nil value and other values 192Thus, Custom distinguishes between a nil value and other values
193that disable the feature, which Custom identifies with `never'. 193that disable the feature, which Custom identifies with `never'.
194The default is `never'." 194The default is `never'.
195
196Eldoc uses the echo area to display documentation. As such it
197conflicts with `help-at-pt-display-when-idle' due to the use of
198the echo area. If you use Eldoc, consider setting
199`eldoc-help-at-pt' instead."
195 :group 'help-at-pt 200 :group 'help-at-pt
196 :type '(choice (const :tag "Always" 201 :type '(choice (const :tag "Always"
197 :format "%t\n%h" 202 :format "%t\n%h"