Add new convenience command for *Help*

* doc/emacs/help.texi (Help Mode): Document it (bug#36767).

* lisp/help-mode.el (help-mode-map): Add 'c'.
(help-mode-menu): Add help-customize.
(help-customize): New command.
This commit is contained in:
Juri Linkov 2021-06-20 02:14:29 +03:00
parent 6636a64459
commit 415143de47
3 changed files with 23 additions and 9 deletions

View file

@ -456,6 +456,8 @@ View the source of the current help topic (if any)
(@code{help-view-source}).
@item i
Look up the current topic in the manual(s) (@code{help-goto-info}).
@item c
Customize the variable or the face (@code{help-customize}).
@end table
@cindex hyperlink

View file

@ -1131,13 +1131,12 @@ This change is for better compatibility with old versions of non-GNU
** Help
+++
*** New command 'help-view-source' ('s')
This command will view the source file (if any) of the current help
topic.
+++
*** New command 'help-goto-info' ('i')
This command will look up the current symbol (if any) in Info.
*** New convenience commands with short keys in the Help buffer.
New command 'help-view-source' ('s') will view the source file (if
any) of the current help topic. New command 'help-goto-info' ('i')
will look up the current symbol (if any) in Info. New command
'help-customize' ('c') will customize the variable or the face
(if any) whose doc string is being shown in the Help buffer.
---
*** The 'help-for-help' ('C-h C-h') screen has been redesigned.

View file

@ -46,6 +46,7 @@
(define-key map "\r" 'help-follow)
(define-key map "s" 'help-view-source)
(define-key map "i" 'help-goto-info)
(define-key map "c" 'help-customize)
map)
"Keymap for Help mode.")
@ -63,11 +64,13 @@
["Move to Previous Button" backward-button
:help "Move to the Previous Button in the help buffer"]
["Move to Next Button" forward-button
:help "Move to the Next Button in the help buffer"]
:help "Move to the Next Button in the help buffer"]
["View Source" help-view-source
:help "Go to the source file for the current help item"]
["Goto Info" help-goto-info
:help "Go to the info node for the current help item"]))
:help "Go to the info node for the current help item"]
["Customize" help-customize
:help "Customize variable or face"]))
(defvar help-mode-tool-bar-map
(let ((map (make-sparse-keymap)))
@ -746,6 +749,16 @@ See `help-make-xrefs'."
(info-lookup-symbol (plist-get help-mode--current-data :symbol)
'emacs-lisp-mode))
(defun help-customize ()
"Customize variable or face."
(interactive nil help-mode)
(let ((sym (plist-get help-mode--current-data :symbol)))
(unless (or (boundp sym) (facep sym))
(user-error "No variable or face to customize"))
(cond
((boundp sym) (customize-variable sym))
((facep sym) (customize-face sym)))))
(defun help-do-xref (_pos function args)
"Call the help cross-reference function FUNCTION with args ARGS.
Things are set up properly so that the resulting help-buffer has