aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/info.el171
1 files changed, 98 insertions, 73 deletions
diff --git a/lisp/info.el b/lisp/info.el
index 5fd9af31202..dd78e86cb3a 100644
--- a/lisp/info.el
+++ b/lisp/info.el
@@ -480,7 +480,7 @@ in all the directories in that path."
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 ()
@@ -535,15 +535,11 @@ just return nil (no error)."
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))
547 (t 543 (t
548 (let ((dirs (if (string-match "^\\./" filename) 544 (let ((dirs (if (string-match "^\\./" filename)
549 ;; If specified name starts with `./' 545 ;; If specified name starts with `./'
@@ -746,10 +742,6 @@ a case-insensitive match is tried."
746 (Info-insert-dir)) 742 (Info-insert-dir))
747 ((eq filename 'apropos) 743 ((eq filename 'apropos)
748 (insert-buffer-substring " *info-apropos*")) 744 (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*"))
753 (t 745 (t
754 (info-insert-file-contents filename nil) 746 (info-insert-file-contents filename nil)
755 (setq default-directory (file-name-directory filename)))) 747 (setq default-directory (file-name-directory filename))))
@@ -790,8 +782,6 @@ a case-insensitive match is tried."
790 (cond 782 (cond
791 ((eq filename t) "dir") 783 ((eq filename t) "dir")
792 ((eq filename 'apropos) "apropos") 784 ((eq filename 'apropos) "apropos")
793 ((eq filename 'history) "history")
794 ((eq filename 'toc) "toc")
795 (t filename))) 785 (t filename)))
796 )) 786 ))
797 ;; Use string-equal, not equal, to ignore text props. 787 ;; Use string-equal, not equal, to ignore text props.
@@ -853,8 +843,8 @@ a case-insensitive match is tried."
853 (when pos 843 (when pos
854 (goto-char pos) 844 (goto-char pos)
855 (throw 'foo t)) 845 (throw 'foo t))
856 ;; No such anchor in tag table or node in tag table or file 846 (error "No such anchor in tag table or node in tag table or file: %s"
857 (error "No such node or anchor: %s" nodename))) 847 nodename)))
858 848
859 (Info-select-node) 849 (Info-select-node)
860 (goto-char (point-min)) 850 (goto-char (point-min))
@@ -992,7 +982,9 @@ a case-insensitive match is tried."
992 nodename end) 982 nodename end)
993 (re-search-backward "^\^_") 983 (re-search-backward "^\^_")
994 (search-forward "Node: ") 984 (search-forward "Node: ")
995 (setq nodename (Info-following-node-name)) 985 (setq nodename
986 (and (looking-at (Info-following-node-name-re))
987 (match-string 1)))
996 (search-forward "\n\^_" nil 'move) 988 (search-forward "\n\^_" nil 'move)
997 (beginning-of-line) 989 (beginning-of-line)
998 (setq end (point)) 990 (setq end (point))
@@ -1306,6 +1298,8 @@ If FORK is a string, it is the name to use for the new buffer."
1306 (if fork 1298 (if fork
1307 (set-buffer 1299 (set-buffer
1308 (clone-buffer (concat "*info-" (if (stringp fork) fork nodename) "*") t))) 1300 (clone-buffer (concat "*info-" (if (stringp fork) fork nodename) "*") t)))
1301 (if (member (buffer-name) '("*info-history*" "*info-toc*"))
1302 (switch-to-buffer "*info*"))
1309 (let (filename) 1303 (let (filename)
1310 (string-match "\\s *\\((\\s *\\([^\t)]*\\)\\s *)\\s *\\|\\)\\(.*\\)" 1304 (string-match "\\s *\\((\\s *\\([^\t)]*\\)\\s *)\\s *\\|\\)\\(.*\\)"
1311 nodename) 1305 nodename)
@@ -1622,60 +1616,75 @@ If SAME-FILE is non-nil, do not move to a different Info file."
1622 (interactive) 1616 (interactive)
1623 (Info-find-node "dir" "top")) 1617 (Info-find-node "dir" "top"))
1624 1618
1619;;;###autoload (add-hook 'same-window-buffer-names "*info-history*")
1620
1625(defun Info-history () 1621(defun Info-history ()
1626 "Go to a node with a menu of visited nodes." 1622 "Create the buffer *info-history* with a menu of visited nodes."
1627 (interactive) 1623 (interactive)
1628 (let ((curr-file Info-current-file) 1624 (let ((curr-file Info-current-file)
1629 (curr-node Info-current-node) 1625 (curr-node Info-current-node)
1630 p) 1626 p)
1631 (with-current-buffer (get-buffer-create " *info-history*") 1627 (pop-to-buffer
1632 (let ((inhibit-read-only t)) 1628 (with-current-buffer (get-buffer-create "*info-history*")
1633 (erase-buffer) 1629 (let ((inhibit-read-only t))
1634 (goto-char (point-min)) 1630 (erase-buffer)
1635 (insert "\n\nFile: history Node: Top, Up: (dir)\n\n") 1631 (goto-char (point-min))
1636 (insert "Recently Visited Nodes\n**********************\n\n") 1632 (insert "Node: History\n\n")
1637 (insert "* Menu:\n\n") 1633 (insert "Recently Visited Nodes\n**********************\n\n")
1638 (let ((hl (delete '("history" "Top") Info-history-list))) 1634 (insert "* Menu:\n\n")
1639 (while hl 1635 (let ((hl Info-history-list))
1640 (let ((file (nth 0 (car hl))) 1636 (while hl
1641 (node (nth 1 (car hl)))) 1637 (let ((file (nth 0 (car hl)))
1642 (if (and (string-equal file curr-file) 1638 (node (nth 1 (car hl))))
1643 (string-equal node curr-node)) 1639 (if (and (string-equal file curr-file)
1644 (setq p (point))) 1640 (string-equal node curr-node))
1645 (insert "* " node ": (" (file-name-nondirectory file) 1641 (setq p (point)))
1646 ")" node ".\n")) 1642 (insert "* " node ": (" (file-name-nondirectory file)
1647 (setq hl (cdr hl)))))) 1643 ")" node ".\n"))
1648 (Info-find-node "history" "Top") 1644 (setq hl (cdr hl))))
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))))
1649 (goto-char (or p (point-min))))) 1651 (goto-char (or p (point-min)))))
1650 1652
1653;;;###autoload (add-hook 'same-window-buffer-names "*info-toc*")
1654
1651(defun Info-toc () 1655(defun Info-toc ()
1652 "Go to a node with table of contents of the current Info file." 1656 "Create the buffer *info-toc* with Info file's table of contents."
1653 (interactive) 1657 (interactive)
1654 (let ((curr-file Info-current-file) 1658 (let ((curr-file Info-current-file)
1655 (curr-node Info-current-node) 1659 (curr-node Info-current-node)
1656 p) 1660 p)
1657 (with-current-buffer (get-buffer-create " *info-toc*") 1661 (pop-to-buffer
1658 (let ((inhibit-read-only t) 1662 (with-current-buffer (get-buffer-create "*info-toc*")
1659 (node-list (Info-build-toc curr-file))) 1663 (if (not (equal Info-current-file curr-file))
1660 (erase-buffer) 1664 (let ((inhibit-read-only t)
1661 (goto-char (point-min)) 1665 (node-list (Info-build-toc curr-file)))
1662 (insert "\n\nFile: toc Node: Top, Up: (dir)\n\n") 1666 (erase-buffer)
1663 (insert "Table of Contents\n*****************\n\n") 1667 (goto-char (point-min))
1664 (insert "*Note Top::\n") 1668 (insert "Node: Contents\n\n")
1665 (Info-insert-toc 1669 (insert "Table of Contents\n*****************\n\n")
1666 (nth 2 (assoc "Top" node-list)) ; get Top nodes 1670 (insert "*Note Top::\n")
1667 node-list 0 (file-name-nondirectory curr-file))) 1671 (Info-insert-toc
1668 (if (not (bobp)) 1672 (nth 2 (assoc "Top" node-list)) ; get Top nodes
1669 (let ((Info-hide-note-references 'hide) 1673 node-list 0)
1670 (Info-fontify-visited-nodes nil)) 1674 (or (eq major-mode 'Info-mode) (Info-mode))
1671 (Info-fontify-node))) 1675 (setq Info-current-file curr-file)
1672 (goto-char (point-min)) 1676 (setq Info-current-node "Contents")
1673 (if (setq p (search-forward (concat "*Note " curr-node ":") nil t)) 1677 (Info-set-mode-line)))
1674 (setq p (- p (length curr-node) 2)))) 1678 (if (not (bobp))
1675 (Info-find-node "toc" "Top") 1679 (let ((Info-hide-note-references 'hide))
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)))
1676 (goto-char (or p (point-min))))) 1685 (goto-char (or p (point-min)))))
1677 1686
1678(defun Info-insert-toc (nodes node-list level curr-file) 1687(defun Info-insert-toc (nodes node-list level)
1679 "Insert table of contents with references to nodes." 1688 "Insert table of contents with references to nodes."
1680 (let ((section "Top")) 1689 (let ((section "Top"))
1681 (while nodes 1690 (while nodes
@@ -1683,8 +1692,8 @@ If SAME-FILE is non-nil, do not move to a different Info file."
1683 (unless (member (nth 1 node) (list nil section)) 1692 (unless (member (nth 1 node) (list nil section))
1684 (insert (setq section (nth 1 node)) "\n")) 1693 (insert (setq section (nth 1 node)) "\n"))
1685 (insert (make-string level ?\t)) 1694 (insert (make-string level ?\t))
1686 (insert "*Note " (car nodes) ": (" curr-file ")" (car nodes) ".\n") 1695 (insert "*Note " (car nodes) "::\n")
1687 (Info-insert-toc (nth 2 node) node-list (1+ level) curr-file) 1696 (Info-insert-toc (nth 2 node) node-list (1+ level))
1688 (setq nodes (cdr nodes)))))) 1697 (setq nodes (cdr nodes))))))
1689 1698
1690(defun Info-build-toc (file) 1699(defun Info-build-toc (file)
@@ -2311,7 +2320,7 @@ name contains the word \"Index\", plus any immediately following
2311nodes whose names also contain the word \"Index\". 2320nodes whose names also contain the word \"Index\".
2312If there are no exact matches to the specified topic, this chooses 2321If there are no exact matches to the specified topic, this chooses
2313the first match which is a case-insensitive substring of a topic. 2322the first match which is a case-insensitive substring of a topic.
2314Use the \\<Info-mode-map>\\[Info-index-next] command to see the other matches. 2323Use the `,' command to see the other matches.
2315Give a blank topic name to go to the Index node itself." 2324Give a blank topic name to go to the Index node itself."
2316 (interactive 2325 (interactive
2317 (list 2326 (list
@@ -2366,7 +2375,7 @@ Give a blank topic name to go to the Index node itself."
2366 (Info-index-next 0))))) 2375 (Info-index-next 0)))))
2367 2376
2368(defun Info-index-next (num) 2377(defun Info-index-next (num)
2369 "Go to the next matching index item from the last \\<Info-mode-map>\\[Info-index] command." 2378 "Go to the next matching index item from the last `i' command."
2370 (interactive "p") 2379 (interactive "p")
2371 (or Info-index-alternatives 2380 (or Info-index-alternatives
2372 (error "No previous `i' command")) 2381 (error "No previous `i' command"))
@@ -2424,7 +2433,7 @@ Build a menu of the possible matches."
2424 (ohist-list Info-history-list) 2433 (ohist-list Info-history-list)
2425 (current-node Info-current-node) 2434 (current-node Info-current-node)
2426 (current-file Info-current-file) 2435 (current-file Info-current-file)
2427 manuals matches node) 2436 manuals matches temp-file node)
2428 (let ((Info-fontify-maximum-menu-size 0) 2437 (let ((Info-fontify-maximum-menu-size 0)
2429 Info-use-header-lines 2438 Info-use-header-lines
2430 Info-hide-note-references) 2439 Info-hide-note-references)
@@ -2846,7 +2855,7 @@ Selecting other nodes:
2846\\[Info-history] Go to the history buffer. 2855\\[Info-history] Go to the history buffer.
2847\\[Info-toc] Go to the buffer with a table of contents. 2856\\[Info-toc] Go to the buffer with a table of contents.
2848\\[Info-index] Look up a topic in this file's Index and move to that node. 2857\\[Info-index] Look up a topic in this file's Index and move to that node.
2849\\[Info-index-next] (comma) Move to the next match from a previous \\<Info-mode-map>\\[Info-index] command. 2858\\[Info-index-next] (comma) Move to the next match from a previous `i' command.
2850\\[Info-top-node] Go to the Top node of this file. 2859\\[Info-top-node] Go to the Top node of this file.
2851\\[Info-final-node] Go to the final node in this file. 2860\\[Info-final-node] Go to the final node in this file.
2852\\[Info-backward-node] Go backward one node, considering all nodes as forming one sequence. 2861\\[Info-backward-node] Go backward one node, considering all nodes as forming one sequence.
@@ -2877,7 +2886,7 @@ Advanced commands:
2877\\[Info-search-case-sensitively] Search through this Info file 2886\\[Info-search-case-sensitively] Search through this Info file
2878 for specified regexp case-sensitively. 2887 for specified regexp case-sensitively.
2879\\[Info-search-next] Search for another occurrence of regexp 2888\\[Info-search-next] Search for another occurrence of regexp
2880 from a previous \\<Info-mode-map>\\[Info-search] command. 2889 from a previous `Info-search' command.
2881\\[Info-next-reference] Move cursor to next cross-reference or menu item. 2890\\[Info-next-reference] Move cursor to next cross-reference or menu item.
2882\\[Info-prev-reference] Move cursor to previous cross-reference or menu item." 2891\\[Info-prev-reference] Move cursor to previous cross-reference or menu item."
2883 (kill-all-local-variables) 2892 (kill-all-local-variables)
@@ -2907,6 +2916,8 @@ Advanced commands:
2907 ;; This is for the sake of the invisible text we use handling titles. 2916 ;; This is for the sake of the invisible text we use handling titles.
2908 (make-local-variable 'line-move-ignore-invisible) 2917 (make-local-variable 'line-move-ignore-invisible)
2909 (setq line-move-ignore-invisible t) 2918 (setq line-move-ignore-invisible t)
2919 (make-local-variable 'desktop-buffer-misc-data-function)
2920 (setq desktop-buffer-misc-data-function 'Info-desktop-buffer-misc-data)
2910 (add-hook 'clone-buffer-hook 'Info-clone-buffer-hook nil t) 2921 (add-hook 'clone-buffer-hook 'Info-clone-buffer-hook nil t)
2911 (add-hook 'change-major-mode-hook 'font-lock-defontify nil t) 2922 (add-hook 'change-major-mode-hook 'font-lock-defontify nil t)
2912 (Info-set-mode-line) 2923 (Info-set-mode-line)
@@ -3071,7 +3082,9 @@ COMMAND must be a symbol or string."
3071 ;; Get Info running, and pop to it in another window. 3082 ;; Get Info running, and pop to it in another window.
3072 (save-window-excursion 3083 (save-window-excursion
3073 (info)) 3084 (info))
3074 (or (eq major-mode 'Info-mode) (pop-to-buffer "*info*")) 3085 ;; FIXME It would be cool if this could use a buffer other
3086 ;; than *info*.
3087 (pop-to-buffer "*info*")
3075 ;; Bind Info-history to nil, to prevent the last Index node 3088 ;; Bind Info-history to nil, to prevent the last Index node
3076 ;; visited by Info-find-emacs-command-nodes from being 3089 ;; visited by Info-find-emacs-command-nodes from being
3077 ;; pushed onto the history. 3090 ;; pushed onto the history.
@@ -3366,20 +3379,14 @@ Preserve text properties."
3366 (add-text-properties (match-beginning 3) (match-end 3) 3379 (add-text-properties (match-beginning 3) (match-end 3)
3367 '(invisible t front-sticky nil rear-nonsticky t)) 3380 '(invisible t front-sticky nil rear-nonsticky t))
3368 ;; Unhide the file name of the external reference in parens 3381 ;; Unhide the file name of the external reference in parens
3369 (if (and (match-string 6) (not (eq Info-hide-note-references 'hide))) 3382 (if (match-string 6)
3370 (remove-text-properties (match-beginning 6) (match-end 6) 3383 (remove-text-properties (match-beginning 6) (match-end 6)
3371 '(invisible t front-sticky nil rear-nonsticky t))) 3384 '(invisible t front-sticky nil rear-nonsticky t)))
3372 ;; Unhide newline because hidden newlines cause too long lines 3385 ;; Unhide newline because hidden newlines cause too long lines
3373 (save-match-data 3386 (save-match-data
3374 (let ((beg3 (match-beginning 3)) 3387 (let ((start3 (match-beginning 3)))
3375 (end3 (match-end 3))) 3388 (if (string-match "\n[ \t]*" (match-string 3))
3376 (if (and (string-match "\n[ \t]*" (match-string 3)) 3389 (remove-text-properties (+ start3 (match-beginning 0)) (+ start3 (match-end 0))
3377 (not (save-match-data
3378 (save-excursion
3379 (goto-char (1+ end3))
3380 (looking-at "[.)]*$")))))
3381 (remove-text-properties (+ beg3 (match-beginning 0))
3382 (+ beg3 (match-end 0))
3383 '(invisible t front-sticky nil rear-nonsticky t)))))) 3390 '(invisible t front-sticky nil rear-nonsticky t))))))
3384 (when (and Info-refill-paragraphs Info-hide-note-references) 3391 (when (and Info-refill-paragraphs Info-hide-note-references)
3385 (push (set-marker (make-marker) start) 3392 (push (set-marker (make-marker) start)
@@ -3708,6 +3715,24 @@ BUFFER is the buffer speedbar is requesting buttons for."
3708 "^No \".*\" in index$")) 3715 "^No \".*\" in index$"))
3709 (add-to-list 'debug-ignored-errors mess)) 3716 (add-to-list 'debug-ignored-errors mess))
3710 3717
3718;;;; Desktop support
3719
3720(defun Info-desktop-buffer-misc-data (desktop-dirname)
3721 "Auxiliary information to be saved in desktop file."
3722 (list Info-current-file Info-current-node))
3723
3724;;;###autoload
3725(defun Info-restore-desktop-buffer (desktop-buffer-file-name
3726 desktop-buffer-name
3727 desktop-buffer-misc)
3728 "Restore an info buffer specified in a desktop file."
3729 (let ((first (nth 0 desktop-buffer-misc))
3730 (second (nth 1 desktop-buffer-misc)))
3731 (when (and first second)
3732 (with-no-warnings
3733 (Info-find-node first second))
3734 (current-buffer))))
3735
3711(provide 'info) 3736(provide 'info)
3712 3737
3713;;; arch-tag: f2480fe2-2139-40c1-a49b-6314991164ac 3738;;; arch-tag: f2480fe2-2139-40c1-a49b-6314991164ac