* doc/emacs/help.texi (Help Mode): Document it (bug#36767).
* lisp/help-fns.el (help-fns-function-description-header)
(describe-variable, describe-face, describe-keymap)
(describe-mode): Add the required data.
* lisp/help-mode.el (help-mode-map): Add 'i' and 's'.
(help-mode--current-data): New variable.
(help-mode): Make it local.
(help-view-source, help-goto-info): New commands.
@item C-c C-b
@itemx l
Go back to the previous help topic (@code{help-go-back}).
+@item s
+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}).
@end table
@cindex hyperlink
** 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.
+
---
*** The 'help-for-help' ('C-h C-h') screen has been redesigned.
nil t)
(help-xref-button 1 'help-function real-def)))))
- (when file-name
+ (if (not file-name)
+ (with-current-buffer standard-output
+ (setq help-mode--current-data (list :symbol function)))
;; We used to add .el to the file name,
;; but that's completely wrong when the user used load-file.
(princ (format-message " in `%s'"
(help-fns-short-filename file-name))))
;; Make a hyperlink to the library.
(with-current-buffer standard-output
+ (setq help-mode--current-data (list :symbol function
+ :file file-name))
(save-excursion
(re-search-backward (substitute-command-keys "`\\([^`']+\\)'")
nil t)
"C source code"
(help-fns-short-filename file-name))))
(with-current-buffer standard-output
- (save-excursion
+ (setq help-mode--current-data
+ (list :symbol variable
+ :file file-name))
+ (save-excursion
(re-search-backward (substitute-command-keys
"`\\([^`']+\\)'")
nil t)
(if valvoid
"It is void as a variable."
"Its "))
+ (with-current-buffer standard-output
+ (setq help-mode--current-data (list :symbol variable)))
(if valvoid
" is void as a variable."
(substitute-command-keys "'s ")))))
(concat "\\(" customize-label "\\)") nil t)
(help-xref-button 1 'help-customize-face f)))
(setq file-name (find-lisp-object-file-name f 'defface))
- (when file-name
+ (if (not file-name)
+ (setq help-mode--current-data (list :symbol f))
+ (setq help-mode--current-data (list :symbol f
+ :file file-name))
(princ (substitute-command-keys "Defined in `"))
(princ (help-fns-short-filename file-name))
(princ (substitute-command-keys "'"))
(unless used-gentemp
(princ (format-message "%S is a keymap variable" keymap))
(if (not file-name)
- (princ ".\n\n")
+ (progn
+ (setq help-mode--current-data (list :symbol keymap))
+ (princ ".\n\n"))
(princ (format-message
" defined in `%s'.\n\n"
(if (eq file-name 'C-source)
(re-search-backward (substitute-command-keys
"`\\([^`']+\\)'")
nil t)
+ (setq help-mode--current-data (list :symbol keymap
+ :file file-name))
(help-xref-button 1 'help-variable-def
keymap file-name))))
(when (and (not (equal "" doc)) doc)
(princ " mode")
(let* ((mode major-mode)
(file-name (find-lisp-object-file-name mode nil)))
- (when file-name
+ (if (not file-name)
+ (setq help-mode--current-data (list :symbol mode))
(princ (format-message " defined in `%s'"
(help-fns-short-filename file-name)))
;; Make a hyperlink to the library.
(save-excursion
(re-search-backward (substitute-command-keys "`\\([^`']+\\)'")
nil t)
+ (setq help-mode--current-data (list :symbol mode
+ :file file-name))
(help-xref-button 1 'help-function-def mode file-name)))))
(let ((fundoc (help-split-fundoc (documentation major-mode) nil 'doc)))
(with-current-buffer standard-output
(define-key map [XF86Forward] 'help-go-forward)
(define-key map "\C-c\C-c" 'help-follow-symbol)
(define-key map "\r" 'help-follow)
+ (define-key map "s" 'help-view-source)
+ (define-key map "i" 'help-goto-info)
map)
"Keymap for Help mode.")
["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"]))
(defvar help-mode-tool-bar-map
(let ((map (make-sparse-keymap)))
'help-echo (purecopy "mouse-2, RET: show corresponding NEWS announcement"))
\f
(defvar bookmark-make-record-function)
+(defvar help-mode--current-data nil)
;;;###autoload
(define-derived-mode help-mode special-mode "Help"
#'help-mode-revert-buffer)
(setq-local tool-bar-map
help-mode-tool-bar-map)
+ (setq-local help-mode--current-data nil)
(setq-local bookmark-make-record-function
#'help-bookmark-make-record))
(help-xref-go-forward (current-buffer))
(user-error "No next help buffer")))
+(defun help-view-source ()
+ "View the source of the current help item."
+ (interactive nil help-mode)
+ (unless help-mode--current-data
+ (error "Source file for the current help item is not defined"))
+ (help-function-def--button-function (plist-get help-mode--current-data :symbol)
+ (plist-get help-mode--current-data :file)))
+
+(defun help-goto-info ()
+ "View the *info* node of the current help item."
+ (interactive nil help-mode)
+ (unless help-mode--current-data
+ (error "No symbol to look up in the current buffer"))
+ (info-lookup-symbol (plist-get help-mode--current-data :symbol)
+ 'emacs-lisp-mode))
+
(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