comparison lisp/textmodes/texnfo-upd.el @ 53315:767b85819555

(texinfo-multi-file-update): create a new list of included files, called `files-with-node-lines', that only have node lines. This way @include commands can include any file, such as version and update files without node lines, not just files that are chapters.
author Robert J. Chassell <bob@rattlesnake.com>
date Thu, 25 Dec 2003 20:20:50 +0000
parents 695cf19ef79e
children e7fef31e8d98
comparison
equal deleted inserted replaced
53314:990c58ec131c 53315:767b85819555
1 ;;; texnfo-upd.el --- utilities for updating nodes and menus in Texinfo files 1 ;;; texnfo-upd.el --- utilities for updating nodes and menus in Texinfo files
2 2
3 ;; Copyright (C) 1989, 1990, 1991, 1992, 2001, 2002 Free Software Foundation, Inc. 3 ;; Copyright (C) 1989, 1990, 1991, 1992, 2001, 2002, 2003 Free Software Foundation, Inc.
4 4
5 ;; Author: Robert J. Chassell 5 ;; Author: Robert J. Chassell
6 ;; Maintainer: bug-texinfo@gnu.org 6 ;; Maintainer: bug-texinfo@gnu.org
7 ;; Keywords: maint, tex, docs 7 ;; Keywords: maint, tex, docs
8 8
1793 ;; does not fill it; however a comment tells you how to do so. 1793 ;; does not fill it; however a comment tells you how to do so.
1794 ;; You would use the title field if you wanted to insert titles in the 1794 ;; You would use the title field if you wanted to insert titles in the
1795 ;; description slot of a menu as a description. 1795 ;; description slot of a menu as a description.
1796 1796
1797 (let ((case-fold-search t) 1797 (let ((case-fold-search t)
1798 menu-list next-node-name previous-node-name) 1798 menu-list next-node-name previous-node-name files-with-node-lines)
1799 1799
1800 ;; Find the name of the first node of the first included file. 1800 ;; Create a new list of included files that only have node lines
1801 (set-buffer (find-file-noselect (car (cdr files)))) 1801 (while files
1802 (set-buffer (find-file-noselect (car files)))
1803 (widen)
1804 (goto-char (point-min))
1805 (when (re-search-forward "^@node" nil t)
1806 (setq files-with-node-lines (cons (car files) files-with-node-lines)))
1807 (setq files (cdr files)))
1808 (setq files-with-node-lines (nreverse files-with-node-lines))
1809
1810 ;; Find the name of the first node in a subsequent file
1811 ;; and copy it into the variable next-node-name
1812 (set-buffer (find-file-noselect (car (cdr files-with-node-lines))))
1802 (widen) 1813 (widen)
1803 (goto-char (point-min)) 1814 (goto-char (point-min))
1804 (if (not (re-search-forward "^@node" nil t))
1805 (error "No `@node' line found in %s" (buffer-name)))
1806 (beginning-of-line) 1815 (beginning-of-line)
1807 (texinfo-check-for-node-name) 1816 (texinfo-check-for-node-name)
1808 (setq next-node-name (texinfo-copy-node-name)) 1817 (setq next-node-name (texinfo-copy-node-name))
1809
1810 (push (cons next-node-name (prog1 "" (forward-line 1))) 1818 (push (cons next-node-name (prog1 "" (forward-line 1)))
1811 ;; Use following to insert section titles automatically. 1819 ;; Use following to insert section titles automatically.
1812 ;; (texinfo-copy-next-section-title) 1820 ;; (texinfo-copy-next-section-title)
1813 menu-list) 1821 menu-list)
1814 1822
1815 ;; Go to outer file 1823 ;; Go to outer file
1816 (set-buffer (find-file-noselect (pop files))) 1824 ;; `pop' is analogous to (prog1 (car PLACE) (setf PLACE (cdr PLACE)))
1825 (set-buffer (find-file-noselect (pop files-with-node-lines)))
1817 (goto-char (point-min)) 1826 (goto-char (point-min))
1818 (if (not (re-search-forward "^@node [ \t]*top[ \t]*\\(,\\|$\\)" nil t)) 1827 (if (not (re-search-forward "^@node [ \t]*top[ \t]*\\(,\\|$\\)" nil t))
1819 (error "This buffer needs a Top node")) 1828 (error "This buffer needs a Top node"))
1820 (beginning-of-line) 1829 (beginning-of-line)
1821 (texinfo-delete-existing-pointers) 1830 (texinfo-delete-existing-pointers)
1822 (end-of-line) 1831 (end-of-line)
1823 (insert ", " next-node-name ", (dir), (dir)") 1832 (insert ", " next-node-name ", (dir), (dir)")
1824 (beginning-of-line) 1833 (beginning-of-line)
1825 (setq previous-node-name "Top") 1834 (setq previous-node-name "Top")
1826 1835
1827 (while files 1836 (while files-with-node-lines
1828 1837
1829 (if (not (cdr files)) 1838 (if (not (cdr files-with-node-lines))
1830 ;; No next file 1839 ;; No next file
1831 (setq next-node-name "") 1840 (setq next-node-name "")
1832 ;; Else, 1841 ;; Else,
1833 ;; find the name of the first node in the next file. 1842 ;; find the name of the first node in the next file.
1834 (set-buffer (find-file-noselect (car (cdr files)))) 1843 (set-buffer (find-file-noselect (car (cdr files-with-node-lines))))
1835 (widen) 1844 (widen)
1836 (goto-char (point-min)) 1845 (goto-char (point-min))
1837 (if (not (re-search-forward "^@node" nil t))
1838 (error "No `@node' line found in %s" (buffer-name)))
1839 (beginning-of-line) 1846 (beginning-of-line)
1840 (texinfo-check-for-node-name) 1847 (texinfo-check-for-node-name)
1841 (setq next-node-name (texinfo-copy-node-name)) 1848 (setq next-node-name (texinfo-copy-node-name))
1842 (push (cons next-node-name (prog1 "" (forward-line 1))) 1849 (push (cons next-node-name (prog1 "" (forward-line 1)))
1843 ;; Use following to insert section titles automatically. 1850 ;; Use following to insert section titles automatically.
1844 ;; (texinfo-copy-next-section-title) 1851 ;; (texinfo-copy-next-section-title)
1845 menu-list)) 1852 menu-list))
1846 1853
1847 ;; Go to node to be updated. 1854 ;; Go to node to be updated.
1848 (set-buffer (find-file-noselect (car files))) 1855 (set-buffer (find-file-noselect (car files-with-node-lines)))
1849 (goto-char (point-min)) 1856 (goto-char (point-min))
1850 (if (not (re-search-forward "^@node" nil t))
1851 (error "No `@node' line found in %s" (buffer-name)))
1852 (beginning-of-line) 1857 (beginning-of-line)
1853 1858
1854 ;; Update other menus and nodes if requested. 1859 ;; Update other menus and nodes if requested.
1855 (if update-everything (texinfo-all-menus-update t)) 1860 (if update-everything (texinfo-all-menus-update t))
1856 1861
1860 (insert ", " next-node-name ", " previous-node-name ", Top") 1865 (insert ", " next-node-name ", " previous-node-name ", Top")
1861 1866
1862 (beginning-of-line) 1867 (beginning-of-line)
1863 (setq previous-node-name (texinfo-copy-node-name)) 1868 (setq previous-node-name (texinfo-copy-node-name))
1864 1869
1865 (setq files (cdr files))) 1870 (setq files-with-node-lines (cdr files-with-node-lines)))
1866 (nreverse menu-list))) 1871 (nreverse menu-list)))
1867 1872
1868 (defun texinfo-multi-files-insert-main-menu (menu-list) 1873 (defun texinfo-multi-files-insert-main-menu (menu-list)
1869 "Insert formatted main menu at point. 1874 "Insert formatted main menu at point.
1870 Indents the first line of the description, if any, to the value of 1875 Indents the first line of the description, if any, to the value of