aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2008-06-15 18:18:16 +0000
committerJuri Linkov2008-06-15 18:18:16 +0000
commit586f928490060f89e56c1db84e0eb660dda4db25 (patch)
tree6773435dd3ddc3ed3db955334031797cc088323e
parentd8ac123e392b87317aee5f56dc9244e1f780ca63 (diff)
downloademacs-586f928490060f89e56c1db84e0eb660dda4db25.tar.gz
emacs-586f928490060f89e56c1db84e0eb660dda4db25.zip
(Info-toc): Call Info-toc-nodes instead of Info-build-toc.
(Info-toc, Info-insert-toc): Increment nth's index to add PARENT as the second element. (Info-build-toc): Add PARENT element extracted from the Up pointer. Don't print progress messages. (Info-toc-nodes): New variable and function. (Info-index-nodes): Optimize non-string file name case. (Info-breadcrumbs-depth): Increment the default value from 3 to 4. (Info-insert-breadcrumbs): Use the cached document structure instead of visiting all ancestor nodes. Remove the initial `>'.
-rw-r--r--lisp/ChangeLog13
-rw-r--r--lisp/info.el141
2 files changed, 97 insertions, 57 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 6f7b1ce01b2..023a12b7b5f 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,16 @@
12008-06-15 Juri Linkov <juri@jurta.org>
2
3 * info.el (Info-toc): Call Info-toc-nodes instead of Info-build-toc.
4 (Info-toc, Info-insert-toc): Increment nth's index to add PARENT
5 as the second element.
6 (Info-build-toc): Add PARENT element extracted from the Up pointer.
7 Don't print progress messages.
8 (Info-toc-nodes): New variable and function.
9 (Info-index-nodes): Optimize non-string file name case.
10 (Info-breadcrumbs-depth): Increment the default value from 3 to 4.
11 (Info-insert-breadcrumbs): Use the cached document structure instead
12 of visiting all ancestor nodes. Remove the initial `>'.
13
12008-06-15 Dan Nicolaescu <dann@ics.uci.edu> 142008-06-15 Dan Nicolaescu <dann@ics.uci.edu>
2 15
3 * log-view.el (log-view-diff-changeset): New function. 16 * log-view.el (log-view-diff-changeset): New function.
diff --git a/lisp/info.el b/lisp/info.el
index fcdee4b660f..82ece8dadbd 100644
--- a/lisp/info.el
+++ b/lisp/info.el
@@ -1991,14 +1991,14 @@ Table of contents is created from the tree structure of menus."
1991 p) 1991 p)
1992 (with-current-buffer (get-buffer-create " *info-toc*") 1992 (with-current-buffer (get-buffer-create " *info-toc*")
1993 (let ((inhibit-read-only t) 1993 (let ((inhibit-read-only t)
1994 (node-list (Info-build-toc curr-file))) 1994 (node-list (Info-toc-nodes curr-file)))
1995 (erase-buffer) 1995 (erase-buffer)
1996 (goto-char (point-min)) 1996 (goto-char (point-min))
1997 (insert "\n\^_\nFile: toc, Node: Top, Up: (dir)\n\n") 1997 (insert "\n\^_\nFile: toc, Node: Top, Up: (dir)\n\n")
1998 (insert "Table of Contents\n*****************\n\n") 1998 (insert "Table of Contents\n*****************\n\n")
1999 (insert "*Note Top: (" curr-file ")Top.\n") 1999 (insert "*Note Top: (" curr-file ")Top.\n")
2000 (Info-insert-toc 2000 (Info-insert-toc
2001 (nth 2 (assoc "Top" node-list)) ; get Top nodes 2001 (nth 3 (assoc "Top" node-list)) ; get Top nodes
2002 node-list 0 curr-file)) 2002 node-list 0 curr-file))
2003 (if (not (bobp)) 2003 (if (not (bobp))
2004 (let ((Info-hide-note-references 'hide) 2004 (let ((Info-hide-note-references 'hide)
@@ -2022,11 +2022,11 @@ Table of contents is created from the tree structure of menus."
2022 (let ((section "Top")) 2022 (let ((section "Top"))
2023 (while nodes 2023 (while nodes
2024 (let ((node (assoc (car nodes) node-list))) 2024 (let ((node (assoc (car nodes) node-list)))
2025 (unless (member (nth 1 node) (list nil section)) 2025 (unless (member (nth 2 node) (list nil section))
2026 (insert (setq section (nth 1 node)) "\n")) 2026 (insert (setq section (nth 2 node)) "\n"))
2027 (insert (make-string level ?\t)) 2027 (insert (make-string level ?\t))
2028 (insert "*Note " (car nodes) ": (" curr-file ")" (car nodes) ".\n") 2028 (insert "*Note " (car nodes) ": (" curr-file ")" (car nodes) ".\n")
2029 (Info-insert-toc (nth 2 node) node-list (1+ level) curr-file) 2029 (Info-insert-toc (nth 3 node) node-list (1+ level) curr-file)
2030 (setq nodes (cdr nodes)))))) 2030 (setq nodes (cdr nodes))))))
2031 2031
2032(defun Info-build-toc (file) 2032(defun Info-build-toc (file)
@@ -2040,17 +2040,22 @@ Table of contents is created from the tree structure of menus."
2040 (sections '(("Top" "Top"))) 2040 (sections '(("Top" "Top")))
2041 nodes subfiles) 2041 nodes subfiles)
2042 (while (or main-file subfiles) 2042 (while (or main-file subfiles)
2043 (or main-file (message "Searching subfile %s..." (car subfiles))) 2043 ;; (or main-file (message "Searching subfile %s..." (car subfiles)))
2044 (erase-buffer) 2044 (erase-buffer)
2045 (info-insert-file-contents (or main-file (car subfiles))) 2045 (info-insert-file-contents (or main-file (car subfiles)))
2046 (goto-char (point-min)) 2046 (goto-char (point-min))
2047 (while (and (search-forward "\n\^_\nFile:" nil 'move) 2047 (while (and (search-forward "\n\^_\nFile:" nil 'move)
2048 (search-forward "Node: " nil 'move)) 2048 (search-forward "Node: " nil 'move))
2049 (let ((nodename (substring-no-properties (Info-following-node-name))) 2049 (let* ((nodename (substring-no-properties (Info-following-node-name)))
2050 (bound (- (or (save-excursion (search-forward "\n\^_" nil t)) 2050 (bound (- (or (save-excursion (search-forward "\n\^_" nil t))
2051 (point-max)) 2)) 2051 (point-max)) 2))
2052 (section "Top") 2052 (upnode (and (re-search-forward
2053 menu-items) 2053 (concat "Up:" (Info-following-node-name-re))
2054 bound t)
2055 (match-string-no-properties 1)))
2056 (section "Top")
2057 menu-items)
2058 (when (string-match "(" upnode) (setq upnode nil))
2054 (when (and (not (Info-index-node nodename file)) 2059 (when (and (not (Info-index-node nodename file))
2055 (re-search-forward "^\\* Menu:" bound t)) 2060 (re-search-forward "^\\* Menu:" bound t))
2056 (forward-line 1) 2061 (forward-line 1)
@@ -2078,7 +2083,7 @@ Table of contents is created from the tree structure of menus."
2078 (setq section (match-string-no-properties 1)))) 2083 (setq section (match-string-no-properties 1))))
2079 (forward-line 1) 2084 (forward-line 1)
2080 (beginning-of-line))) 2085 (beginning-of-line)))
2081 (setq nodes (cons (list nodename 2086 (setq nodes (cons (list nodename upnode
2082 (cadr (assoc nodename sections)) 2087 (cadr (assoc nodename sections))
2083 (nreverse menu-items)) 2088 (nreverse menu-items))
2084 nodes)) 2089 nodes))
@@ -2096,6 +2101,32 @@ Table of contents is created from the tree structure of menus."
2096 (setq subfiles (cdr subfiles)))) 2101 (setq subfiles (cdr subfiles))))
2097 (message "") 2102 (message "")
2098 (nreverse nodes)))) 2103 (nreverse nodes))))
2104
2105(defvar Info-toc-nodes nil
2106 "Alist of cached parent-children node information in visited Info files.
2107Each element is (FILE (NODE-NAME PARENT SECTION CHILDREN) ...)
2108where PARENT is the parent node extracted from the Up pointer,
2109SECTION is the section name in the Top node where this node is placed,
2110CHILDREN is a list of child nodes extracted from the node menu.")
2111
2112(defun Info-toc-nodes (file)
2113 "Return a node list of Info FILE with parent-children information.
2114This information is cached in the variable `Info-toc-nodes' with the help
2115of the function `Info-build-toc'."
2116 (or file (setq file Info-current-file))
2117 (or (assoc file Info-toc-nodes)
2118 ;; Skip virtual Info files
2119 (and (or (not (stringp file))
2120 (member file '("dir" apropos history toc)))
2121 (push (cons file nil) Info-toc-nodes))
2122 ;; Scan the entire manual and cache the result in Info-toc-nodes
2123 (let ((nodes (Info-build-toc file)))
2124 (push (cons file nodes) Info-toc-nodes)
2125 nodes)
2126 ;; If there is an error, still add nil to the cache
2127 (push (cons file nil) Info-toc-nodes))
2128 (cdr (assoc file Info-toc-nodes)))
2129
2099 2130
2100(defun Info-follow-reference (footnotename &optional fork) 2131(defun Info-follow-reference (footnotename &optional fork)
2101 "Follow cross reference named FOOTNOTENAME to the node it refers to. 2132 "Follow cross reference named FOOTNOTENAME to the node it refers to.
@@ -2700,9 +2731,9 @@ following nodes whose names also contain the word \"Index\"."
2700 (or file (setq file Info-current-file)) 2731 (or file (setq file Info-current-file))
2701 (or (assoc file Info-index-nodes) 2732 (or (assoc file Info-index-nodes)
2702 ;; Skip virtual Info files 2733 ;; Skip virtual Info files
2703 (and (member file '("dir" apropos history toc)) 2734 (and (or (not (stringp file))
2735 (member file '("dir" apropos history toc)))
2704 (setq Info-index-nodes (cons (cons file nil) Info-index-nodes))) 2736 (setq Info-index-nodes (cons (cons file nil) Info-index-nodes)))
2705 (not (stringp file))
2706 (if Info-file-supports-index-cookies 2737 (if Info-file-supports-index-cookies
2707 ;; Find nodes with index cookie 2738 ;; Find nodes with index cookie
2708 (let* ((default-directory (or (and (stringp file) 2739 (let* ((default-directory (or (and (stringp file)
@@ -3710,55 +3741,51 @@ the variable `Info-file-list-for-emacs'."
3710 keymap) 3741 keymap)
3711 "Keymap to put on the Up link in the text or the header line.") 3742 "Keymap to put on the Up link in the text or the header line.")
3712 3743
3713(defcustom Info-breadcrumbs-depth 3 3744(defcustom Info-breadcrumbs-depth 4
3714 "Depth of breadcrumbs to display. 3745 "Depth of breadcrumbs to display.
37150 means do not display breadcrumbs." 37460 means do not display breadcrumbs."
3716 :type 'integer) 3747 :type 'integer)
3717 3748
3718(defun Info-insert-breadcrumbs () 3749(defun Info-insert-breadcrumbs ()
3719 (let ((onode Info-current-node) 3750 (let ((nodes (Info-toc-nodes Info-current-file))
3751 (node Info-current-node)
3720 (crumbs ()) 3752 (crumbs ())
3721 (depth Info-breadcrumbs-depth) 3753 (depth Info-breadcrumbs-depth))
3722 (Info-fontify-maximum-menu-size nil)) ; Prevent infinite recursion. 3754
3723 (unwind-protect 3755 ;; Get ancestors from the cached parent-children node info
3724 (while (and (not (equal "Top" Info-current-node)) (> depth 0)) 3756 (while (and (not (equal "Top" node)) (> depth 0))
3725 (let ((up (Info-extract-pointer "up"))) 3757 (setq node (nth 1 (assoc node nodes)))
3726 (if (string-match "\\`(.*)" up) 3758 (if node (push node crumbs))
3727 ;; Crossing over to another manual. This is typically (dir). 3759 (setq depth (1- depth)))
3728 (setq depth 0) 3760
3729 (push up crumbs) 3761 ;; Add bottom node.
3730 (setq depth (1- depth)) 3762 (when Info-use-header-line
3731 (Info-find-node Info-current-file up 'no-going-back)))) 3763 ;; Let it disappear if crumbs is nil.
3732 (if crumbs ;Do bother going back if we haven't moved. 3764 (nconc crumbs (list Info-current-node)))
3733 (Info-find-node Info-current-file onode 'no-going-back)) 3765 (when (or Info-use-header-line crumbs)
3734 ;; Add bottom node. 3766 ;; Add top node (and continuation if needed).
3735 (when Info-use-header-line 3767 (setq crumbs
3736 ;; Let it disappear if crumbs is nil. 3768 (cons "Top" (if (member (pop crumbs) '(nil "Top"))
3737 (nconc crumbs (list Info-current-node))) 3769 crumbs (cons nil crumbs))))
3738 (when (or Info-use-header-line crumbs) 3770 ;; Eliminate duplicate.
3739 ;; Add top node (and continuation if needed). 3771 (forward-line 1)
3740 (setq crumbs 3772 (dolist (node crumbs)
3741 (cons "Top" (if (member (pop crumbs) '(nil "Top")) 3773 (let ((text
3742 crumbs (cons nil crumbs)))) 3774 (if (not (equal node "Top")) node
3743 ;; Eliminate duplicate. 3775 (format "(%s)Top"
3744 (forward-line 1) 3776 (if (stringp Info-current-file)
3745 (dolist (node crumbs) 3777 (file-name-nondirectory Info-current-file)
3746 (let ((text 3778 ;; Can be `toc', `apropos', or even `history'.
3747 (if (not (equal node "Top")) node 3779 Info-current-file)))))
3748 (format "(%s)Top" 3780 (insert (if (bolp) "" " > ")
3749 (if (stringp Info-current-file) 3781 (cond
3750 (file-name-nondirectory Info-current-file) 3782 ((null node) "...")
3751 ;; Can be `toc', `apropos', or even `history'. 3783 ((equal node Info-current-node)
3752 Info-current-file))))) 3784 ;; No point linking to ourselves.
3753 (insert (if (bolp) "> " " > ") 3785 (propertize text 'font-lock-face 'info-header-node))
3754 (cond 3786 (t
3755 ((null node) "...") 3787 (concat "*Note " text "::"))))))
3756 ((equal node Info-current-node) 3788 (insert "\n"))))
3757 ;; No point linking to ourselves.
3758 (propertize text 'font-lock-face 'info-header-node))
3759 (t
3760 (concat "*Note " text "::"))))))
3761 (insert "\n")))))
3762 3789
3763(defun Info-fontify-node () 3790(defun Info-fontify-node ()
3764 "Fontify the node." 3791 "Fontify the node."