From: Lars Ingebrigtsen Date: Sun, 24 Apr 2022 11:53:17 +0000 (+0200) Subject: Allow 'C-u C-h .' to describe button/widgets X-Git-Tag: emacs-29.0.90~1931^2~333 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=4d5fd0174905863bea4110865a0c124f8999e273;p=emacs.git Allow 'C-u C-h .' to describe button/widgets * doc/emacs/help.texi (Help Summary): Document it. * lisp/help-at-pt.el (display-local-help): Display button/widget help (bug#54963). --- diff --git a/doc/emacs/help.texi b/doc/emacs/help.texi index 1f743ccd88f..ee3d898019e 100644 --- a/doc/emacs/help.texi +++ b/doc/emacs/help.texi @@ -182,7 +182,9 @@ programming language you are editing (@code{info-lookup-symbol}). @item C-h . Display the help message for a special text area, if point is in one (@code{display-local-help}). (These include, for example, links in -@file{*Help*} buffers.) @xref{Help Echo}. +@file{*Help*} buffers.) @xref{Help Echo}. If you use a prefix for +this command, and point as on a button or a widget, this command will +pop to a new buffer that describes the button/widget. @end table @node Key Help diff --git a/etc/NEWS b/etc/NEWS index 4dd56e005e4..48ff8c37087 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -416,6 +416,12 @@ command also works for non-Emoji characters.) ** Help ++++ +*** The 'C-h .' command now takes a prefix to display button/widget help. +'C-u C-h .' would previously inhibit displaying a warning message if +there's no local help at point. This has been changed to trigger a +call 'button-describe'/'widget-describe' instead. + --- *** New user option 'help-enable-variable-value-editing'. If enabled, 'e' on a value in *Help* will pop you to a new buffer diff --git a/lisp/help-at-pt.el b/lisp/help-at-pt.el index c5a9a93482c..5bdaa35c0bc 100644 --- a/lisp/help-at-pt.el +++ b/lisp/help-at-pt.el @@ -82,24 +82,33 @@ If this produces no string either, return nil." (if (and kbd (not (eq kbd t))) kbd echo))) ;;;###autoload -(defun display-local-help (&optional arg) +(defun display-local-help (&optional inhibit-warning describe-button) "Display local help in the echo area. -This displays a short help message, namely the string produced by -the `kbd-help' property at point. If `kbd-help' does not produce -a string, but the `help-echo' property does, then that string is -printed instead. +This command, by default, displays a short help message, namely +the string produced by the `kbd-help' property at point. If +`kbd-help' does not produce a string, but the `help-echo' +property does, then that string is printed instead. The string is passed through `substitute-command-keys' before it is displayed. -A numeric argument ARG prevents display of a message in case -there is no help. While ARG can be used interactively, it is -mainly meant for use from Lisp." - (interactive "P") +If INHIBIT-WARNING is non-nil, this prevents display of a message +in case there is no help. + +If DESCRIBE-BUTTON in non-nil (interactively, the prefix), and +there's a button/widget at point, pop to a buffer describing that +button/widget instead." + (interactive (list nil current-prefix-arg)) (let ((help (help-at-pt-kbd-string))) - (if help - (message "%s" (substitute-command-keys help)) - (if (not arg) (message "No local help at point"))))) + (cond + ((and describe-button (button-at (point))) + (button-describe)) + ((and describe-button (widget-at (point))) + (widget-describe)) + (help + (message "%s" (substitute-command-keys help))) + ((not inhibit-warning) + (message "No local help at point"))))) (defvar help-at-pt-timer nil "Non-nil means that a timer is set that checks for local help.