/[emacs]/emacs/lisp/info.el
ViewVC logotype

Diff of /emacs/lisp/info.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.367.2.1 by handa, Fri Apr 16 12:50:05 2004 UTC revision 1.367.2.2 by miles, Mon Jun 28 07:28:41 2004 UTC
# Line 66  The Lisp code is executed when the node Line 66  The Lisp code is executed when the node
66  (put 'Info-enable-active-nodes 'risky-local-variable t)  (put 'Info-enable-active-nodes 'risky-local-variable t)
67    
68  (defface info-node  (defface info-node
69    '((((class color) (background light)) (:foreground "brown" :weight bold :slant italic))    '((((class color) (background light)) :foreground "brown" :weight bold :slant italic)
70      (((class color) (background dark)) (:foreground "white" :weight bold :slant italic))      (((class color) (background dark)) :foreground "white" :weight bold :slant italic)
71      (t (:weight bold :slant italic)))      (t :weight bold :slant italic))
72    "Face for Info node names."    "Face for Info node names."
73    :group 'info)    :group 'info)
74    
75  (defface info-menu-5  (defface info-menu-5
76    '((((class color)) (:foreground "red1"))    '((((class color)) :foreground "red1")
77      (t (:underline t)))      (t :underline t))
78    "Face for every third `*' in an Info menu."    "Face for every third `*' in an Info menu."
79    :group 'info)    :group 'info)
80    
81  (defface info-xref  (defface info-xref
82    '((((class color) (background light)) (:foreground "blue"))    '((((class color) (background light)) :foreground "blue")
83      (((class color) (background dark)) (:foreground "cyan"))      (((class color) (background dark)) :foreground "cyan")
84      (t (:underline t)))      (t :underline t))
85    "Face for Info cross-references."    "Face for Info cross-references."
86    :group 'info)    :group 'info)
87    
88  (defface info-xref-visited  (defface info-xref-visited
89    '((((class color) (background light)) (:foreground "magenta4"))    '((t :inherit info-xref)
90      (((class color) (background dark)) (:foreground "magenta4"))      (((class color) (background light)) :foreground "magenta4")
91      (t (:underline t)))      (((class color) (background dark)) :foreground "magenta3")) ;"violet"?
92    "Face for visited Info cross-references."    "Face for visited Info cross-references."
93    :group 'info)    :group 'info)
94    
# Line 110  A header-line does not scroll with the r Line 110  A header-line does not scroll with the r
110    :group 'info)    :group 'info)
111    
112  (defface info-header-xref  (defface info-header-xref
113    '((t (:inherit info-xref)))    '((t :inherit info-xref))
114    "Face for Info cross-references in a node header."    "Face for Info cross-references in a node header."
115    :group 'info)    :group 'info)
116    
117  (defface info-header-node  (defface info-header-node
118    '((t (:inherit info-node)))    '((t :inherit info-node))
119    "Face for Info nodes in a node header."    "Face for Info nodes in a node header."
120    :group 'info)    :group 'info)
121    
# Line 239  Marker points nowhere if file has no tag Line 239  Marker points nowhere if file has no tag
239  (defvar Info-index-alternatives nil  (defvar Info-index-alternatives nil
240    "List of possible matches for last `Info-index' command.")    "List of possible matches for last `Info-index' command.")
241    
242  (defvar Info-reference-name nil  (defvar Info-point-loc nil
243    "Name of the selected cross-reference.    "Point location within a selected node.
244  Point is moved to the proper occurrence of this name within a node  If string, the point is moved to the proper occurrence of the
245  after selecting it.")  name of the followed cross reference within a selected node.
246    If number, the point is moved to the corresponding line.")
247    
248  (defvar Info-standalone nil  (defvar Info-standalone nil
249    "Non-nil if Emacs was started solely as an Info browser.")    "Non-nil if Emacs was started solely as an Info browser.")
# Line 449  Do the right thing if the file has been Line 450  Do the right thing if the file has been
450    "Like `info' but show the Info buffer in another window."    "Like `info' but show the Info buffer in another window."
451    (interactive (if current-prefix-arg    (interactive (if current-prefix-arg
452                     (list (read-file-name "Info file name: " nil nil t))))                     (list (read-file-name "Info file name: " nil nil t))))
453    (let (same-window-buffer-names)    (let (same-window-buffer-names same-window-regexps)
454      (info file)))      (info file)))
455    
456  ;;;###autoload (add-hook 'same-window-buffer-names "*info*")  ;;;###autoload (add-hook 'same-window-regexps "\\*info\\*\\(\\|<[0-9]+>\\)")
457    
458  ;;;###autoload  ;;;###autoload
459  (defun info (&optional file)  (defun info (&optional file buffer)
460    "Enter Info, the documentation browser.    "Enter Info, the documentation browser.
461  Optional argument FILE specifies the file to examine;  Optional argument FILE specifies the file to examine;
462  the default is the top-level directory of Info.  the default is the top-level directory of Info.
463  Called from a program, FILE may specify an Info node of the form  Called from a program, FILE may specify an Info node of the form
464  `(FILENAME)NODENAME'.  `(FILENAME)NODENAME'.
465    Optional argument BUFFER specifies the Info buffer name;
466  In interactive use, a prefix argument directs this command  the default buffer name is *info*.  If BUFFER exists,
467  to read a file name from the minibuffer.  just switch to BUFFER.  Otherwise, create a new buffer
468    with the top-level Info directory.
469    
470    In interactive use, a non-numeric prefix argument directs
471    this command to read a file name from the minibuffer.
472    A numeric prefix argument selects an Info buffer with the prefix number
473    appended to the Info buffer name.
474    
475  The search path for Info files is in the variable `Info-directory-list'.  The search path for Info files is in the variable `Info-directory-list'.
476  The top-level Info directory is made by combining all the files named `dir'  The top-level Info directory is made by combining all the files named `dir'
477  in all the directories in that path."  in all the directories in that path."
478    (interactive (if current-prefix-arg    (interactive (list
479                     (list (read-file-name "Info file name: " nil nil t))))                  (if (and current-prefix-arg (not (numberp current-prefix-arg)))
480    (pop-to-buffer "*info*")                      (read-file-name "Info file name: " nil nil t))
481                    (if (numberp current-prefix-arg)
482                        (format "*info*<%s>" current-prefix-arg))))
483      (pop-to-buffer (or buffer "*info*"))
484      (if (and buffer (not (eq major-mode 'Info-mode)))
485          (Info-mode))
486    (if file    (if file
487        ;; If argument already contains parentheses, don't add another set        ;; If argument already contains parentheses, don't add another set
488        ;; since the argument will then be parsed improperly.  This also        ;; since the argument will then be parsed improperly.  This also
# Line 480  in all the directories in that path." Line 492  in all the directories in that path."
492            (Info-goto-node file)            (Info-goto-node file)
493          (Info-goto-node (concat "(" file ")")))          (Info-goto-node (concat "(" file ")")))
494      (if (zerop (buffer-size))      (if (zerop (buffer-size))
495        (Info-directory))))          (Info-directory))))
496    
497  ;;;###autoload  ;;;###autoload
498  (defun info-emacs-manual ()  (defun info-emacs-manual ()
# Line 535  just return nil (no error)." Line 547  just return nil (no error)."
547    (if (stringp filename)    (if (stringp filename)
548        (let (temp temp-downcase found)        (let (temp temp-downcase found)
549          (setq filename (substitute-in-file-name filename))          (setq filename (substitute-in-file-name filename))
550          (cond          (cond
551           ((string= (downcase filename) "dir")           ((string= (downcase filename) "dir")
552            (setq found t))            (setq found t))
553           ((string= filename "apropos")           ((string= filename "apropos")
554            (setq found 'apropos))            (setq found 'apropos))
555             ((string= filename "history")
556              (setq found 'history))
557             ((string= filename "toc")
558              (setq found 'toc))
559           (t           (t
560            (let ((dirs (if (string-match "^\\./" filename)            (let ((dirs (if (string-match "^\\./" filename)
561                            ;; If specified name starts with `./'                            ;; If specified name starts with `./'
# Line 742  a case-insensitive match is tried." Line 758  a case-insensitive match is tried."
758                  (Info-insert-dir))                  (Info-insert-dir))
759                 ((eq filename 'apropos)                 ((eq filename 'apropos)
760                  (insert-buffer-substring " *info-apropos*"))                  (insert-buffer-substring " *info-apropos*"))
761                   ((eq filename 'history)
762                    (insert-buffer-substring " *info-history*"))
763                   ((eq filename 'toc)
764                    (insert-buffer-substring " *info-toc*"))
765                 (t                 (t
766                  (info-insert-file-contents filename nil)                  (info-insert-file-contents filename nil)
767                  (setq default-directory (file-name-directory filename))))                  (setq default-directory (file-name-directory filename))))
# Line 782  a case-insensitive match is tried." Line 802  a case-insensitive match is tried."
802                      (cond                      (cond
803                       ((eq filename t) "dir")                       ((eq filename t) "dir")
804                       ((eq filename 'apropos) "apropos")                       ((eq filename 'apropos) "apropos")
805                         ((eq filename 'history) "history")
806                         ((eq filename 'toc) "toc")
807                       (t filename)))                       (t filename)))
808                ))                ))
809          ;; Use string-equal, not equal, to ignore text props.          ;; Use string-equal, not equal, to ignore text props.
# Line 842  a case-insensitive match is tried." Line 864  a case-insensitive match is tried."
864                (let ((pos (Info-find-node-in-buffer regexp)))                (let ((pos (Info-find-node-in-buffer regexp)))
865                  (when pos                  (when pos
866                    (goto-char pos)                    (goto-char pos)
867                    (throw 'foo t))                    (throw 'foo t)))
868                  (error "No such anchor in tag table or node in tag table or file: %s"  
869                         nodename)))                (when (string-match "\\([^.]+\\)\\." nodename)
870                    (let (Info-point-loc)
871                      (Info-find-node-2
872                       filename (match-string 1 nodename) no-going-back))
873                    (widen)
874                    (throw 'foo t))
875    
876                  ;; No such anchor in tag table or node in tag table or file
877                  (error "No such node or anchor: %s" nodename))
878    
879              (Info-select-node)              (Info-select-node)
880              (goto-char (point-min))              (goto-char (point-min))
# Line 856  a case-insensitive match is tried." Line 886  a case-insensitive match is tried."
886                             (cons new-history                             (cons new-history
887                                   (delete new-history Info-history-list))))                                   (delete new-history Info-history-list))))
888                     (goto-char anchorpos))                     (goto-char anchorpos))
889                    (Info-reference-name                    ((numberp Info-point-loc)
890                     (Info-find-index-name Info-reference-name)                     (forward-line (1- Info-point-loc))
891                     (setq Info-reference-name nil))))))                     (setq Info-point-loc nil))
892                      ((stringp Info-point-loc)
893                       (Info-find-index-name Info-point-loc)
894                       (setq Info-point-loc nil))))))
895      ;; If we did not finish finding the specified node,      ;; If we did not finish finding the specified node,
896      ;; go back to the previous one.      ;; go back to the previous one.
897      (or Info-current-node no-going-back (null Info-history)      (or Info-current-node no-going-back (null Info-history)
# Line 982  a case-insensitive match is tried." Line 1015  a case-insensitive match is tried."
1015                      nodename end)                      nodename end)
1016                  (re-search-backward "^\^_")                  (re-search-backward "^\^_")
1017                  (search-forward "Node: ")                  (search-forward "Node: ")
1018                  (setq nodename                  (setq nodename (Info-following-node-name))
                       (and (looking-at (Info-following-node-name-re))  
                            (match-string 1)))  
1019                  (search-forward "\n\^_" nil 'move)                  (search-forward "\n\^_" nil 'move)
1020                  (beginning-of-line)                  (beginning-of-line)
1021                  (setq end (point))                  (setq end (point))
# Line 1053  a case-insensitive match is tried." Line 1084  a case-insensitive match is tried."
1084      (goto-char (point-min))      (goto-char (point-min))
1085      ;; Remove duplicate headings in the same menu.      ;; Remove duplicate headings in the same menu.
1086      (while (search-forward "\n* Menu:" nil t)      (while (search-forward "\n* Menu:" nil t)
1087        (setq limit (save-excursion (search-forward "\n" nil t)))        (setq limit (save-excursion (search-forward "\n\^_" nil t)))
1088        ;; Look for the next heading to unify.        ;; Look for the next heading to unify.
1089        (while (re-search-forward "^\\(\\w.*\\)\n\\*" limit t)        (while (re-search-forward "^\\(\\w.*\\)\n\\*" limit t)
1090          (let ((name (match-string 1))          (let ((name (match-string 1))
# Line 1264  any double quotes or backslashes must be Line 1295  any double quotes or backslashes must be
1295          (let ((new-history (list Info-current-file Info-current-node)))          (let ((new-history (list Info-current-file Info-current-node)))
1296            (setq Info-history-list            (setq Info-history-list
1297                  (cons new-history (delete new-history Info-history-list))))                  (cons new-history (delete new-history Info-history-list))))
1298          (Info-fontify-node)          (if (not (eq Info-fontify-maximum-menu-size nil))
1299                (Info-fontify-node))
1300          (Info-display-images-node)          (Info-display-images-node)
1301          (Info-hide-cookies-node)          (Info-hide-cookies-node)
1302          (run-hooks 'Info-selection-hook)))))          (run-hooks 'Info-selection-hook)))))
# Line 1284  any double quotes or backslashes must be Line 1316  any double quotes or backslashes must be
1316  ;; Go to an info node specified with a filename-and-nodename string  ;; Go to an info node specified with a filename-and-nodename string
1317  ;; of the sort that is found in pointers in nodes.  ;; of the sort that is found in pointers in nodes.
1318    
1319    ;;;###autoload
1320  (defun Info-goto-node (nodename &optional fork)  (defun Info-goto-node (nodename &optional fork)
1321    "Go to info node named NODENAME.  Give just NODENAME or (FILENAME)NODENAME.    "Go to info node named NODENAME.  Give just NODENAME or (FILENAME)NODENAME.
1322  If NODENAME is of the form (FILENAME)NODENAME, the node is in the Info file  If NODENAME is of the form (FILENAME)NODENAME, the node is in the Info file
# Line 1298  If FORK is a string, it is the name to u Line 1331  If FORK is a string, it is the name to u
1331    (if fork    (if fork
1332        (set-buffer        (set-buffer
1333         (clone-buffer (concat "*info-" (if (stringp fork) fork nodename) "*") t)))         (clone-buffer (concat "*info-" (if (stringp fork) fork nodename) "*") t)))
   (if (member (buffer-name) '("*info-history*" "*info-toc*"))  
       (switch-to-buffer "*info*"))  
1334    (let (filename)    (let (filename)
1335      (string-match "\\s *\\((\\s *\\([^\t)]*\\)\\s *)\\s *\\|\\)\\(.*\\)"      (string-match "\\s *\\((\\s *\\([^\t)]*\\)\\s *)\\s *\\|\\)\\(.*\\)"
1336                    nodename)                    nodename)
# Line 1307  If FORK is a string, it is the name to u Line 1338  If FORK is a string, it is the name to u
1338                         ""                         ""
1339                       (match-string 2 nodename))                       (match-string 2 nodename))
1340            nodename (match-string 3 nodename))            nodename (match-string 3 nodename))
1341      (let ((trim (string-match "\\s *\\'" filename)))      (let ((trim (string-match "\\s +\\'" filename)))
1342        (if trim (setq filename (substring filename 0 trim))))        (if trim (setq filename (substring filename 0 trim))))
1343      (let ((trim (string-match "\\s *\\'" nodename)))      (let ((trim (string-match "\\s +\\'" nodename)))
1344        (if trim (setq nodename (substring nodename 0 trim))))        (if trim (setq nodename (substring nodename 0 trim))))
1345      (if transient-mark-mode (deactivate-mark))      (if transient-mark-mode (deactivate-mark))
1346      (Info-find-node (if (equal filename "") nil filename)      (Info-find-node (if (equal filename "") nil filename)
# Line 1616  If SAME-FILE is non-nil, do not move to Line 1647  If SAME-FILE is non-nil, do not move to
1647    (interactive)    (interactive)
1648    (Info-find-node "dir" "top"))    (Info-find-node "dir" "top"))
1649    
 ;;;###autoload (add-hook 'same-window-buffer-names "*info-history*")  
   
1650  (defun Info-history ()  (defun Info-history ()
1651    "Create the buffer *info-history* with a menu of visited nodes."    "Go to a node with a menu of visited nodes."
1652    (interactive)    (interactive)
1653    (let ((curr-file Info-current-file)    (let ((curr-file Info-current-file)
1654          (curr-node Info-current-node)          (curr-node Info-current-node)
1655          p)          p)
1656      (pop-to-buffer      (with-current-buffer (get-buffer-create " *info-history*")
1657       (with-current-buffer (get-buffer-create "*info-history*")        (let ((inhibit-read-only t))
1658         (let ((inhibit-read-only t))          (erase-buffer)
1659           (erase-buffer)          (goto-char (point-min))
1660           (goto-char (point-min))          (insert "\n\^_\nFile: history Node: Top, Up: (dir)\n\n")
1661           (insert "Node: History\n\n")          (insert "Recently Visited Nodes\n**********************\n\n")
1662           (insert "Recently Visited Nodes\n**********************\n\n")          (insert "* Menu:\n\n")
1663           (insert "* Menu:\n\n")          (let ((hl (delete '("history" "Top") Info-history-list)))
1664           (let ((hl Info-history-list))            (while hl
1665             (while hl              (let ((file (nth 0 (car hl)))
1666               (let ((file (nth 0 (car hl)))                    (node (nth 1 (car hl))))
1667                     (node (nth 1 (car hl))))                (if (and (string-equal file curr-file)
1668                 (if (and (string-equal file curr-file)                         (string-equal node curr-node))
1669                          (string-equal node curr-node))                    (setq p (point)))
1670                     (setq p (point)))                (insert "* " node ": (" (file-name-nondirectory file)
1671                 (insert "* " node ": (" (file-name-nondirectory file)                        ")" node ".\n"))
1672                         ")" node ".\n"))              (setq hl (cdr hl))))))
1673               (setq hl (cdr hl))))      (Info-find-node "history" "Top")
          (or (eq major-mode 'Info-mode) (Info-mode))  
          (setq Info-current-file "info-history")  
          (setq Info-current-node "Info History")  
          (Info-set-mode-line)  
          (if (not (bobp)) (Info-fontify-node))  
          (current-buffer))))  
1674      (goto-char (or p (point-min)))))      (goto-char (or p (point-min)))))
1675    
 ;;;###autoload (add-hook 'same-window-buffer-names "*info-toc*")  
   
1676  (defun Info-toc ()  (defun Info-toc ()
1677    "Create the buffer *info-toc* with Info file's table of contents."    "Go to a node with table of contents of the current Info file.
1678    Table of contents is created from the tree structure of menus."
1679    (interactive)    (interactive)
1680    (let ((curr-file Info-current-file)    (let ((curr-file Info-current-file)
1681          (curr-node Info-current-node)          (curr-node Info-current-node)
1682          p)          p)
1683      (pop-to-buffer      (with-current-buffer (get-buffer-create " *info-toc*")
1684       (with-current-buffer (get-buffer-create "*info-toc*")        (let ((inhibit-read-only t)
1685         (if (not (equal Info-current-file curr-file))              (node-list (Info-build-toc curr-file)))
1686             (let ((inhibit-read-only t)          (erase-buffer)
1687                   (node-list (Info-build-toc curr-file)))          (goto-char (point-min))
1688               (erase-buffer)          (insert "\n\^_\nFile: toc Node: Top, Up: (dir)\n\n")
1689               (goto-char (point-min))          (insert "Table of Contents\n*****************\n\n")
1690               (insert "Node: Contents\n\n")          (insert "*Note Top::\n")
1691               (insert "Table of Contents\n*****************\n\n")          (Info-insert-toc
1692               (insert "*Note Top::\n")           (nth 2 (assoc "Top" node-list)) ; get Top nodes
1693               (Info-insert-toc           node-list 0 (substring-no-properties curr-file)))
1694                (nth 2 (assoc "Top" node-list)) ; get Top nodes        (if (not (bobp))
1695                node-list 0)            (let ((Info-hide-note-references 'hide)
1696               (or (eq major-mode 'Info-mode) (Info-mode))                  (Info-fontify-visited-nodes nil))
1697               (setq Info-current-file curr-file)              (Info-mode)
1698               (setq Info-current-node "Contents")              (setq Info-current-file "toc" Info-current-node "Top")
1699               (Info-set-mode-line)))              (Info-fontify-node)))
1700         (if (not (bobp))        (goto-char (point-min))
1701             (let ((Info-hide-note-references 'hide))        (if (setq p (search-forward (concat "*Note " curr-node ":") nil t))
1702               (Info-fontify-node)))            (setq p (- p (length curr-node) 2))))
1703         (goto-char (point-min))      (Info-find-node "toc" "Top")
        (if (setq p (search-forward (concat "*Note " curr-node "::") nil t))  
            (setq p (- p (length curr-node) 2)))  
        (current-buffer)))  
1704      (goto-char (or p (point-min)))))      (goto-char (or p (point-min)))))
1705    
1706  (defun Info-insert-toc (nodes node-list level)  (defun Info-insert-toc (nodes node-list level curr-file)
1707    "Insert table of contents with references to nodes."    "Insert table of contents with references to nodes."
1708    (let ((section "Top"))    (let ((section "Top"))
1709      (while nodes      (while nodes
# Line 1692  If SAME-FILE is non-nil, do not move to Line 1711  If SAME-FILE is non-nil, do not move to
1711          (unless (member (nth 1 node) (list nil section))          (unless (member (nth 1 node) (list nil section))
1712            (insert (setq section (nth 1 node)) "\n"))            (insert (setq section (nth 1 node)) "\n"))
1713          (insert (make-string level ?\t))          (insert (make-string level ?\t))
1714          (insert "*Note " (car nodes) "::\n")          (insert "*Note " (car nodes) ": (" curr-file ")" (car nodes) ".\n")
1715          (Info-insert-toc (nth 2 node) node-list (1+ level))          (Info-insert-toc (nth 2 node) node-list (1+ level) curr-file)
1716          (setq nodes (cdr nodes))))))          (setq nodes (cdr nodes))))))
1717    
1718  (defun Info-build-toc (file)  (defun Info-build-toc (file)
# Line 1701  If SAME-FILE is non-nil, do not move to Line 1720  If SAME-FILE is non-nil, do not move to
1720    (if (equal file "dir")    (if (equal file "dir")
1721        (error "Table of contents for Info directory is not supported yet"))        (error "Table of contents for Info directory is not supported yet"))
1722    (with-temp-buffer    (with-temp-buffer
1723      (let ((default-directory (or (and (stringp file)      (let* ((default-directory (or (and (stringp file)
1724                                        (file-name-directory                                         (file-name-directory
1725                                         (setq file (Info-find-file file))))                                          (setq file (Info-find-file file))))
1726                                   default-directory))                                    default-directory))
1727            (sections '(("Top" "Top")))             (main-file file)
1728            nodes subfiles)             (sections '(("Top" "Top")))
1729        (while (or file subfiles)             nodes subfiles)
1730          (or file (message "Searching subfile %s..." (car subfiles)))        (while (or main-file subfiles)
1731            (or main-file (message "Searching subfile %s..." (car subfiles)))
1732          (erase-buffer)          (erase-buffer)
1733          (info-insert-file-contents (or file (car subfiles)))          (info-insert-file-contents (or main-file (car subfiles)))
1734            (goto-char (point-min))
1735          (while (and (search-forward "\n\^_\nFile:" nil 'move)          (while (and (search-forward "\n\^_\nFile:" nil 'move)
1736                      (search-forward "Node: " nil 'move))                      (search-forward "Node: " nil 'move))
1737            (let ((nodename (substring-no-properties (Info-following-node-name)))            (let ((nodename (substring-no-properties (Info-following-node-name)))
# Line 1718  If SAME-FILE is non-nil, do not move to Line 1739  If SAME-FILE is non-nil, do not move to
1739                                (point-max)) 2))                                (point-max)) 2))
1740                  (section "Top")                  (section "Top")
1741                  menu-items)                  menu-items)
1742              (when (and (not (string-match "\\<index\\>" nodename))              (when (and (not (Info-index-node nodename file))
1743                         (re-search-forward "^\\* Menu:" bound t))                         (re-search-forward "^\\* Menu:" bound t))
1744                (forward-line 1)                (forward-line 1)
1745                (beginning-of-line)                (beginning-of-line)
# Line 1750  If SAME-FILE is non-nil, do not move to Line 1771  If SAME-FILE is non-nil, do not move to
1771                                      (nreverse menu-items))                                      (nreverse menu-items))
1772                                nodes))                                nodes))
1773              (goto-char bound)))              (goto-char bound)))
1774          (if file          (if main-file
1775              (save-excursion              (save-excursion
1776                (goto-char (point-min))                (goto-char (point-min))
1777                (if (search-forward "\n\^_\nIndirect:" nil t)                (if (search-forward "\n\^_\nIndirect:" nil t)
# Line 1759  If SAME-FILE is non-nil, do not move to Line 1780  If SAME-FILE is non-nil, do not move to
1780                        (setq subfiles (cons (match-string-no-properties 1)                        (setq subfiles (cons (match-string-no-properties 1)
1781                                             subfiles)))))                                             subfiles)))))
1782                (setq subfiles (nreverse subfiles)                (setq subfiles (nreverse subfiles)
1783                      file nil))                      main-file nil))
1784            (setq subfiles (cdr subfiles))))            (setq subfiles (cdr subfiles))))
1785        (message "")        (message "")
1786        (nreverse nodes))))        (nreverse nodes))))
# Line 1838  new buffer." Line 1859  new buffer."
1859            (if (and (save-excursion            (if (and (save-excursion
1860                       (goto-char (+ (point) 5)) ; skip a possible *note                       (goto-char (+ (point) 5)) ; skip a possible *note
1861                       (re-search-backward "\\*note[ \n\t]+" nil t)                       (re-search-backward "\\*note[ \n\t]+" nil t)
1862                       (looking-at (concat "\\*note[ \n\t]+"                       (looking-at str))
                                          (Info-following-node-name-re "^.,\t"))))  
1863                     (<= (point) (match-end 0)))                     (<= (point) (match-end 0)))
1864                (goto-char (match-beginning 0))))                (goto-char (match-beginning 0))))
1865        ;; Go to the reference closest to point        ;; Go to the reference closest to point
# Line 1867  new buffer." Line 1887  new buffer."
1887  Because of ambiguities, this should be concatenated with something like  Because of ambiguities, this should be concatenated with something like
1888  `:' and `Info-following-node-name-re'.")  `:' and `Info-following-node-name-re'.")
1889    
1890  (defun Info-extract-menu-node-name (&optional multi-line)  (defun Info-extract-menu-node-name (&optional multi-line index-node)
1891    (skip-chars-forward " \t\n")    (skip-chars-forward " \t\n")
1892    (when (looking-at (concat Info-menu-entry-name-re ":\\(:\\|"    (when (looking-at (concat Info-menu-entry-name-re ":\\(:\\|"
1893                              (Info-following-node-name-re                              (Info-following-node-name-re
1894                               (if multi-line "^.,\t" "^.,\t\n")) "\\)"))                               (cond
1895                                  (index-node "^,\t\n")
1896                                  (multi-line "^.,\t")
1897                                  (t          "^.,\t\n")))
1898                                "\\)"
1899                                (if index-node
1900                                    "\\.\\(?:[ \t\n]+(line +\\([0-9]+\\))\\)?"
1901                                  "")))
1902        (if index-node
1903            (setq Info-point-loc
1904                  (if (match-beginning 5)
1905                      (string-to-number (match-string 5))
1906                    (buffer-substring (match-beginning 0) (1- (match-beginning 1)))))
1907    ;;; Comment out the next line to use names of cross-references:
1908    ;;;       (setq Info-point-loc
1909    ;;;             (buffer-substring (match-beginning 0) (1- (match-beginning 1))))
1910          )
1911      (replace-regexp-in-string      (replace-regexp-in-string
1912       "[ \n]+" " "       "[ \n]+" " "
1913       (or (match-string 2)       (or (match-string 2)
# Line 1886  Because of ambiguities, this should be c Line 1922  Because of ambiguities, this should be c
1922    
1923  (defvar Info-complete-menu-buffer)  (defvar Info-complete-menu-buffer)
1924  (defvar Info-complete-next-re nil)  (defvar Info-complete-next-re nil)
1925    (defvar Info-complete-nodes nil)
1926  (defvar Info-complete-cache nil)  (defvar Info-complete-cache nil)
1927    
1928  (defconst Info-node-spec-re  (defconst Info-node-spec-re
# Line 1899  Because of ambiguities, this should be c Line 1936  Because of ambiguities, this should be c
1936    ;; - `Info-complete-next-re' which, if non-nil, indicates that we should    ;; - `Info-complete-next-re' which, if non-nil, indicates that we should
1937    ;; also look for menu items in subsequent nodes as long as those    ;; also look for menu items in subsequent nodes as long as those
1938    ;; nodes' names match `Info-complete-next-re'.  This feature is currently    ;; nodes' names match `Info-complete-next-re'.  This feature is currently
1939      ;; not used.
1940      ;; - `Info-complete-nodes' which, if non-nil, indicates that we should
1941      ;; also look for menu items in these nodes.  This feature is currently
1942    ;; only used for completion in Info-index.    ;; only used for completion in Info-index.
1943    
1944    ;; Note that `Info-complete-menu-buffer' could be current already,    ;; Note that `Info-complete-menu-buffer' could be current already,
# Line 1922  Because of ambiguities, this should be c Line 1962  Because of ambiguities, this should be c
1962            (if (and (equal (nth 0 Info-complete-cache) Info-current-file)            (if (and (equal (nth 0 Info-complete-cache) Info-current-file)
1963                     (equal (nth 1 Info-complete-cache) Info-current-node)                     (equal (nth 1 Info-complete-cache) Info-current-node)
1964                     (equal (nth 2 Info-complete-cache) Info-complete-next-re)                     (equal (nth 2 Info-complete-cache) Info-complete-next-re)
1965                       (equal (nth 5 Info-complete-cache) Info-complete-nodes)
1966                     (let ((prev (nth 3 Info-complete-cache)))                     (let ((prev (nth 3 Info-complete-cache)))
1967                       (eq t (compare-strings string 0 (length prev)                       (eq t (compare-strings string 0 (length prev)
1968                                              prev 0 nil t))))                                              prev 0 nil t))))
# Line 1934  Because of ambiguities, this should be c Line 1975  Because of ambiguities, this should be c
1975                      (push (match-string-no-properties 1)                      (push (match-string-no-properties 1)
1976                            completions))                            completions))
1977                    ;; Check subsequent nodes if applicable.                    ;; Check subsequent nodes if applicable.
1978                    (and Info-complete-next-re                    (or (and Info-complete-next-re
1979                         (setq nextnode (Info-extract-pointer "next" t))                             (setq nextnode (Info-extract-pointer "next" t))
1980                         (string-match Info-complete-next-re nextnode)))                             (string-match Info-complete-next-re nextnode))
1981                          (and Info-complete-nodes
1982                               (setq Info-complete-nodes (cdr Info-complete-nodes)
1983                                     nextnode (car Info-complete-nodes)))))
1984                (Info-goto-node nextnode))                (Info-goto-node nextnode))
1985              ;; Go back to the start node (for the next completion).              ;; Go back to the start node (for the next completion).
1986              (unless (equal Info-current-node orignode)              (unless (equal Info-current-node orignode)
# Line 1944  Because of ambiguities, this should be c Line 1988  Because of ambiguities, this should be c
1988              ;; Update the cache.              ;; Update the cache.
1989              (set (make-local-variable 'Info-complete-cache)              (set (make-local-variable 'Info-complete-cache)
1990                   (list Info-current-file Info-current-node                   (list Info-current-file Info-current-node
1991                         Info-complete-next-re string completions)))                         Info-complete-next-re string completions
1992                           Info-complete-nodes)))
1993            (if action            (if action
1994                (all-completions string completions predicate)                (all-completions string completions predicate)
1995              (try-completion string completions predicate)))))))              (try-completion string completions predicate)))))))
# Line 2013  new buffer." Line 2058  new buffer."
2058              (error "No such item in menu"))              (error "No such item in menu"))
2059          (beginning-of-line)          (beginning-of-line)
2060          (forward-char 2)          (forward-char 2)
2061          (Info-extract-menu-node-name)))))          (Info-extract-menu-node-name nil (Info-index-node))))))
2062    
2063  ;; If COUNT is nil, use the last item in the menu.  ;; If COUNT is nil, use the last item in the menu.
2064  (defun Info-extract-menu-counting (count)  (defun Info-extract-menu-counting (count)
# Line 2028  new buffer." Line 2073  new buffer."
2073                  (error "Too few items in menu"))                  (error "Too few items in menu"))
2074            (while (search-forward "\n* " nil t)            (while (search-forward "\n* " nil t)
2075              nil))              nil))
2076          (Info-extract-menu-node-name)))))          (Info-extract-menu-node-name nil (Info-index-node))))))
2077    
2078  (defun Info-nth-menu-item ()  (defun Info-nth-menu-item ()
2079    "Go to the node of the Nth menu item.    "Go to the node of the Nth menu item.
# Line 2055  N is the digit argument used to invoke t Line 2100  N is the digit argument used to invoke t
2100      ;; move forward until we can't go any farther.      ;; move forward until we can't go any farther.
2101      (while (Info-forward-node t t) nil)      (while (Info-forward-node t t) nil)
2102      ;; Then keep moving down to last subnode, unless we reach an index.      ;; Then keep moving down to last subnode, unless we reach an index.
2103      (while (and (not (string-match "\\<index\\>" Info-current-node))      (while (and (not (Info-index-node))
2104                  (save-excursion (search-forward "\n* Menu:" nil t)))                  (save-excursion (search-forward "\n* Menu:" nil t)))
2105        (Info-goto-node (Info-extract-menu-counting nil)))))        (Info-goto-node (Info-extract-menu-counting nil)))))
2106    
# Line 2071  N is the digit argument used to invoke t Line 2116  N is the digit argument used to invoke t
2116      ;;     3. next node is up and next      ;;     3. next node is up and next
2117      (cond ((and (not not-down)      (cond ((and (not not-down)
2118                  (save-excursion (search-forward "\n* menu:" nil t))                  (save-excursion (search-forward "\n* menu:" nil t))
2119                  (not (string-match "\\<index\\>" Info-current-node)))                  (not (Info-index-node)))
2120             (Info-goto-node (Info-extract-menu-counting 1))             (Info-goto-node (Info-extract-menu-counting 1))
2121             t)             t)
2122            ((save-excursion (search-backward "next:" nil t))            ((save-excursion (search-backward "next:" nil t))
# Line 2109  N is the digit argument used to invoke t Line 2154  N is the digit argument used to invoke t
2154             ;; go down to find the last subnode*.             ;; go down to find the last subnode*.
2155             (Info-prev)             (Info-prev)
2156             (let (Info-history)             (let (Info-history)
2157               (while (and (not (string-match "\\<index\\>" Info-current-node))               (while (and (not (Info-index-node))
2158                           (save-excursion (search-forward "\n* Menu:" nil t)))                           (save-excursion (search-forward "\n* Menu:" nil t)))
2159                 (Info-goto-node (Info-extract-menu-counting nil)))))                 (Info-goto-node (Info-extract-menu-counting nil)))))
2160            (t            (t
# Line 2300  parent node." Line 2345  parent node."
2345          (if recur          (if recur
2346              (error "No cross references in this node")              (error "No cross references in this node")
2347            (Info-prev-reference t)))))            (Info-prev-reference t)))))
2348    
2349    (defvar Info-index-nodes nil
2350      "Alist of cached index node names of visited Info files.
2351    Each element has the form (INFO-FILE INDEX-NODE-NAMES-LIST).")
2352    
2353    (defun Info-index-nodes (&optional file)
2354      "Return a list of names of all index nodes in Info FILE.
2355    If FILE is omitted, it defaults to the current Info file.
2356    First look in a list of cached index node names.  Then scan Info
2357    file and its subfiles for nodes with the index cookie.  Then try
2358    to find index nodes starting from the first node in the top level
2359    menu whose name contains the word \"Index\", plus any immediately
2360    following nodes whose names also contain the word \"Index\"."
2361      (or file (setq file Info-current-file))
2362      (or (assoc file Info-index-nodes)
2363          ;; Skip virtual Info files
2364          (and (member file '("dir" "history" "toc" "apropos"))
2365               (setq Info-index-nodes (cons (cons file nil) Info-index-nodes)))
2366          (not (stringp file))
2367          ;; Find nodes with index cookie
2368          (let* ((default-directory (or (and (stringp file)
2369                                             (file-name-directory
2370                                              (setq file (Info-find-file file))))
2371                                        default-directory))
2372                 Info-history Info-history-list Info-fontify-maximum-menu-size
2373                 (main-file file) subfiles nodes node)
2374            (condition-case nil
2375                (with-temp-buffer
2376                  (while (or main-file subfiles)
2377                    (erase-buffer)
2378                    (info-insert-file-contents (or main-file (car subfiles)))
2379                    (goto-char (point-min))
2380                    (while (search-forward "\0\b[index\0\b]" nil 'move)
2381                      (save-excursion
2382                        (re-search-backward "^\^_")
2383                        (search-forward "Node: ")
2384                        (setq nodes (cons (Info-following-node-name) nodes))))
2385                    (if main-file
2386                        (save-excursion
2387                          (goto-char (point-min))
2388                          (if (search-forward "\n\^_\nIndirect:" nil t)
2389                              (let ((bound (save-excursion (search-forward "\n\^_" nil t))))
2390                                (while (re-search-forward "^\\(.*\\): [0-9]+$" bound t)
2391                                  (setq subfiles (cons (match-string-no-properties 1)
2392                                                       subfiles)))))
2393                          (setq subfiles (nreverse subfiles)
2394                                main-file nil))
2395                      (setq subfiles (cdr subfiles)))))
2396              (error nil))
2397            (if nodes
2398                (setq nodes (nreverse nodes)
2399                      Info-index-nodes (cons (cons file nodes) Info-index-nodes)))
2400            nodes)
2401          ;; Find nodes with the word "Index" in the node name
2402          (let ((case-fold-search t)
2403                Info-history Info-history-list Info-fontify-maximum-menu-size
2404                nodes node)
2405            (condition-case nil
2406                (with-temp-buffer
2407                  (Info-mode)
2408                  (Info-find-node file "Top")
2409                  (when (and (search-forward "\n* menu:" nil t)
2410                             (re-search-forward "\n\\* \\(.*\\<Index\\>\\)" nil t))
2411                    (goto-char (match-beginning 1))
2412                    (setq nodes (list (Info-extract-menu-node-name)))
2413                    (Info-goto-node (car nodes))
2414                    (while (and (setq node (Info-extract-pointer "next" t))
2415                                (string-match "\\<Index\\>" node))
2416                      (setq nodes (cons node nodes))
2417                      (Info-goto-node node))))
2418              (error nil))
2419            (if nodes
2420                (setq nodes (nreverse nodes)
2421                      Info-index-nodes (cons (cons file nodes) Info-index-nodes)))
2422            nodes)
2423          ;; If file has no index nodes, still add it to the cache
2424          (setq Info-index-nodes (cons (cons file nil) Info-index-nodes)))
2425      (cdr (assoc file Info-index-nodes)))
2426    
2427    (defun Info-index-node (&optional node file)
2428      "Return non-nil value if NODE is an index node.
2429    If NODE is nil, check the current Info node.
2430    If FILE is nil, check the current Info file."
2431      (if (or (and node (not (equal node Info-current-node)))
2432              (assoc (or file Info-current-file) Info-index-nodes))
2433          (member (or node Info-current-node) (Info-index-nodes file))
2434        ;; Don't search all index nodes if request is only for the current node
2435        ;; and file is not in the cache of index nodes
2436        (or
2437         (save-match-data
2438           (string-match "\\<Index\\>" (or node Info-current-node "")))
2439         (save-excursion
2440           (goto-char (+ (or (save-excursion
2441                               (search-backward "\n\^_" nil t))
2442                             (point-min)) 2))
2443           (search-forward "\0\b[index\0\b]"
2444                           (or (save-excursion
2445                                 (search-forward "\n\^_" nil t))
2446                               (point-max)) t)))))
2447    
2448  (defun Info-goto-index ()  (defun Info-goto-index ()
2449    (Info-goto-node "Top")    "Go to the first index node."
2450    (or (search-forward "\n* menu:" nil t)    (let ((node (car (Info-index-nodes))))
2451        (error "No index"))      (or node (error "No index"))
2452    (or (re-search-forward "\n\\* \\(.*\\<Index\\>\\)" nil t)      (Info-goto-node node)))
       (error "No index"))  
   (goto-char (match-beginning 1))  
   ;; Protect Info-history so that the current node (Top) is not added to it.  
   (let ((Info-history nil))  
     (Info-goto-node (Info-extract-menu-node-name))))  
2453    
2454  ;;;###autoload  ;;;###autoload
2455  (defun Info-index (topic)  (defun Info-index (topic)
2456    "Look up a string TOPIC in the index for this file.    "Look up a string TOPIC in the index for this file.
 The index is defined as the first node in the top level menu whose  
 name contains the word \"Index\", plus any immediately following  
 nodes whose names also contain the word \"Index\".  
2457  If there are no exact matches to the specified topic, this chooses  If there are no exact matches to the specified topic, this chooses
2458  the first match which is a case-insensitive substring of a topic.  the first match which is a case-insensitive substring of a topic.
2459  Use the `,' command to see the other matches.  Use the \\<Info-mode-map>\\[Info-index-next] command to see the other matches.
2460  Give a blank topic name to go to the Index node itself."  Give a blank topic name to go to the Index node itself."
2461    (interactive    (interactive
2462     (list     (list
2463      (let ((Info-complete-menu-buffer (clone-buffer))      (let ((Info-complete-menu-buffer (clone-buffer))
2464            (Info-complete-next-re "\\<Index\\>"))            (Info-complete-nodes (Info-index-nodes))
2465              (Info-history-list nil))
2466        (if (equal Info-current-file "dir")        (if (equal Info-current-file "dir")
2467            (error "The Info directory node has no index; use m to select a manual"))            (error "The Info directory node has no index; use m to select a manual"))
2468        (unwind-protect        (unwind-protect
# Line 2336  Give a blank topic name to go to the Ind Line 2473  Give a blank topic name to go to the Ind
2473    (if (equal Info-current-file "dir")    (if (equal Info-current-file "dir")
2474        (error "The Info directory node has no index; use m to select a manual"))        (error "The Info directory node has no index; use m to select a manual"))
2475    (let ((orignode Info-current-node)    (let ((orignode Info-current-node)
2476          (pattern (format "\n\\* +\\([^\n]*%s[^\n]*\\):[ \t]+\\([^.\n]*\\)\\.[ \t]*\\([0-9]*\\)"          (pattern (format "\n\\* +\\([^\n]*%s[^\n]*\\):[ \t]+\\([^\n]*\\)\\.\\(?:[ \t\n]*(line +\\([0-9]+\\))\\)?"
2477                           (regexp-quote topic)))                           (regexp-quote topic)))
2478          node          node (nodes (Info-index-nodes))
2479            (ohist-list Info-history-list)
2480          (case-fold-search t))          (case-fold-search t))
2481      (Info-goto-index)      (Info-goto-index)
2482      (or (equal topic "")      (or (equal topic "")
# Line 2360  Give a blank topic name to go to the Ind Line 2498  Give a blank topic name to go to the Ind
2498                                (string-to-number (concat "0"                                (string-to-number (concat "0"
2499                                                          (match-string 3))))                                                          (match-string 3))))
2500                          matches))                          matches))
2501                  (and (setq node (Info-extract-pointer "next" t))                  (setq nodes (cdr nodes) node (car nodes)))
                      (string-match "\\<Index\\>" node)))  
2502              (Info-goto-node node))              (Info-goto-node node))
2503            (or matches            (or matches
2504                (progn                (progn
# Line 2371  Give a blank topic name to go to the Ind Line 2508  Give a blank topic name to go to the Ind
2508            (while (setq found (assoc topic matches))            (while (setq found (assoc topic matches))
2509              (setq exact (cons found exact)              (setq exact (cons found exact)
2510                    matches (delq found matches)))                    matches (delq found matches)))
2511              (setq Info-history-list ohist-list)
2512            (setq Info-index-alternatives (nconc exact (nreverse matches)))            (setq Info-index-alternatives (nconc exact (nreverse matches)))
2513            (Info-index-next 0)))))            (Info-index-next 0)))))
2514    
2515  (defun Info-index-next (num)  (defun Info-index-next (num)
2516    "Go to the next matching index item from the last `i' command."    "Go to the next matching index item from the last \\<Info-mode-map>\\[Info-index] command."
2517    (interactive "p")    (interactive "p")
2518    (or Info-index-alternatives    (or Info-index-alternatives
2519        (error "No previous `i' command"))        (error "No previous `i' command"))
# Line 2388  Give a blank topic name to go to the Ind Line 2526  Give a blank topic name to go to the Ind
2526            num (1- num)))            num (1- num)))
2527    (Info-goto-node (nth 1 (car Info-index-alternatives)))    (Info-goto-node (nth 1 (car Info-index-alternatives)))
2528    (if (> (nth 3 (car Info-index-alternatives)) 0)    (if (> (nth 3 (car Info-index-alternatives)) 0)
2529        (forward-line (nth 3 (car Info-index-alternatives)))        (forward-line (1- (nth 3 (car Info-index-alternatives))))
2530      (forward-line 3)                    ; don't search in headers      (forward-line 3)                    ; don't search in headers
2531      (let ((name (car (car Info-index-alternatives))))      (let ((name (car (car Info-index-alternatives))))
2532        (Info-find-index-name name)))        (Info-find-index-name name)))
# Line 2427  Give a blank topic name to go to the Ind Line 2565  Give a blank topic name to go to the Ind
2565  Build a menu of the possible matches."  Build a menu of the possible matches."
2566    (interactive "sIndex apropos: ")    (interactive "sIndex apropos: ")
2567    (unless (string= string "")    (unless (string= string "")
2568      (let ((pattern (format "\n\\* +\\([^\n]*%s[^\n]*\\):[ \t]+\\([^.]+\\)."      (let ((pattern (format "\n\\* +\\([^\n]*%s[^\n]*\\):[ \t]+\\([^\n]+\\)\\.\\(?:[ \t\n]*(line +\\([0-9]+\\))\\)?"
2569                             (regexp-quote string)))                             (regexp-quote string)))
2570            (ohist Info-history)            (ohist Info-history)
2571            (ohist-list Info-history-list)            (ohist-list Info-history-list)
2572            (current-node Info-current-node)            (current-node Info-current-node)
2573            (current-file Info-current-file)            (current-file Info-current-file)
2574            manuals matches temp-file node)            manuals matches node nodes)
2575        (let ((Info-fontify-maximum-menu-size 0)        (let ((Info-fontify-maximum-menu-size nil))
             Info-use-header-lines  
             Info-hide-note-references)  
2576          (Info-directory)          (Info-directory)
2577          (message "Searching indices...")          (message "Searching indices...")
2578          (goto-char (point-min))          (goto-char (point-min))
# Line 2445  Build a menu of the possible matches." Line 2581  Build a menu of the possible matches."
2581            (add-to-list 'manuals (match-string 1)))            (add-to-list 'manuals (match-string 1)))
2582          (dolist (manual manuals)          (dolist (manual manuals)
2583            (message "Searching %s" manual)            (message "Searching %s" manual)
2584            (condition-case nil            (if (setq nodes (Info-index-nodes (Info-find-file manual)))
2585                (save-excursion                (condition-case nil
2586                  (Info-find-node manual "Top")                    (save-excursion
2587                  (when (re-search-forward "\n\\* \\(.*\\<Index\\>\\)" nil t)                      (Info-find-node manual (car nodes))
2588                    (goto-char (match-beginning 1))                      (while
2589                    (Info-goto-node (Info-extract-menu-node-name))                          (progn
2590                    (while                            (goto-char (point-min))
2591                        (progn                            (while (re-search-forward pattern nil t)
2592                          (goto-char (point-min))                              (add-to-list 'matches
2593                          (while (re-search-forward pattern nil t)                                           (list manual
2594                            (add-to-list 'matches                                                 (match-string-no-properties 1)
2595                                         (list (match-string 1)                                                 (match-string-no-properties 2)
2596                                               (match-string 2)                                                 (match-string-no-properties 3))))
2597                                               manual)))                            (setq nodes (cdr nodes) node (car nodes)))
2598                          (and (setq node (Info-extract-pointer "next" t))                        (Info-goto-node node)))
2599                               (string-match "\\<Index\\>" node)))                  (error nil)))))
                     (Info-goto-node node))))  
             (error nil))))  
2600        (Info-goto-node (concat "(" current-file ")" current-node))        (Info-goto-node (concat "(" current-file ")" current-node))
2601        (setq Info-history ohist        (setq Info-history ohist
2602              Info-history-list ohist-list)              Info-history-list ohist-list)
# Line 2471  Build a menu of the possible matches." Line 2605  Build a menu of the possible matches."
2605            (message "No matches found")            (message "No matches found")
2606          (with-current-buffer (get-buffer-create " *info-apropos*")          (with-current-buffer (get-buffer-create " *info-apropos*")
2607            (erase-buffer)            (erase-buffer)
2608            (insert "\n\nFile: apropos, Node: Top, Up: (dir)\n")            (insert "\n\^_\nFile: apropos, Node: Index, Up: (dir)\n")
2609            (insert "* Menu: \nNodes whose indices contain \"" string "\"\n\n")            (insert "* Menu: \nNodes whose indices contain \"" string "\"\n\n")
2610            (dolist (entry matches)            (dolist (entry matches)
2611              (insert "* " (car entry) " [" (nth 2 entry)              (insert
2612                      "]: (" (nth 2 entry) ")" (nth 1 entry) ".\n")))               (format "* %-38s (%s)%s.%s\n"
2613          (Info-find-node "apropos" "top")))))                       (concat (nth 1 entry) " [" (nth 0 entry) "]:")
2614                         (nth 0 entry)
2615                         (nth 2 entry)
2616                         (if (nth 3 entry)
2617                             (concat " (line " (nth 3 entry) ")")
2618                           "")))))
2619            (Info-find-node "apropos" "Index")
2620            (setq Info-complete-cache nil)))))
2621    
2622  (defun Info-undefined ()  (defun Info-undefined ()
2623    "Make command be undefined in Info."    "Make command be undefined in Info."
# Line 2592  if point is in a menu item description, Line 2733  if point is in a menu item description,
2733        (browse-url (browse-url-url-at-point)))        (browse-url (browse-url-url-at-point)))
2734       ((setq node (Info-get-token (point) "\\*note[ \n\t]+"       ((setq node (Info-get-token (point) "\\*note[ \n\t]+"
2735                                   "\\*note[ \n\t]+\\([^:]*\\):\\(:\\|[ \n\t]*(\\)?"))                                   "\\*note[ \n\t]+\\([^:]*\\):\\(:\\|[ \n\t]*(\\)?"))
 ;;;       (or (match-string 2)  
 ;;;           (setq Info-reference-name  
 ;;;                 (replace-regexp-in-string  
 ;;;                  "[ \n\t]+" " " (match-string-no-properties 1))))  
2736        (Info-follow-reference node fork))        (Info-follow-reference node fork))
2737       ;; menu item: node name       ;; menu item: node name
2738       ((setq node (Info-get-token (point) "\\* +" "\\* +\\([^:]*\\)::"))       ((setq node (Info-get-token (point) "\\* +" "\\* +\\([^:]*\\)::"))
2739        (Info-goto-node node fork))        (Info-goto-node node fork))
2740       ;; menu item: index entry       ;; menu item: node name or index entry
2741       ((Info-get-token (point) "\\* +" "\\* +\\(.*\\): ")       ((Info-get-token (point) "\\* +" "\\* +\\(.*\\): ")
       (if (save-match-data (string-match "\\<index\\>" Info-current-node))  
           (setq Info-reference-name (match-string-no-properties 1)))  
2742        (beginning-of-line)        (beginning-of-line)
2743        (forward-char 2)        (forward-char 2)
2744        (setq node (Info-extract-menu-node-name))        (setq node (Info-extract-menu-node-name nil (Info-index-node)))
2745        (Info-goto-node node fork))        (Info-goto-node node fork))
2746       ((setq node (Info-get-token (point) "Up: " "Up: \\([^,\n\t]*\\)"))       ((setq node (Info-get-token (point) "Up: " "Up: \\([^,\n\t]*\\)"))
2747        (Info-goto-node node fork))        (Info-goto-node node fork))
# Line 2654  if point is in a menu item description, Line 2789  if point is in a menu item description,
2789    (define-key Info-mode-map "h" 'Info-help)    (define-key Info-mode-map "h" 'Info-help)
2790    (define-key Info-mode-map "i" 'Info-index)    (define-key Info-mode-map "i" 'Info-index)
2791    (define-key Info-mode-map "l" 'Info-last)    (define-key Info-mode-map "l" 'Info-last)
2792      (define-key Info-mode-map "L" 'Info-history)
2793    (define-key Info-mode-map "m" 'Info-menu)    (define-key Info-mode-map "m" 'Info-menu)
2794    (define-key Info-mode-map "n" 'Info-next)    (define-key Info-mode-map "n" 'Info-next)
2795    (define-key Info-mode-map "p" 'Info-prev)    (define-key Info-mode-map "p" 'Info-prev)
2796    (define-key Info-mode-map "q" 'Info-exit)    (define-key Info-mode-map "q" 'Info-exit)
2797    (define-key Info-mode-map "s" 'Info-search)    (define-key Info-mode-map "s" 'Info-search)
2798      (define-key Info-mode-map "S" 'Info-search-case-sensitively)
2799    ;; For consistency with Rmail.    ;; For consistency with Rmail.
2800    (define-key Info-mode-map "\M-s" 'Info-search)    (define-key Info-mode-map "\M-s" 'Info-search)
2801    (define-key Info-mode-map "\M-n" 'clone-buffer)    (define-key Info-mode-map "\M-n" 'clone-buffer)
2802    (define-key Info-mode-map "t" 'Info-top-node)    (define-key Info-mode-map "t" 'Info-top-node)
2803      (define-key Info-mode-map "T" 'Info-toc)
2804    (define-key Info-mode-map "u" 'Info-up)    (define-key Info-mode-map "u" 'Info-up)
2805      ;; For consistency with dired-copy-filename-as-kill.
2806      (define-key Info-mode-map "w" 'Info-copy-current-node-name)
2807    (define-key Info-mode-map "," 'Info-index-next)    (define-key Info-mode-map "," 'Info-index-next)
2808    (define-key Info-mode-map "\177" 'Info-scroll-down)    (define-key Info-mode-map "\177" 'Info-scroll-down)
2809    (define-key Info-mode-map [mouse-2] 'Info-mouse-follow-nearest-node)    (define-key Info-mode-map [mouse-2] 'Info-mouse-follow-nearest-node)
# Line 2708  if point is in a menu item description, Line 2848  if point is in a menu item description,
2848     ["Last" Info-last :active Info-history     ["Last" Info-last :active Info-history
2849      :help "Go to the last node you were at"]      :help "Go to the last node you were at"]
2850     ["History" Info-history :active Info-history-list     ["History" Info-history :active Info-history-list
2851      :help "Go to the history buffer"]      :help "Go to menu of visited nodes"]
2852     ["Table of Contents" Info-toc     ["Table of Contents" Info-toc
2853      :help "Go to the buffer with a table of contents"]      :help "Go to table of contents"]
2854     ("Index..."     ("Index..."
2855      ["Lookup a String" Info-index      ["Lookup a String" Info-index
2856       :help "Look for a string in the index items"]       :help "Look for a string in the index items"]
# Line 2808  if point is in a menu item description, Line 2948  if point is in a menu item description,
2948      (error (ding))))      (error (ding))))
2949    
2950    
2951  (defun Info-copy-current-node-name ()  (defun Info-copy-current-node-name (&optional arg)
2952    "Put the name of the current info node into the kill ring.    "Put the name of the current info node into the kill ring.
2953  The name of the info file is prepended to the node name in parentheses."  The name of the info file is prepended to the node name in parentheses.
2954    (interactive)  With a zero prefix arg, put the name inside a function call to `info'."
2955      (interactive "P")
2956    (unless Info-current-node    (unless Info-current-node
2957      (error "No current info node"))      (error "No current info node"))
2958    (kill-new    (let ((node (concat "(" (file-name-nondirectory
2959     (concat "("                             (or (and (stringp Info-current-file)
2960             (file-name-nondirectory                                      Info-current-file)
2961              (if (stringp Info-current-file)                                 buffer-file-name
2962                  Info-current-file                                 ""))
2963                (or buffer-file-name "")))                        ")" Info-current-node)))
2964             ")"      (if (zerop (prefix-numeric-value arg))
2965             Info-current-node)))          (setq node (concat "(info \"" node "\")")))
2966        (kill-new node)
2967        (message "%s" node)))
2968    
2969    
2970  ;; Info mode is suitable only for specially formatted data.  ;; Info mode is suitable only for specially formatted data.
# Line 2852  Selecting other nodes: Line 2995  Selecting other nodes:
2995  \\[Info-directory]      Go to the Info directory node.  \\[Info-directory]      Go to the Info directory node.
2996  \\[Info-follow-reference]       Follow a cross reference.  Reads name of reference.  \\[Info-follow-reference]       Follow a cross reference.  Reads name of reference.
2997  \\[Info-last]   Move to the last node you were at.  \\[Info-last]   Move to the last node you were at.
2998  \\[Info-history]        Go to the history buffer.  \\[Info-history]        Go to menu of visited nodes.
2999  \\[Info-toc]    Go to the buffer with a table of contents.  \\[Info-toc]    Go to table of contents of the current Info file.
 \\[Info-index]  Look up a topic in this file's Index and move to that node.  
 \\[Info-index-next]     (comma) Move to the next match from a previous `i' command.  
3000  \\[Info-top-node]       Go to the Top node of this file.  \\[Info-top-node]       Go to the Top node of this file.
3001  \\[Info-final-node]     Go to the final node in this file.  \\[Info-final-node]     Go to the final node in this file.
3002  \\[Info-backward-node]  Go backward one node, considering all nodes as forming one sequence.  \\[Info-backward-node]  Go backward one node, considering all nodes as forming one sequence.
3003  \\[Info-forward-node]   Go forward one node, considering all nodes as forming one sequence.  \\[Info-forward-node]   Go forward one node, considering all nodes as forming one sequence.
3004    \\[Info-index]  Look up a topic in this file's Index and move to that node.
3005    \\[Info-index-next]     (comma) Move to the next match from a previous \\<Info-mode-map>\\[Info-index] command.
3006    \\[info-apropos]        Look for a string in the indices of all manuals.
3007    
3008  Moving within a node:  Moving within a node:
3009  \\[Info-scroll-up]      Normally, scroll forward a full screen.  \\[Info-scroll-up]      Normally, scroll forward a full screen.
# Line 2876  Advanced commands: Line 3020  Advanced commands:
3020  \\[Info-copy-current-node-name] Put name of current info node in the kill ring.  \\[Info-copy-current-node-name] Put name of current info node in the kill ring.
3021  \\[clone-buffer]        Select a new cloned Info buffer in another window.  \\[clone-buffer]        Select a new cloned Info buffer in another window.
3022  \\[Info-edit]   Edit contents of selected node.  \\[Info-edit]   Edit contents of selected node.
3023  1       Pick first item in node's menu.  1 .. 9  Pick first ... ninth item in node's menu.
3024  2, 3, 4, 5   Pick second ... fifth item in node's menu.            Every third `*' is highlighted to help pick the right number.
3025  \\[Info-goto-node]      Move to node specified by name.  \\[Info-goto-node]      Move to node specified by name.
3026            You may include a filename as well, as (FILENAME)NODENAME.            You may include a filename as well, as (FILENAME)NODENAME.
3027  \\[universal-argument] \\[info] Move to new Info file with completion.  \\[universal-argument] \\[info] Move to new Info file with completion.
3028    \\[universal-argument] N \\[info]       Select Info buffer with prefix number in the name *info*<N>.
3029  \\[Info-search] Search through this Info file for specified regexp,  \\[Info-search] Search through this Info file for specified regexp,
3030            and select the node in which the next occurrence is found.            and select the node in which the next occurrence is found.
3031  \\[Info-search-case-sensitively]        Search through this Info file  \\[Info-search-case-sensitively]        Search through this Info file for specified regexp case-sensitively.
           for specified regexp case-sensitively.  
3032  \\[Info-search-next]    Search for another occurrence of regexp  \\[Info-search-next]    Search for another occurrence of regexp
3033            from a previous `Info-search' command.            from a previous \\<Info-mode-map>\\[Info-search] command.
3034  \\[Info-next-reference] Move cursor to next cross-reference or menu item.  \\[Info-next-reference] Move cursor to next cross-reference or menu item.
3035  \\[Info-prev-reference] Move cursor to previous cross-reference or menu item."  \\[Info-prev-reference] Move cursor to previous cross-reference or menu item."
3036    (kill-all-local-variables)    (kill-all-local-variables)
# Line 2916  Advanced commands: Line 3060  Advanced commands:
3060    ;; This is for the sake of the invisible text we use handling titles.    ;; This is for the sake of the invisible text we use handling titles.
3061    (make-local-variable 'line-move-ignore-invisible)    (make-local-variable 'line-move-ignore-invisible)
3062    (setq line-move-ignore-invisible t)    (setq line-move-ignore-invisible t)
3063      (make-local-variable 'desktop-save-buffer)
3064      (setq desktop-save-buffer 'Info-desktop-buffer-misc-data)
3065    (add-hook 'clone-buffer-hook 'Info-clone-buffer-hook nil t)    (add-hook 'clone-buffer-hook 'Info-clone-buffer-hook nil t)
3066    (add-hook 'change-major-mode-hook 'font-lock-defontify nil t)    (add-hook 'change-major-mode-hook 'font-lock-defontify nil t)
3067    (Info-set-mode-line)    (Info-set-mode-line)
# Line 3045  The locations are of the format used in Line 3191  The locations are of the format used in
3191      ;; Bind Info-history to nil, to prevent the index nodes from      ;; Bind Info-history to nil, to prevent the index nodes from
3192      ;; getting into the node history.      ;; getting into the node history.
3193      (let ((Info-history nil)      (let ((Info-history nil)
3194            node)            (Info-history-list nil)
3195        (Info-goto-node (Info-extract-menu-node-name))            node (nodes (Info-index-nodes)))
3196          (Info-goto-node (car nodes))
3197        (while        (while
3198            (progn            (progn
3199              (goto-char (point-min))              (goto-char (point-min))
# Line 3056  The locations are of the format used in Line 3203  The locations are of the format used in
3203                                  (match-string-no-properties 2)                                  (match-string-no-properties 2)
3204                                  0)                                  0)
3205                            where)))                            where)))
3206              (and (setq node (Info-extract-pointer "next" t))              (and (setq nodes (cdr nodes) node (car nodes))))
                  (string-match "\\<Index\\>" node)))  
3207          (Info-goto-node node)))          (Info-goto-node node)))
3208      where))      where))
3209    
# Line 3080  COMMAND must be a symbol or string." Line 3226  COMMAND must be a symbol or string."
3226            ;; Get Info running, and pop to it in another window.            ;; Get Info running, and pop to it in another window.
3227            (save-window-excursion            (save-window-excursion
3228              (info))              (info))
3229            ;; FIXME It would be cool if this could use a buffer other            (or (eq major-mode 'Info-mode) (pop-to-buffer "*info*"))
           ;; than *info*.  
           (pop-to-buffer "*info*")  
3230            ;; Bind Info-history to nil, to prevent the last Index node            ;; Bind Info-history to nil, to prevent the last Index node
3231            ;; visited by Info-find-emacs-command-nodes from being            ;; visited by Info-find-emacs-command-nodes from being
3232            ;; pushed onto the history.            ;; pushed onto the history.
3233            (let ((Info-history nil))            (let ((Info-history nil) (Info-history-list nil))
3234              (Info-find-node (car (car where))              (Info-find-node (car (car where))
3235                              (car (cdr (car where)))))                              (car (cdr (car where)))))
3236            (if (> num-matches 1)            (if (> num-matches 1)
# Line 3122  the variable `Info-file-list-for-emacs'. Line 3266  the variable `Info-file-list-for-emacs'.
3266             (Info-goto-emacs-command-node command)))))             (Info-goto-emacs-command-node command)))))
3267    
3268  (defface Info-title-1-face  (defface Info-title-1-face
3269    '((((type tty pc) (class color)) (:foreground "yellow" :weight bold))    '((((type tty pc) (class color)) :foreground "yellow" :weight bold)
3270      (t (:height 1.2 :inherit Info-title-2-face)))      (t :height 1.2 :inherit Info-title-2-face))
3271    "Face for Info titles at level 1."    "Face for Info titles at level 1."
3272    :group 'info)    :group 'info)
3273    
3274  (defface Info-title-2-face  (defface Info-title-2-face
3275    '((((type tty pc) (class color)) (:foreground "lightblue" :weight bold))    '((((type tty pc) (class color)) :foreground "lightblue" :weight bold)
3276      (t (:height 1.2 :inherit Info-title-3-face)))      (t :height 1.2 :inherit Info-title-3-face))
3277    "Face for Info titles at level 2."    "Face for Info titles at level 2."
3278    :group 'info)    :group 'info)
3279    
3280  (defface Info-title-3-face  (defface Info-title-3-face
3281    '((((type tty pc) (class color)) (:weight bold))    '((((type tty pc) (class color)) :weight bold)
3282      (t (:height 1.2 :inherit Info-title-4-face)))      (t :height 1.2 :inherit Info-title-4-face))
3283    "Face for Info titles at level 3."    "Face for Info titles at level 3."
3284    :group 'info)    :group 'info)
3285    
3286  (defface Info-title-4-face  (defface Info-title-4-face
3287    '((((type tty pc) (class color)) (:weight bold))    '((((type tty pc) (class color)) :weight bold)
3288      (t (:weight bold :inherit variable-pitch)))      (t :weight bold :inherit variable-pitch))
3289    "Face for Info titles at level 4."    "Face for Info titles at level 4."
3290    :group 'info)    :group 'info)
3291    
# Line 3360  Preserve text properties." Line 3504  Preserve text properties."
3504                                    (hl Info-history-list)                                    (hl Info-history-list)
3505                                    res)                                    res)
3506                               (if (string-match "(\\([^)]+\\))\\([^)]*\\)" node)                               (if (string-match "(\\([^)]+\\))\\([^)]*\\)" node)
3507                                   (setq file (match-string 1 node)                                   (setq file (file-name-nondirectory
3508                                                 (match-string 1 node))
3509                                         node (if (equal (match-string 2 node) "")                                         node (if (equal (match-string 2 node) "")
3510                                                  "Top"                                                  "Top"
3511                                                (match-string 2 node))))                                                (match-string 2 node))))
# Line 3377  Preserve text properties." Line 3522  Preserve text properties."
3522                  (add-text-properties (match-beginning 3) (match-end 3)                  (add-text-properties (match-beginning 3) (match-end 3)
3523                                       '(invisible t front-sticky nil rear-nonsticky t))                                       '(invisible t front-sticky nil rear-nonsticky t))
3524                  ;; Unhide the file name of the external reference in parens                  ;; Unhide the file name of the external reference in parens
3525                  (if (match-string 6)                  (if (and (match-string 6) (not (eq Info-hide-note-references 'hide)))
3526                      (remove-text-properties (match-beginning 6) (match-end 6)                      (remove-text-properties (match-beginning 6) (match-end 6)
3527                                              '(invisible t front-sticky nil rear-nonsticky t)))                                              '(invisible t front-sticky nil rear-nonsticky t)))
3528                  ;; Unhide newline because hidden newlines cause too long lines                  ;; Unhide newline because hidden newlines cause too long lines
3529                  (save-match-data                  (save-match-data
3530                    (let ((start3 (match-beginning 3)))                    (let ((beg3 (match-beginning 3))
3531                      (if (string-match "\n[ \t]*" (match-string 3))                          (end3 (match-end 3)))
3532                          (remove-text-properties (+ start3 (match-beginning 0)) (+ start3 (match-end 0))                      (if (and (string-match "\n[ \t]*" (match-string 3))
3533                                 (not (save-match-data
3534                                        (save-excursion
3535                                          (goto-char (1+ end3))
3536                                          (looking-at "[.)]*$")))))
3537                            (remove-text-properties (+ beg3 (match-beginning 0))
3538                                                    (+ beg3 (match-end 0))
3539                                                  '(invisible t front-sticky nil rear-nonsticky t))))))                                                  '(invisible t front-sticky nil rear-nonsticky t))))))
3540                (when (and Info-refill-paragraphs Info-hide-note-references)                (when (and Info-refill-paragraphs Info-hide-note-references)
3541                  (push (set-marker (make-marker) start)                  (push (set-marker (make-marker) start)
# Line 3416  Preserve text properties." Line 3567  Preserve text properties."
3567        (goto-char (point-min))        (goto-char (point-min))
3568        (when (and (or not-fontified-p fontify-visited-p)        (when (and (or not-fontified-p fontify-visited-p)
3569                   (search-forward "\n* Menu:" nil t)                   (search-forward "\n* Menu:" nil t)
3570                   (not (string-match "\\<Index\\>" Info-current-node))                   (not (Info-index-node))
3571                   ;; Don't take time to annotate huge menus                   ;; Don't take time to annotate huge menus
3572                   (< (- (point-max) (point)) Info-fontify-maximum-menu-size))                   (< (- (point-max) (point)) Info-fontify-maximum-menu-size))
3573          (let ((n 0)          (let ((n 0)
# Line 3454  Preserve text properties." Line 3605  Preserve text properties."
3605                                   (hl Info-history-list)                                   (hl Info-history-list)
3606                                   res)                                   res)
3607                               (if (string-match "(\\([^)]+\\))\\([^)]*\\)" node)                               (if (string-match "(\\([^)]+\\))\\([^)]*\\)" node)
3608                                   (setq file (match-string 1 node)                                   (setq file (file-name-nondirectory
3609                                                 (match-string 1 node))
3610                                         node (if (equal (match-string 2 node) "")                                         node (if (equal (match-string 2 node) "")
3611                                                  "Top"                                                  "Top"
3612                                                (match-string 2 node))))                                                (match-string 2 node))))
# Line 3502  Preserve text properties." Line 3654  Preserve text properties."
3654            (put-text-property (match-beginning 1) (match-end 1)            (put-text-property (match-beginning 1) (match-end 1)
3655                               'font-lock-face 'info-menu-header)))                               'font-lock-face 'info-menu-header)))
3656    
3657          ;; Hide index line numbers
3658          (goto-char (point-min))
3659          (when (and not-fontified-p (Info-index-node))
3660            (while (re-search-forward "[ \t\n]*(line +[0-9]+)" nil t)
3661              (put-text-property (match-beginning 0) (match-end 0)
3662                                 'invisible t)))
3663    
3664        ;; Fontify http and ftp references        ;; Fontify http and ftp references
3665        (goto-char (point-min))        (goto-char (point-min))
3666        (when not-fontified-p        (when not-fontified-p
# Line 3713  BUFFER is the buffer speedbar is request Line 3872  BUFFER is the buffer speedbar is request
3872                  "^No \".*\" in index$"))                  "^No \".*\" in index$"))
3873    (add-to-list 'debug-ignored-errors mess))    (add-to-list 'debug-ignored-errors mess))
3874    
3875    ;;;;  Desktop support
3876    
3877    (defun Info-desktop-buffer-misc-data (desktop-dirname)
3878      "Auxiliary information to be saved in desktop file."
3879      (if (not (member Info-current-file '("apropos" "history" "toc")))
3880          (list Info-current-file Info-current-node)))
3881    
3882    ;;;###autoload
3883    (defun Info-restore-desktop-buffer (desktop-buffer-file-name
3884                                        desktop-buffer-name
3885                                        desktop-buffer-misc)
3886      "Restore an info buffer specified in a desktop file."
3887      (let ((first (nth 0 desktop-buffer-misc))
3888            (second (nth 1 desktop-buffer-misc)))
3889      (when (and first second)
3890        (when desktop-buffer-name
3891          (set-buffer (get-buffer-create desktop-buffer-name))
3892          (Info-mode))
3893        (Info-find-node first second)
3894        (current-buffer))))
3895    
3896  (provide 'info)  (provide 'info)
3897    
3898  ;;; arch-tag: f2480fe2-2139-40c1-a49b-6314991164ac  ;;; arch-tag: f2480fe2-2139-40c1-a49b-6314991164ac

Legend:
Removed from v.1.367.2.1  
changed lines
  Added in v.1.367.2.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26