;;; texnfo-upd.el --- utilities for updating nodes and menus in Texinfo files
-;; Copyright (C) 1989, 1990, 1991, 1992, 2001, 2002 Free Software Foundation, Inc.
+;; Copyright (C) 1989, 1990, 1991, 1992, 2001, 2002, 2003 Free Software Foundation, Inc.
;; Author: Robert J. Chassell
;; Maintainer: bug-texinfo@gnu.org
;; description slot of a menu as a description.
(let ((case-fold-search t)
- menu-list next-node-name previous-node-name)
+ menu-list next-node-name previous-node-name files-with-node-lines)
- ;; Find the name of the first node of the first included file.
- (set-buffer (find-file-noselect (car (cdr files))))
+ ;; Create a new list of included files that only have node lines
+ (while files
+ (set-buffer (find-file-noselect (car files)))
+ (widen)
+ (goto-char (point-min))
+ (when (re-search-forward "^@node" nil t)
+ (setq files-with-node-lines (cons (car files) files-with-node-lines)))
+ (setq files (cdr files)))
+ (setq files-with-node-lines (nreverse files-with-node-lines))
+
+ ;; Find the name of the first node in a subsequent file
+ ;; and copy it into the variable next-node-name
+ (set-buffer (find-file-noselect (car (cdr files-with-node-lines))))
(widen)
(goto-char (point-min))
- (if (not (re-search-forward "^@node" nil t))
- (error "No `@node' line found in %s" (buffer-name)))
(beginning-of-line)
(texinfo-check-for-node-name)
(setq next-node-name (texinfo-copy-node-name))
-
(push (cons next-node-name (prog1 "" (forward-line 1)))
;; Use following to insert section titles automatically.
;; (texinfo-copy-next-section-title)
menu-list)
;; Go to outer file
- (set-buffer (find-file-noselect (pop files)))
+ ;; `pop' is analogous to (prog1 (car PLACE) (setf PLACE (cdr PLACE)))
+ (set-buffer (find-file-noselect (pop files-with-node-lines)))
(goto-char (point-min))
(if (not (re-search-forward "^@node [ \t]*top[ \t]*\\(,\\|$\\)" nil t))
(error "This buffer needs a Top node"))
(beginning-of-line)
(setq previous-node-name "Top")
- (while files
+ (while files-with-node-lines
- (if (not (cdr files))
+ (if (not (cdr files-with-node-lines))
;; No next file
(setq next-node-name "")
;; Else,
;; find the name of the first node in the next file.
- (set-buffer (find-file-noselect (car (cdr files))))
+ (set-buffer (find-file-noselect (car (cdr files-with-node-lines))))
(widen)
(goto-char (point-min))
- (if (not (re-search-forward "^@node" nil t))
- (error "No `@node' line found in %s" (buffer-name)))
(beginning-of-line)
(texinfo-check-for-node-name)
(setq next-node-name (texinfo-copy-node-name))
menu-list))
;; Go to node to be updated.
- (set-buffer (find-file-noselect (car files)))
+ (set-buffer (find-file-noselect (car files-with-node-lines)))
(goto-char (point-min))
- (if (not (re-search-forward "^@node" nil t))
- (error "No `@node' line found in %s" (buffer-name)))
(beginning-of-line)
;; Update other menus and nodes if requested.
(beginning-of-line)
(setq previous-node-name (texinfo-copy-node-name))
- (setq files (cdr files)))
+ (setq files-with-node-lines (cdr files-with-node-lines)))
(nreverse menu-list)))
(defun texinfo-multi-files-insert-main-menu (menu-list)