comparison lisp/info.el @ 57329:52649ba67540

(Info-history, Info-toc): Fix Info headers. (Info-toc): Narrow buffer before Info-fontify-node. (Info-build-toc): Don't check for special Info file names. Set main-file to nil if Info-find-file returns a symbol.
author Juri Linkov <juri@jurta.org>
date Tue, 05 Oct 2004 04:23:17 +0000
parents 53c840d7ea68
children 478f1e91eac3
comparison
equal deleted inserted replaced
57328:e2c34e75e585 57329:52649ba67540
1727 p) 1727 p)
1728 (with-current-buffer (get-buffer-create " *info-history*") 1728 (with-current-buffer (get-buffer-create " *info-history*")
1729 (let ((inhibit-read-only t)) 1729 (let ((inhibit-read-only t))
1730 (erase-buffer) 1730 (erase-buffer)
1731 (goto-char (point-min)) 1731 (goto-char (point-min))
1732 (insert "\n\^_\nFile: history Node: Top, Up: (dir)\n\n") 1732 (insert "\n\^_\nFile: history, Node: Top, Up: (dir)\n\n")
1733 (insert "Recently Visited Nodes\n**********************\n\n") 1733 (insert "Recently Visited Nodes\n**********************\n\n")
1734 (insert "* Menu:\n\n") 1734 (insert "* Menu:\n\n")
1735 (let ((hl (delete '("history" "Top") Info-history-list))) 1735 (let ((hl (delete '("history" "Top") Info-history-list)))
1736 (while hl 1736 (while hl
1737 (let ((file (nth 0 (car hl))) 1737 (let ((file (nth 0 (car hl)))
1747 1747
1748 (defun Info-toc () 1748 (defun Info-toc ()
1749 "Go to a node with table of contents of the current Info file. 1749 "Go to a node with table of contents of the current Info file.
1750 Table of contents is created from the tree structure of menus." 1750 Table of contents is created from the tree structure of menus."
1751 (interactive) 1751 (interactive)
1752 (let ((curr-file Info-current-file) 1752 (let ((curr-file (substring-no-properties Info-current-file))
1753 (curr-node Info-current-node) 1753 (curr-node (substring-no-properties Info-current-node))
1754 p) 1754 p)
1755 (with-current-buffer (get-buffer-create " *info-toc*") 1755 (with-current-buffer (get-buffer-create " *info-toc*")
1756 (let ((inhibit-read-only t) 1756 (let ((inhibit-read-only t)
1757 (node-list (Info-build-toc curr-file))) 1757 (node-list (Info-build-toc curr-file)))
1758 (erase-buffer) 1758 (erase-buffer)
1759 (goto-char (point-min)) 1759 (goto-char (point-min))
1760 (insert "\n\^_\nFile: toc Node: Top, Up: (dir)\n\n") 1760 (insert "\n\^_\nFile: toc, Node: Top, Up: (dir)\n\n")
1761 (insert "Table of Contents\n*****************\n\n") 1761 (insert "Table of Contents\n*****************\n\n")
1762 (insert "*Note Top::\n") 1762 (insert "*Note Top: (" curr-file ")Top.\n")
1763 (Info-insert-toc 1763 (Info-insert-toc
1764 (nth 2 (assoc "Top" node-list)) ; get Top nodes 1764 (nth 2 (assoc "Top" node-list)) ; get Top nodes
1765 node-list 0 (substring-no-properties curr-file))) 1765 node-list 0 curr-file))
1766 (if (not (bobp)) 1766 (if (not (bobp))
1767 (let ((Info-hide-note-references 'hide) 1767 (let ((Info-hide-note-references 'hide)
1768 (Info-fontify-visited-nodes nil)) 1768 (Info-fontify-visited-nodes nil))
1769 (Info-mode) 1769 (Info-mode)
1770 (setq Info-current-file "toc" Info-current-node "Top") 1770 (setq Info-current-file "toc" Info-current-node "Top")
1771 (Info-fontify-node))) 1771 (goto-char (point-min))
1772 (narrow-to-region (or (re-search-forward "\n[\^_\f]\n" nil t)
1773 (point-min))
1774 (point-max))
1775 (Info-fontify-node)
1776 (widen)))
1772 (goto-char (point-min)) 1777 (goto-char (point-min))
1773 (if (setq p (search-forward (concat "*Note " curr-node ":") nil t)) 1778 (if (setq p (search-forward (concat "*Note " curr-node ":") nil t))
1774 (setq p (- p (length curr-node) 2)))) 1779 (setq p (- p (length curr-node) 2))))
1775 (Info-find-node "toc" "Top") 1780 (Info-find-node "toc" "Top")
1776 (goto-char (or p (point-min))))) 1781 (goto-char (or p (point-min)))))
1787 (Info-insert-toc (nth 2 node) node-list (1+ level) curr-file) 1792 (Info-insert-toc (nth 2 node) node-list (1+ level) curr-file)
1788 (setq nodes (cdr nodes)))))) 1793 (setq nodes (cdr nodes))))))
1789 1794
1790 (defun Info-build-toc (file) 1795 (defun Info-build-toc (file)
1791 "Build table of contents from menus of Info FILE and its subfiles." 1796 "Build table of contents from menus of Info FILE and its subfiles."
1792 (if (equal file "dir")
1793 (error "Table of contents for Info directory is not supported yet"))
1794 (with-temp-buffer 1797 (with-temp-buffer
1795 (let* ((default-directory (or (and (stringp file) 1798 (let* ((file (and (stringp file) (Info-find-file file)))
1796 (file-name-directory 1799 (default-directory (or (and (stringp file)
1797 (setq file (Info-find-file file)))) 1800 (file-name-directory file))
1798 default-directory)) 1801 default-directory))
1799 (main-file file) 1802 (main-file (and (stringp file) file))
1800 (sections '(("Top" "Top"))) 1803 (sections '(("Top" "Top")))
1801 nodes subfiles) 1804 nodes subfiles)
1802 (while (or main-file subfiles) 1805 (while (or main-file subfiles)
1803 (or main-file (message "Searching subfile %s..." (car subfiles))) 1806 (or main-file (message "Searching subfile %s..." (car subfiles)))
1804 (erase-buffer) 1807 (erase-buffer)