]> code.delx.au - gnu-emacs/commitdiff
*** empty log message ***
authorRoland McGrath <roland@gnu.org>
Sun, 28 Jul 1991 00:21:00 +0000 (00:21 +0000)
committerRoland McGrath <roland@gnu.org>
Sun, 28 Jul 1991 00:21:00 +0000 (00:21 +0000)
lisp/info.el

index f009accc567f2ab2b3a0fc4e43423f2c2d91129c..d31e86839a899128f852390ceebe953fc7cb6471 100644 (file)
@@ -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")))
+\f
+(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)