summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1991-07-28 00:21:00 +0000
committerRoland McGrath <roland@gnu.org>1991-07-28 00:21:00 +0000
commitf0a8a3f19809587d848a1e01391af0d3e8791d92 (patch)
tree5b06eeaba455364264f6243088602e79f85a39bd /lisp
parent43bad9918a91877e1361d76544e0e5e78a0b998d (diff)
downloademacs-f0a8a3f19809587d848a1e01391af0d3e8791d92.tar.gz
*** empty log message ***
Diffstat (limited to 'lisp')
-rw-r--r--lisp/info.el69
1 files changed, 69 insertions, 0 deletions
diff --git a/lisp/info.el b/lisp/info.el
index f009accc567..d31e86839a8 100644
--- a/lisp/info.el
+++ b/lisp/info.el
@@ -923,3 +923,72 @@ Allowed only if variable `Info-enable-edit' is non-nil."
(and (marker-position Info-tag-table-marker)
(buffer-modified-p)
(message "Tags may have changed. Use Info-tagify if necessary")))
+
+(defun Info-find-emacs-command-nodes (command)
+ "Return a list of locations documenting COMMAND in the Emacs Info manual.
+The locations are of the format used in Info-history, i.e.
+\(FILENAME NODENAME BUFFERPOS\)."
+ (require 'info)
+ (let ((where '())
+ (cmd-desc (concat "^\\* " (regexp-quote (symbol-name command))
+ ":\\s *\\(.*\\)\\.$")))
+ (save-excursion
+ (Info-find-node "emacs" "Command Index")
+ ;; Take the index node off the Info history.
+ (setq Info-history (cdr Info-history))
+ (goto-char (point-max))
+ (while (re-search-backward cmd-desc nil t)
+ (setq where (cons (list Info-current-file
+ (buffer-substring
+ (match-beginning 1)
+ (match-end 1))
+ 0)
+ where)))
+ where)))
+
+;;;###autoload
+(defun Info-goto-emacs-command-node (command)
+ "Go to the Info node in the Emacs manual for command COMMAND."
+ (interactive "CFind documentation for command: ")
+ (or (commandp command)
+ (signal 'wrong-type-argument (list 'commandp command)))
+ (let ((where (Info-find-emacs-command-nodes command)))
+ (if where
+ (let ((num-matches (length where)))
+ ;; Get Info running, and pop to it in another window.
+ (save-window-excursion
+ (info))
+ (pop-to-buffer "*info*")
+ (Info-find-node (car (car where))
+ (car (cdr (car where))))
+ (if (> num-matches 1)
+ (progn
+ ;; Info-find-node already pushed (car where) onto
+ ;; Info-history. Put the other nodes that were found on
+ ;; the history.
+ (setq Info-history (nconc (cdr where) Info-history))
+ (message (substitute-command-keys
+ "Found %d other entr%. Use \\[Info-last] to see %s."
+ (1- num-matches)
+ (if (> num-matches 2) "ies" "y")
+ (if (> num-matches 2) "them" "it"))))))
+ (error "Couldn't find documentation for %s." command))))
+;;;###autoload
+(define-key help-map "\C-f" 'Info-goto-emacs-command-node)
+
+;;;###autoload
+(defun Info-goto-emacs-key-command-node (key)
+ "Go to the Info node in the Emacs manual the command bound to KEY, a string.
+Interactively, if the binding is execute-extended-command, a command is read."
+ (interactive "kFind documentation for key:")
+ (let ((command (key-binding key)))
+ (cond ((null command)
+ (message "%s is undefined" (key-description keys)))
+ ((and (interactive-p)
+ (eq command 'execute-extended-command))
+ (Info-goto-emacs-command-node
+ (read-command "Find documentation for command: ")))
+ (t
+ (Info-goto-emacs-command-node command)))))
+;;;###autoload
+(define-key help-map "\C-k" 'Info-goto-emacs-key-command-node)