comparison lisp/info.el @ 55074:dd4c270b21af

Restore 2004-04-18 changes.
author Juri Linkov <juri@jurta.org>
date Wed, 21 Apr 2004 22:23:25 +0000
parents 966081800217
children b8934c440dd6
comparison
equal deleted inserted replaced
55073:dacc27f37199 55074:dd4c270b21af
478 ;; following the parenthesized filename. 478 ;; following the parenthesized filename.
479 (if (and (stringp file) (string-match "(.*)" file)) 479 (if (and (stringp file) (string-match "(.*)" file))
480 (Info-goto-node file) 480 (Info-goto-node file)
481 (Info-goto-node (concat "(" file ")"))) 481 (Info-goto-node (concat "(" file ")")))
482 (if (zerop (buffer-size)) 482 (if (zerop (buffer-size))
483 (Info-directory)))) 483 (Info-directory))))
484 484
485 ;;;###autoload 485 ;;;###autoload
486 (defun info-emacs-manual () 486 (defun info-emacs-manual ()
487 "Display the Emacs manual in Info mode." 487 "Display the Emacs manual in Info mode."
488 (interactive) 488 (interactive)
533 ;; Convert filename to lower case if not found as specified. 533 ;; Convert filename to lower case if not found as specified.
534 ;; Expand it. 534 ;; Expand it.
535 (if (stringp filename) 535 (if (stringp filename)
536 (let (temp temp-downcase found) 536 (let (temp temp-downcase found)
537 (setq filename (substitute-in-file-name filename)) 537 (setq filename (substitute-in-file-name filename))
538 (cond 538 (cond
539 ((string= (downcase filename) "dir") 539 ((string= (downcase filename) "dir")
540 (setq found t)) 540 (setq found t))
541 ((string= filename "apropos") 541 ((string= filename "apropos")
542 (setq found 'apropos)) 542 (setq found 'apropos))
543 ((string= filename "history")
544 (setq found 'history))
545 ((string= filename "toc")
546 (setq found 'toc))
543 (t 547 (t
544 (let ((dirs (if (string-match "^\\./" filename) 548 (let ((dirs (if (string-match "^\\./" filename)
545 ;; If specified name starts with `./' 549 ;; If specified name starts with `./'
546 ;; then just try current directory. 550 ;; then just try current directory.
547 '("./") 551 '("./")
740 (cond 744 (cond
741 ((eq filename t) 745 ((eq filename t)
742 (Info-insert-dir)) 746 (Info-insert-dir))
743 ((eq filename 'apropos) 747 ((eq filename 'apropos)
744 (insert-buffer-substring " *info-apropos*")) 748 (insert-buffer-substring " *info-apropos*"))
749 ((eq filename 'history)
750 (insert-buffer-substring " *info-history*"))
751 ((eq filename 'toc)
752 (insert-buffer-substring " *info-toc*"))
745 (t 753 (t
746 (info-insert-file-contents filename nil) 754 (info-insert-file-contents filename nil)
747 (setq default-directory (file-name-directory filename)))) 755 (setq default-directory (file-name-directory filename))))
748 (set-buffer-modified-p nil) 756 (set-buffer-modified-p nil)
749 ;; See whether file has a tag table. Record the location if yes. 757 ;; See whether file has a tag table. Record the location if yes.
780 (set-marker Info-tag-table-marker nil)) 788 (set-marker Info-tag-table-marker nil))
781 (setq Info-current-file 789 (setq Info-current-file
782 (cond 790 (cond
783 ((eq filename t) "dir") 791 ((eq filename t) "dir")
784 ((eq filename 'apropos) "apropos") 792 ((eq filename 'apropos) "apropos")
793 ((eq filename 'history) "history")
794 ((eq filename 'toc) "toc")
785 (t filename))) 795 (t filename)))
786 )) 796 ))
787 ;; Use string-equal, not equal, to ignore text props. 797 ;; Use string-equal, not equal, to ignore text props.
788 (if (string-equal nodename "*") 798 (if (string-equal nodename "*")
789 (progn (setq Info-current-node nodename) 799 (progn (setq Info-current-node nodename)
841 ;; buffer begins with a node. 851 ;; buffer begins with a node.
842 (let ((pos (Info-find-node-in-buffer regexp))) 852 (let ((pos (Info-find-node-in-buffer regexp)))
843 (when pos 853 (when pos
844 (goto-char pos) 854 (goto-char pos)
845 (throw 'foo t)) 855 (throw 'foo t))
846 (error "No such anchor in tag table or node in tag table or file: %s" 856 ;; No such anchor in tag table or node in tag table or file
847 nodename))) 857 (error "No such node or anchor: %s" nodename)))
848 858
849 (Info-select-node) 859 (Info-select-node)
850 (goto-char (point-min)) 860 (goto-char (point-min))
851 (cond (anchorpos 861 (cond (anchorpos
852 (let ((new-history (list Info-current-file 862 (let ((new-history (list Info-current-file
980 (while (and (zerop (forward-line 1)) (eolp))) 990 (while (and (zerop (forward-line 1)) (eolp)))
981 (let ((beg (point)) 991 (let ((beg (point))
982 nodename end) 992 nodename end)
983 (re-search-backward "^\^_") 993 (re-search-backward "^\^_")
984 (search-forward "Node: ") 994 (search-forward "Node: ")
985 (setq nodename 995 (setq nodename (Info-following-node-name))
986 (and (looking-at (Info-following-node-name-re))
987 (match-string 1)))
988 (search-forward "\n\^_" nil 'move) 996 (search-forward "\n\^_" nil 'move)
989 (beginning-of-line) 997 (beginning-of-line)
990 (setq end (point)) 998 (setq end (point))
991 (push (list nodename other beg end) this-buffer-nodes))) 999 (push (list nodename other beg end) this-buffer-nodes)))
992 (if (assoc-string "top" this-buffer-nodes t) 1000 (if (assoc-string "top" this-buffer-nodes t)
1296 (interactive (list (Info-read-node-name "Go to node: ") current-prefix-arg)) 1304 (interactive (list (Info-read-node-name "Go to node: ") current-prefix-arg))
1297 (info-initialize) 1305 (info-initialize)
1298 (if fork 1306 (if fork
1299 (set-buffer 1307 (set-buffer
1300 (clone-buffer (concat "*info-" (if (stringp fork) fork nodename) "*") t))) 1308 (clone-buffer (concat "*info-" (if (stringp fork) fork nodename) "*") t)))
1301 (if (member (buffer-name) '("*info-history*" "*info-toc*"))
1302 (switch-to-buffer "*info*"))
1303 (let (filename) 1309 (let (filename)
1304 (string-match "\\s *\\((\\s *\\([^\t)]*\\)\\s *)\\s *\\|\\)\\(.*\\)" 1310 (string-match "\\s *\\((\\s *\\([^\t)]*\\)\\s *)\\s *\\|\\)\\(.*\\)"
1305 nodename) 1311 nodename)
1306 (setq filename (if (= (match-beginning 1) (match-end 1)) 1312 (setq filename (if (= (match-beginning 1) (match-end 1))
1307 "" 1313 ""
1614 (defun Info-directory () 1620 (defun Info-directory ()
1615 "Go to the Info directory node." 1621 "Go to the Info directory node."
1616 (interactive) 1622 (interactive)
1617 (Info-find-node "dir" "top")) 1623 (Info-find-node "dir" "top"))
1618 1624
1619 ;;;###autoload (add-hook 'same-window-buffer-names "*info-history*")
1620
1621 (defun Info-history () 1625 (defun Info-history ()
1622 "Create the buffer *info-history* with a menu of visited nodes." 1626 "Go to a node with a menu of visited nodes."
1623 (interactive) 1627 (interactive)
1624 (let ((curr-file Info-current-file) 1628 (let ((curr-file Info-current-file)
1625 (curr-node Info-current-node) 1629 (curr-node Info-current-node)
1626 p) 1630 p)
1627 (pop-to-buffer 1631 (with-current-buffer (get-buffer-create " *info-history*")
1628 (with-current-buffer (get-buffer-create "*info-history*") 1632 (let ((inhibit-read-only t))
1629 (let ((inhibit-read-only t)) 1633 (erase-buffer)
1630 (erase-buffer) 1634 (goto-char (point-min))
1631 (goto-char (point-min)) 1635 (insert "\n\nFile: history Node: Top, Up: (dir)\n\n")
1632 (insert "Node: History\n\n") 1636 (insert "Recently Visited Nodes\n**********************\n\n")
1633 (insert "Recently Visited Nodes\n**********************\n\n") 1637 (insert "* Menu:\n\n")
1634 (insert "* Menu:\n\n") 1638 (let ((hl (delete '("history" "Top") Info-history-list)))
1635 (let ((hl Info-history-list)) 1639 (while hl
1636 (while hl 1640 (let ((file (nth 0 (car hl)))
1637 (let ((file (nth 0 (car hl))) 1641 (node (nth 1 (car hl))))
1638 (node (nth 1 (car hl)))) 1642 (if (and (string-equal file curr-file)
1639 (if (and (string-equal file curr-file) 1643 (string-equal node curr-node))
1640 (string-equal node curr-node)) 1644 (setq p (point)))
1641 (setq p (point))) 1645 (insert "* " node ": (" (file-name-nondirectory file)
1642 (insert "* " node ": (" (file-name-nondirectory file) 1646 ")" node ".\n"))
1643 ")" node ".\n")) 1647 (setq hl (cdr hl))))))
1644 (setq hl (cdr hl)))) 1648 (Info-find-node "history" "Top")
1645 (or (eq major-mode 'Info-mode) (Info-mode))
1646 (setq Info-current-file "info-history")
1647 (setq Info-current-node "Info History")
1648 (Info-set-mode-line)
1649 (if (not (bobp)) (Info-fontify-node))
1650 (current-buffer))))
1651 (goto-char (or p (point-min))))) 1649 (goto-char (or p (point-min)))))
1652 1650
1653 ;;;###autoload (add-hook 'same-window-buffer-names "*info-toc*")
1654
1655 (defun Info-toc () 1651 (defun Info-toc ()
1656 "Create the buffer *info-toc* with Info file's table of contents." 1652 "Go to a node with table of contents of the current Info file."
1657 (interactive) 1653 (interactive)
1658 (let ((curr-file Info-current-file) 1654 (let ((curr-file Info-current-file)
1659 (curr-node Info-current-node) 1655 (curr-node Info-current-node)
1660 p) 1656 p)
1661 (pop-to-buffer 1657 (with-current-buffer (get-buffer-create " *info-toc*")
1662 (with-current-buffer (get-buffer-create "*info-toc*") 1658 (let ((inhibit-read-only t)
1663 (if (not (equal Info-current-file curr-file)) 1659 (node-list (Info-build-toc curr-file)))
1664 (let ((inhibit-read-only t) 1660 (erase-buffer)
1665 (node-list (Info-build-toc curr-file))) 1661 (goto-char (point-min))
1666 (erase-buffer) 1662 (insert "\n\nFile: toc Node: Top, Up: (dir)\n\n")
1667 (goto-char (point-min)) 1663 (insert "Table of Contents\n*****************\n\n")
1668 (insert "Node: Contents\n\n") 1664 (insert "*Note Top::\n")
1669 (insert "Table of Contents\n*****************\n\n") 1665 (Info-insert-toc
1670 (insert "*Note Top::\n") 1666 (nth 2 (assoc "Top" node-list)) ; get Top nodes
1671 (Info-insert-toc 1667 node-list 0 (file-name-nondirectory curr-file)))
1672 (nth 2 (assoc "Top" node-list)) ; get Top nodes 1668 (if (not (bobp))
1673 node-list 0) 1669 (let ((Info-hide-note-references 'hide)
1674 (or (eq major-mode 'Info-mode) (Info-mode)) 1670 (Info-fontify-visited-nodes nil))
1675 (setq Info-current-file curr-file) 1671 (Info-fontify-node)))
1676 (setq Info-current-node "Contents") 1672 (goto-char (point-min))
1677 (Info-set-mode-line))) 1673 (if (setq p (search-forward (concat "*Note " curr-node ":") nil t))
1678 (if (not (bobp)) 1674 (setq p (- p (length curr-node) 2))))
1679 (let ((Info-hide-note-references 'hide)) 1675 (Info-find-node "toc" "Top")
1680 (Info-fontify-node)))
1681 (goto-char (point-min))
1682 (if (setq p (search-forward (concat "*Note " curr-node "::") nil t))
1683 (setq p (- p (length curr-node) 2)))
1684 (current-buffer)))
1685 (goto-char (or p (point-min))))) 1676 (goto-char (or p (point-min)))))
1686 1677
1687 (defun Info-insert-toc (nodes node-list level) 1678 (defun Info-insert-toc (nodes node-list level curr-file)
1688 "Insert table of contents with references to nodes." 1679 "Insert table of contents with references to nodes."
1689 (let ((section "Top")) 1680 (let ((section "Top"))
1690 (while nodes 1681 (while nodes
1691 (let ((node (assoc (car nodes) node-list))) 1682 (let ((node (assoc (car nodes) node-list)))
1692 (unless (member (nth 1 node) (list nil section)) 1683 (unless (member (nth 1 node) (list nil section))
1693 (insert (setq section (nth 1 node)) "\n")) 1684 (insert (setq section (nth 1 node)) "\n"))
1694 (insert (make-string level ?\t)) 1685 (insert (make-string level ?\t))
1695 (insert "*Note " (car nodes) "::\n") 1686 (insert "*Note " (car nodes) ": (" curr-file ")" (car nodes) ".\n")
1696 (Info-insert-toc (nth 2 node) node-list (1+ level)) 1687 (Info-insert-toc (nth 2 node) node-list (1+ level) curr-file)
1697 (setq nodes (cdr nodes)))))) 1688 (setq nodes (cdr nodes))))))
1698 1689
1699 (defun Info-build-toc (file) 1690 (defun Info-build-toc (file)
1700 "Build table of contents from menus of Info FILE and its subfiles." 1691 "Build table of contents from menus of Info FILE and its subfiles."
1701 (if (equal file "dir") 1692 (if (equal file "dir")
2318 The index is defined as the first node in the top level menu whose 2309 The index is defined as the first node in the top level menu whose
2319 name contains the word \"Index\", plus any immediately following 2310 name contains the word \"Index\", plus any immediately following
2320 nodes whose names also contain the word \"Index\". 2311 nodes whose names also contain the word \"Index\".
2321 If there are no exact matches to the specified topic, this chooses 2312 If there are no exact matches to the specified topic, this chooses
2322 the first match which is a case-insensitive substring of a topic. 2313 the first match which is a case-insensitive substring of a topic.
2323 Use the `,' command to see the other matches. 2314 Use the \\<Info-mode-map>\\[Info-index-next] command to see the other matches.
2324 Give a blank topic name to go to the Index node itself." 2315 Give a blank topic name to go to the Index node itself."
2325 (interactive 2316 (interactive
2326 (list 2317 (list
2327 (let ((Info-complete-menu-buffer (clone-buffer)) 2318 (let ((Info-complete-menu-buffer (clone-buffer))
2328 (Info-complete-next-re "\\<Index\\>")) 2319 (Info-complete-next-re "\\<Index\\>"))
2373 matches (delq found matches))) 2364 matches (delq found matches)))
2374 (setq Info-index-alternatives (nconc exact (nreverse matches))) 2365 (setq Info-index-alternatives (nconc exact (nreverse matches)))
2375 (Info-index-next 0))))) 2366 (Info-index-next 0)))))
2376 2367
2377 (defun Info-index-next (num) 2368 (defun Info-index-next (num)
2378 "Go to the next matching index item from the last `i' command." 2369 "Go to the next matching index item from the last \\<Info-mode-map>\\[Info-index] command."
2379 (interactive "p") 2370 (interactive "p")
2380 (or Info-index-alternatives 2371 (or Info-index-alternatives
2381 (error "No previous `i' command")) 2372 (error "No previous `i' command"))
2382 (while (< num 0) 2373 (while (< num 0)
2383 (setq num (+ num (length Info-index-alternatives)))) 2374 (setq num (+ num (length Info-index-alternatives))))
2431 (regexp-quote string))) 2422 (regexp-quote string)))
2432 (ohist Info-history) 2423 (ohist Info-history)
2433 (ohist-list Info-history-list) 2424 (ohist-list Info-history-list)
2434 (current-node Info-current-node) 2425 (current-node Info-current-node)
2435 (current-file Info-current-file) 2426 (current-file Info-current-file)
2436 manuals matches temp-file node) 2427 manuals matches node)
2437 (let ((Info-fontify-maximum-menu-size 0) 2428 (let ((Info-fontify-maximum-menu-size 0)
2438 Info-use-header-lines 2429 Info-use-header-lines
2439 Info-hide-note-references) 2430 Info-hide-note-references)
2440 (Info-directory) 2431 (Info-directory)
2441 (message "Searching indices...") 2432 (message "Searching indices...")
2853 \\[Info-follow-reference] Follow a cross reference. Reads name of reference. 2844 \\[Info-follow-reference] Follow a cross reference. Reads name of reference.
2854 \\[Info-last] Move to the last node you were at. 2845 \\[Info-last] Move to the last node you were at.
2855 \\[Info-history] Go to the history buffer. 2846 \\[Info-history] Go to the history buffer.
2856 \\[Info-toc] Go to the buffer with a table of contents. 2847 \\[Info-toc] Go to the buffer with a table of contents.
2857 \\[Info-index] Look up a topic in this file's Index and move to that node. 2848 \\[Info-index] Look up a topic in this file's Index and move to that node.
2858 \\[Info-index-next] (comma) Move to the next match from a previous `i' command. 2849 \\[Info-index-next] (comma) Move to the next match from a previous \\<Info-mode-map>\\[Info-index] command.
2859 \\[Info-top-node] Go to the Top node of this file. 2850 \\[Info-top-node] Go to the Top node of this file.
2860 \\[Info-final-node] Go to the final node in this file. 2851 \\[Info-final-node] Go to the final node in this file.
2861 \\[Info-backward-node] Go backward one node, considering all nodes as forming one sequence. 2852 \\[Info-backward-node] Go backward one node, considering all nodes as forming one sequence.
2862 \\[Info-forward-node] Go forward one node, considering all nodes as forming one sequence. 2853 \\[Info-forward-node] Go forward one node, considering all nodes as forming one sequence.
2863 2854
2884 \\[Info-search] Search through this Info file for specified regexp, 2875 \\[Info-search] Search through this Info file for specified regexp,
2885 and select the node in which the next occurrence is found. 2876 and select the node in which the next occurrence is found.
2886 \\[Info-search-case-sensitively] Search through this Info file 2877 \\[Info-search-case-sensitively] Search through this Info file
2887 for specified regexp case-sensitively. 2878 for specified regexp case-sensitively.
2888 \\[Info-search-next] Search for another occurrence of regexp 2879 \\[Info-search-next] Search for another occurrence of regexp
2889 from a previous `Info-search' command. 2880 from a previous \\<Info-mode-map>\\[Info-search] command.
2890 \\[Info-next-reference] Move cursor to next cross-reference or menu item. 2881 \\[Info-next-reference] Move cursor to next cross-reference or menu item.
2891 \\[Info-prev-reference] Move cursor to previous cross-reference or menu item." 2882 \\[Info-prev-reference] Move cursor to previous cross-reference or menu item."
2892 (kill-all-local-variables) 2883 (kill-all-local-variables)
2893 (setq major-mode 'Info-mode) 2884 (setq major-mode 'Info-mode)
2894 (setq mode-name "Info") 2885 (setq mode-name "Info")
3080 (if where 3071 (if where
3081 (let ((num-matches (length where))) 3072 (let ((num-matches (length where)))
3082 ;; Get Info running, and pop to it in another window. 3073 ;; Get Info running, and pop to it in another window.
3083 (save-window-excursion 3074 (save-window-excursion
3084 (info)) 3075 (info))
3085 ;; FIXME It would be cool if this could use a buffer other 3076 (or (eq major-mode 'Info-mode) (pop-to-buffer "*info*"))
3086 ;; than *info*.
3087 (pop-to-buffer "*info*")
3088 ;; Bind Info-history to nil, to prevent the last Index node 3077 ;; Bind Info-history to nil, to prevent the last Index node
3089 ;; visited by Info-find-emacs-command-nodes from being 3078 ;; visited by Info-find-emacs-command-nodes from being
3090 ;; pushed onto the history. 3079 ;; pushed onto the history.
3091 (let ((Info-history nil)) 3080 (let ((Info-history nil))
3092 (Info-find-node (car (car where)) 3081 (Info-find-node (car (car where))
3377 (when not-fontified-p 3366 (when not-fontified-p
3378 (when (memq Info-hide-note-references '(t hide)) 3367 (when (memq Info-hide-note-references '(t hide))
3379 (add-text-properties (match-beginning 3) (match-end 3) 3368 (add-text-properties (match-beginning 3) (match-end 3)
3380 '(invisible t front-sticky nil rear-nonsticky t)) 3369 '(invisible t front-sticky nil rear-nonsticky t))
3381 ;; Unhide the file name of the external reference in parens 3370 ;; Unhide the file name of the external reference in parens
3382 (if (match-string 6) 3371 (if (and (match-string 6) (not (eq Info-hide-note-references 'hide)))
3383 (remove-text-properties (match-beginning 6) (match-end 6) 3372 (remove-text-properties (match-beginning 6) (match-end 6)
3384 '(invisible t front-sticky nil rear-nonsticky t))) 3373 '(invisible t front-sticky nil rear-nonsticky t)))
3385 ;; Unhide newline because hidden newlines cause too long lines 3374 ;; Unhide newline because hidden newlines cause too long lines
3386 (save-match-data 3375 (save-match-data
3387 (let ((start3 (match-beginning 3))) 3376 (let ((beg3 (match-beginning 3))
3388 (if (string-match "\n[ \t]*" (match-string 3)) 3377 (end3 (match-end 3)))
3389 (remove-text-properties (+ start3 (match-beginning 0)) (+ start3 (match-end 0)) 3378 (if (and (string-match "\n[ \t]*" (match-string 3))
3379 (not (save-match-data
3380 (save-excursion
3381 (goto-char (1+ end3))
3382 (looking-at "[.)]*$")))))
3383 (remove-text-properties (+ beg3 (match-beginning 0))
3384 (+ beg3 (match-end 0))
3390 '(invisible t front-sticky nil rear-nonsticky t)))))) 3385 '(invisible t front-sticky nil rear-nonsticky t))))))
3391 (when (and Info-refill-paragraphs Info-hide-note-references) 3386 (when (and Info-refill-paragraphs Info-hide-note-references)
3392 (push (set-marker (make-marker) start) 3387 (push (set-marker (make-marker) start)
3393 paragraph-markers)))))) 3388 paragraph-markers))))))
3394 3389