# HG changeset patch # User Karl Heuer # Date 917283863 0 # Node ID ec6c3e69f89ac50d55009fce25208c65b5a32ad4 # Parent 4cd52e40cf3166a277b9b2fdacf93a239609b777 (texinfo-make-menu): Make region-end a marker. diff -r 4cd52e40cf31 -r ec6c3e69f89a lisp/textmodes/texnfo-upd.el --- a/lisp/textmodes/texnfo-upd.el Mon Jan 25 16:41:04 1999 +0000 +++ b/lisp/textmodes/texnfo-upd.el Mon Jan 25 17:04:23 1999 +0000 @@ -178,31 +178,35 @@ (list (point) (mark)))) (if (null beginning) (let ((level (texinfo-hierarchic-level))) - (texinfo-make-one-menu level) - (message "Menu updated")) + (texinfo-make-one-menu level) + (message "Menu updated")) ;; else (message "Making or updating menus in %s... " (buffer-name)) (save-excursion (goto-char (min beginning end)) ;; find section type following point (let ((level (texinfo-hierarchic-level)) - (region-end (max beginning end))) - (save-restriction - (widen) + (region-end-marker (make-marker))) + (set-marker region-end-marker (max beginning end)) + (save-restriction + (widen) - (while (texinfo-find-lower-level-node level region-end) - (setq level (texinfo-hierarchic-level)) ; new, lower level - (texinfo-make-one-menu level)) + (while (texinfo-find-lower-level-node + level (marker-position region-end-marker)) + (setq level (texinfo-hierarchic-level)) ; new, lower level + (texinfo-make-one-menu level)) - (while (and (< (point) region-end) - (texinfo-find-higher-level-node level region-end)) - (setq level (texinfo-hierarchic-level)) + (while (and (< (point) (marker-position region-end-marker)) + (texinfo-find-higher-level-node + level (marker-position region-end-marker))) + (setq level (texinfo-hierarchic-level)) ;; Don't allow texinfo-find-higher-level-node ;; to find the same node again. (forward-line 1) - (while (texinfo-find-lower-level-node level region-end) - (setq level (texinfo-hierarchic-level)) ; new, lower level - (texinfo-make-one-menu level)))))) + (while (texinfo-find-lower-level-node + level (marker-position region-end-marker)) + (setq level (texinfo-hierarchic-level)) ; new, lower level + (texinfo-make-one-menu level)))))) (message "Making or updating menus in %s...done" (buffer-name)))) (defun texinfo-make-one-menu (level) @@ -219,15 +223,15 @@ (end (texinfo-update-menu-region-end level)) (first (texinfo-menu-first-node beginning end)) (node-name (progn - (goto-char beginning) - (beginning-of-line) - (texinfo-copy-node-name))) + (goto-char beginning) + (beginning-of-line) + (texinfo-copy-node-name))) (new-menu-list (texinfo-make-menu-list beginning end level))) (if (texinfo-old-menu-p beginning first) - (progn - (texinfo-incorporate-descriptions new-menu-list) - (texinfo-incorporate-menu-entry-names new-menu-list) - (texinfo-delete-old-menu beginning first))) + (progn + (texinfo-incorporate-descriptions new-menu-list) + (texinfo-incorporate-menu-entry-names new-menu-list) + (texinfo-delete-old-menu beginning first))) (texinfo-insert-menu new-menu-list node-name))) (defun texinfo-all-menus-update (&optional update-all-nodes-p) @@ -238,33 +242,33 @@ nodes in the buffer before updating the menus." (interactive "P") (let ((case-fold-search t) - master-menu-p) + master-menu-p) (save-excursion (push-mark (point-max) t) (goto-char (point-min)) (message "Checking for a master menu in %s ... "(buffer-name)) (save-excursion - (if (search-forward texinfo-master-menu-header nil t) - (progn - ;; Check if @detailmenu kludge is used; - ;; if so, leave point before @detailmenu. - (search-backward "\n@detailmenu" + (if (search-forward texinfo-master-menu-header nil t) + (progn + ;; Check if @detailmenu kludge is used; + ;; if so, leave point before @detailmenu. + (search-backward "\n@detailmenu" (save-excursion (forward-line -3) (point)) t) ;; Remove detailed master menu listing - (setq master-menu-p t) - (goto-char (match-beginning 0)) - (let ((end-of-detailed-menu-descriptions - (save-excursion ; beginning of end menu line - (goto-char (texinfo-menu-end)) - (beginning-of-line) (forward-char -1) - (point)))) - (delete-region (point) end-of-detailed-menu-descriptions))))) + (setq master-menu-p t) + (goto-char (match-beginning 0)) + (let ((end-of-detailed-menu-descriptions + (save-excursion ; beginning of end menu line + (goto-char (texinfo-menu-end)) + (beginning-of-line) (forward-char -1) + (point)))) + (delete-region (point) end-of-detailed-menu-descriptions))))) (if update-all-nodes-p - (progn - (message "Updating all nodes in %s ... " (buffer-name)) - (sleep-for 2) + (progn + (message "Updating all nodes in %s ... " (buffer-name)) + (sleep-for 2) (texinfo-update-node (point-min) (point-max)))) (message "Updating all menus in %s ... " (buffer-name)) @@ -272,10 +276,10 @@ (texinfo-make-menu (point-max) (point-min)) (if master-menu-p - (progn - (message "Updating the master menu in %s... " (buffer-name)) - (sleep-for 2) - (texinfo-master-menu nil)))) + (progn + (message "Updating the master menu in %s... " (buffer-name)) + (sleep-for 2) + (texinfo-master-menu nil)))) (message "Done...updated all the menus. You may save the buffer."))) @@ -288,19 +292,19 @@ of the node if one is found; else do not move point." (let ((case-fold-search t)) (if (and (< (point) region-end) - (re-search-forward - (concat - "\\(^@node\\).*\n" ; match node line - "\\(\\(\\(^@c\\).*\n\\)" ; match comment line, if any - "\\|" ; or - "\\(^@ifinfo[ ]*\n\\)\\)?" ; ifinfo line, if any - (eval (cdr (assoc level texinfo-update-menu-lower-regexps)))) - ;; the next higher level node marks the end of this - ;; section, and no lower level node will be found beyond - ;; this position even if region-end is farther off - (texinfo-update-menu-region-end level) - t)) - (goto-char (match-beginning 1))))) + (re-search-forward + (concat + "\\(^@node\\).*\n" ; match node line + "\\(\\(\\(^@c\\).*\n\\)" ; match comment line, if any + "\\|" ; or + "\\(^@ifinfo[ ]*\n\\)\\)?" ; ifinfo line, if any + (eval (cdr (assoc level texinfo-update-menu-lower-regexps)))) + ;; the next higher level node marks the end of this + ;; section, and no lower level node will be found beyond + ;; this position even if region-end is farther off + (texinfo-update-menu-region-end level) + t)) + (goto-char (match-beginning 1))))) (defun texinfo-find-higher-level-node (level region-end) "Search forward from point for node at any higher level than argument LEVEL. @@ -316,17 +320,17 @@ (cond ((or (string-equal "top" level) (string-equal "chapter" level)) (if (re-search-forward "^@node [ \t]*top[ \t]*\\(,\\|$\\)" region-end t) - (progn (beginning-of-line) t))) + (progn (beginning-of-line) t))) (t (if (re-search-forward - (concat - "\\(^@node\\).*\n" ; match node line - "\\(\\(\\(^@c\\).*\n\\)" ; match comment line, if any - "\\|" ; or - "\\(^@ifinfo[ ]*\n\\)\\)?" ; ifinfo line, if any - (eval (cdr (assoc level texinfo-update-menu-higher-regexps)))) - region-end t) - (progn (beginning-of-line) t)))))) + (concat + "\\(^@node\\).*\n" ; match node line + "\\(\\(\\(^@c\\).*\n\\)" ; match comment line, if any + "\\|" ; or + "\\(^@ifinfo[ ]*\n\\)\\)?" ; ifinfo line, if any + (eval (cdr (assoc level texinfo-update-menu-higher-regexps)))) + region-end t) + (progn (beginning-of-line) t)))))) ;;; Making the list of new menu entries @@ -346,12 +350,12 @@ (let (new-menu-list) (while (texinfo-menu-locate-entry-p level end) (setq new-menu-list - (cons (cons - (texinfo-copy-node-name) - (prog1 "" (forward-line 1))) - ;; Use following to insert section titles automatically. - ;; (texinfo-copy-section-title)) - new-menu-list))) + (cons (cons + (texinfo-copy-node-name) + (prog1 "" (forward-line 1))) + ;; Use following to insert section titles automatically. + ;; (texinfo-copy-section-title)) + new-menu-list))) (reverse new-menu-list))) (defun texinfo-menu-locate-entry-p (level search-end) @@ -367,16 +371,16 @@ `unnumberedsubsecs' will appear in the same menu." (let ((case-fold-search t)) (if (re-search-forward - (concat - "\\(^@node\\).*\n" ; match node line - "\\(\\(\\(^@c\\).*\n\\)" ; match comment line, if any - "\\|" ; or - "\\(^@ifinfo[ ]*\n\\)\\)?" ; ifinfo line, if any - (eval - (cdr (assoc level texinfo-update-menu-same-level-regexps)))) - search-end - t) - (goto-char (match-beginning 1))))) + (concat + "\\(^@node\\).*\n" ; match node line + "\\(\\(\\(^@c\\).*\n\\)" ; match comment line, if any + "\\|" ; or + "\\(^@ifinfo[ ]*\n\\)\\)?" ; ifinfo line, if any + (eval + (cdr (assoc level texinfo-update-menu-same-level-regexps)))) + search-end + t) + (goto-char (match-beginning 1))))) (defun texinfo-copy-node-name () "Return the node name as a string. @@ -389,12 +393,12 @@ (save-excursion (buffer-substring (progn (forward-word 1) ; skip over node command - (skip-chars-forward " \t") ; and over spaces - (point)) + (skip-chars-forward " \t") ; and over spaces + (point)) (if (search-forward - "," - (save-excursion (end-of-line) (point)) t) ; bound search - (1- (point)) + "," + (save-excursion (end-of-line) (point)) t) ; bound search + (1- (point)) (end-of-line) (point))))) (defun texinfo-copy-section-title () @@ -414,8 +418,8 @@ (buffer-substring (progn (forward-word 1) ; skip over section type - (skip-chars-forward " \t") ; and over spaces - (point)) + (skip-chars-forward " \t") ; and over spaces + (point)) (progn (end-of-line) (point)))) @@ -451,26 +455,26 @@ The old menu is the menu as it appears in the Texinfo file." (let ((new-menu-list-pointer new-menu-list) - (end-of-menu (texinfo-menu-end))) + (end-of-menu (texinfo-menu-end))) (while new-menu-list (save-excursion ; keep point at beginning of menu - (if (re-search-forward - ;; Existing nodes can have the form - ;; * NODE NAME:: DESCRIPTION - ;; or - ;; * MENU ITEM: NODE NAME. DESCRIPTION. - ;; - ;; Recognize both when looking for the description. - (concat "\\* \\(" ; so only menu entries are found - (regexp-quote (car (car new-menu-list))) "::" - "\\|" - ".*: " (regexp-quote (car (car new-menu-list))) "[.,\t\n]" - "\\)" - ) ; so only complete entries are found - end-of-menu - t) - (setcdr (car new-menu-list) - (texinfo-menu-copy-old-description end-of-menu)))) + (if (re-search-forward + ;; Existing nodes can have the form + ;; * NODE NAME:: DESCRIPTION + ;; or + ;; * MENU ITEM: NODE NAME. DESCRIPTION. + ;; + ;; Recognize both when looking for the description. + (concat "\\* \\(" ; so only menu entries are found + (regexp-quote (car (car new-menu-list))) "::" + "\\|" + ".*: " (regexp-quote (car (car new-menu-list))) "[.,\t\n]" + "\\)" + ) ; so only complete entries are found + end-of-menu + t) + (setcdr (car new-menu-list) + (texinfo-menu-copy-old-description end-of-menu)))) (setq new-menu-list (cdr new-menu-list))) (setq new-menu-list new-menu-list-pointer))) @@ -494,25 +498,25 @@ appears in the texinfo file." (let ((new-menu-list-pointer new-menu-list) - (end-of-menu (texinfo-menu-end))) + (end-of-menu (texinfo-menu-end))) (while new-menu-list (save-excursion ; keep point at beginning of menu - (if (re-search-forward - ;; Existing nodes can have the form - ;; * NODE NAME:: DESCRIPTION - ;; or - ;; * MENU ITEM: NODE NAME. DESCRIPTION. - ;; - ;; We're interested in the second case. - (concat "\\* " ; so only menu entries are found + (if (re-search-forward + ;; Existing nodes can have the form + ;; * NODE NAME:: DESCRIPTION + ;; or + ;; * MENU ITEM: NODE NAME. DESCRIPTION. + ;; + ;; We're interested in the second case. + (concat "\\* " ; so only menu entries are found "\\(.*\\): " (regexp-quote (car (car new-menu-list))) "[.,\t\n]") - end-of-menu - t) - (setcar - (car new-menu-list) ; replace the node name - (cons (buffer-substring (match-beginning 1) (match-end 1)) - (car (car new-menu-list))))) + end-of-menu + t) + (setcar + (car new-menu-list) ; replace the node name + (cons (buffer-substring (match-beginning 1) (match-end 1)) + (car (car new-menu-list))))) (setq new-menu-list (cdr new-menu-list)))) (setq new-menu-list new-menu-list-pointer))) @@ -525,14 +529,14 @@ ;; do copy a description that begins with an `@'! ;; !! Known bug: does not copy descriptions starting with ^|\{?* etc. (if (and (looking-at "\\(\\w+\\|@\\)") - (not (looking-at "\\(^\\* \\|^@end menu\\)"))) + (not (looking-at "\\(^\\* \\|^@end menu\\)"))) (buffer-substring (point) (save-excursion - (re-search-forward "\\(^\\* \\|^@end menu\\)" end-of-menu t) - (forward-line -1) - (end-of-line) ; go to end of last description line - (point))) + (re-search-forward "\\(^\\* \\|^@end menu\\)" end-of-menu t) + (forward-line -1) + (end-of-line) ; go to end of last description line + (point))) "")) (defun texinfo-menu-end () @@ -540,7 +544,7 @@ Signal an error if not end of menu." (save-excursion (if (re-search-forward "^@end menu" nil t) - (point) + (point) (error "Menu does not have an end.")))) (defun texinfo-delete-old-menu (beginning first) @@ -551,9 +555,9 @@ ;; No third arg to search, so error if search fails. (re-search-backward "^@menu" beginning) (delete-region (point) - (save-excursion - (re-search-forward "^@end menu" first) - (point)))) + (save-excursion + (re-search-forward "^@end menu" first) + (point)))) ;;; Inserting new menu @@ -586,18 +590,18 @@ ;; Insert the node name (and menu entry name, if present). (let ((node-part (car (car menu-list)))) (if (stringp node-part) - ;; "Double colon" entry line; menu entry and node name are the same, - (insert (format "%s::" node-part)) - ;; "Single colon" entry line; menu entry and node name are different. - (insert (format "%s: %s." (car node-part) (cdr node-part))))) + ;; "Double colon" entry line; menu entry and node name are the same, + (insert (format "%s::" node-part)) + ;; "Single colon" entry line; menu entry and node name are different. + (insert (format "%s: %s." (car node-part) (cdr node-part))))) ;; Insert the description, if present. (if (cdr (car menu-list)) - (progn - ;; Move to right place. - (indent-to texinfo-column-for-description 2) - ;; Insert description. - (insert (format "%s" (cdr (car menu-list)))))) + (progn + ;; Move to right place. + (indent-to texinfo-column-for-description 2) + ;; Insert description. + (insert (format "%s" (cdr (car menu-list)))))) (insert "\n") ; end this menu entry (setq menu-list (cdr menu-list))) @@ -621,63 +625,63 @@ (save-excursion (beginning-of-line) (if (search-forward "* " (save-excursion (end-of-line) (point)) t) - (progn (skip-chars-forward " \t") - (setq beginning (point))) - (error "This is not a line in a menu!")) + (progn (skip-chars-forward " \t") + (setq beginning (point))) + (error "This is not a line in a menu!")) (cond - ;; "Double colon" entry line; menu entry and node name are the same, + ;; "Double colon" entry line; menu entry and node name are the same, ((search-forward "::" (save-excursion (end-of-line) (point)) t) - (if (looking-at "[ \t]*[^ \t\n]+") - (error "Descriptive text already exists.")) - (skip-chars-backward ": \t") - (setq node-name (buffer-substring beginning (point)))) + (if (looking-at "[ \t]*[^ \t\n]+") + (error "Descriptive text already exists.")) + (skip-chars-backward ": \t") + (setq node-name (buffer-substring beginning (point)))) ;; "Single colon" entry line; menu entry and node name are different. ((search-forward ":" (save-excursion (end-of-line) (point)) t) - (skip-chars-forward " \t") - (setq beginning (point)) - ;; Menu entry line ends in a period, comma, or tab. - (if (re-search-forward "[.,\t]" - (save-excursion (forward-line 1) (point)) t) - (progn - (if (looking-at "[ \t]*[^ \t\n]+") - (error "Descriptive text already exists.")) - (skip-chars-backward "., \t") - (setq node-name (buffer-substring beginning (point)))) - ;; Menu entry line ends in a return. - (re-search-forward ".*\n" - (save-excursion (forward-line 1) (point)) t) - (skip-chars-backward " \t\n") - (setq node-name (buffer-substring beginning (point))) - (if (= 0 (length node-name)) - (error "No node name on this line.") - (insert ".")))) + (skip-chars-forward " \t") + (setq beginning (point)) + ;; Menu entry line ends in a period, comma, or tab. + (if (re-search-forward "[.,\t]" + (save-excursion (forward-line 1) (point)) t) + (progn + (if (looking-at "[ \t]*[^ \t\n]+") + (error "Descriptive text already exists.")) + (skip-chars-backward "., \t") + (setq node-name (buffer-substring beginning (point)))) + ;; Menu entry line ends in a return. + (re-search-forward ".*\n" + (save-excursion (forward-line 1) (point)) t) + (skip-chars-backward " \t\n") + (setq node-name (buffer-substring beginning (point))) + (if (= 0 (length node-name)) + (error "No node name on this line.") + (insert ".")))) (t (error "No node name on this line."))) ;; Search for node that matches node name, and copy the section title. (if (re-search-forward - (concat - "^@node[ \t]+" - (regexp-quote node-name) - ".*\n" ; match node line - "\\(" - "\\(\\(^@c \\|^@comment\\).*\n\\)" ; match comment line, if any - "\\|" ; or - "\\(^@ifinfo[ ]*\n\\)" ; ifinfo line, if any - "\\)?") - nil t) - (progn - (setq title - (buffer-substring - ;; skip over section type - (progn (forward-word 1) - ;; and over spaces - (skip-chars-forward " \t") - (point)) - (progn (end-of-line) - (skip-chars-backward " \t") - (point))))) - (error "Cannot find node to match node name in menu entry."))) + (concat + "^@node[ \t]+" + (regexp-quote node-name) + ".*\n" ; match node line + "\\(" + "\\(\\(^@c \\|^@comment\\).*\n\\)" ; match comment line, if any + "\\|" ; or + "\\(^@ifinfo[ ]*\n\\)" ; ifinfo line, if any + "\\)?") + nil t) + (progn + (setq title + (buffer-substring + ;; skip over section type + (progn (forward-word 1) + ;; and over spaces + (skip-chars-forward " \t") + (point)) + (progn (end-of-line) + (skip-chars-backward " \t") + (point))))) + (error "Cannot find node to match node name in menu entry."))) ;; Return point to the menu and insert the title. (end-of-line) (delete-region @@ -704,19 +708,19 @@ (save-restriction (widen) (if (not region-p) - (progn - (re-search-forward "^@menu") - (texinfo-menu-indent-description column) - (message - "Indented descriptions in menu. You may save the buffer.")) - ;;else - (message "Indenting every menu description in region... ") - (goto-char (region-beginning)) - (while (and (< (point) (region-end)) - (texinfo-locate-menu-p)) - (forward-line 1) - (texinfo-menu-indent-description column)) - (message "Indenting done. You may save the buffer."))))) + (progn + (re-search-forward "^@menu") + (texinfo-menu-indent-description column) + (message + "Indented descriptions in menu. You may save the buffer.")) + ;;else + (message "Indenting every menu description in region... ") + (goto-char (region-beginning)) + (while (and (< (point) (region-end)) + (texinfo-locate-menu-p)) + (forward-line 1) + (texinfo-menu-indent-description column)) + (message "Indenting done. You may save the buffer."))))) (defun texinfo-menu-indent-description (to-column-number) "Indent the Texinfo file menu description to TO-COLUMN-NUMBER. @@ -725,22 +729,22 @@ second and subsequent lines of a multi-line description." (let* ((beginning-of-next-line (point))) (while (< beginning-of-next-line - (save-excursion ; beginning of end menu line - (goto-char (texinfo-menu-end)) - (beginning-of-line) - (point))) + (save-excursion ; beginning of end menu line + (goto-char (texinfo-menu-end)) + (beginning-of-line) + (point))) (if (re-search-forward "\\* \\(.*::\\|.*: [^.,\t\n]+[.,\t]\\)" - (texinfo-menu-end) - t) - (progn - (let ((beginning-white-space (point))) - (skip-chars-forward " \t") ; skip over spaces - (if (looking-at "\\(@\\|\\w\\)+") ; if there is text - (progn - ;; remove pre-existing indentation - (delete-region beginning-white-space (point)) - (indent-to-column to-column-number)))))) + (texinfo-menu-end) + t) + (progn + (let ((beginning-white-space (point))) + (skip-chars-forward " \t") ; skip over spaces + (if (looking-at "\\(@\\|\\w\\)+") ; if there is text + (progn + ;; remove pre-existing indentation + (delete-region beginning-white-space (point)) + (indent-to-column to-column-number)))))) ;; position point at beginning of next line (forward-line 1) (setq beginning-of-next-line (point))))) @@ -788,39 +792,39 @@ ;; Move point to location after `top'. (if (not (re-search-forward "^@node [ \t]*top[ \t]*\\(,\\|$\\)" nil t)) - (error "This buffer needs a Top node!")) + (error "This buffer needs a Top node!")) (let ((first-chapter - (save-excursion - (or (re-search-forward "^@node" nil t) - (error "Too few nodes for a master menu!")) - (point)))) + (save-excursion + (or (re-search-forward "^@node" nil t) + (error "Too few nodes for a master menu!")) + (point)))) (if (search-forward texinfo-master-menu-header first-chapter t) - (progn - ;; Check if @detailmenu kludge is used; - ;; if so, leave point before @detailmenu. - (search-backward "\n@detailmenu" + (progn + ;; Check if @detailmenu kludge is used; + ;; if so, leave point before @detailmenu. + (search-backward "\n@detailmenu" (save-excursion (forward-line -3) (point)) t) ;; Remove detailed master menu listing - (goto-char (match-beginning 0)) - (let ((end-of-detailed-menu-descriptions - (save-excursion ; beginning of end menu line - (goto-char (texinfo-menu-end)) - (beginning-of-line) (forward-char -1) - (point)))) - (delete-region (point) end-of-detailed-menu-descriptions))))) + (goto-char (match-beginning 0)) + (let ((end-of-detailed-menu-descriptions + (save-excursion ; beginning of end menu line + (goto-char (texinfo-menu-end)) + (beginning-of-line) (forward-char -1) + (point)))) + (delete-region (point) end-of-detailed-menu-descriptions))))) (if update-all-nodes-menus-p - (progn - (message "Making a master menu in %s ...first updating all nodes... " - (buffer-name)) - (sleep-for 2) - (texinfo-update-node (point-min) (point-max)) + (progn + (message "Making a master menu in %s ...first updating all nodes... " + (buffer-name)) + (sleep-for 2) + (texinfo-update-node (point-min) (point-max)) - (message "Updating all menus in %s ... " (buffer-name)) - (sleep-for 2) - (texinfo-make-menu (point-min) (point-max)))) + (message "Updating all menus in %s ... " (buffer-name)) + (sleep-for 2) + (texinfo-make-menu (point-min) (point-max)))) (message "Now making the master menu in %s... " (buffer-name)) (sleep-for 2) @@ -835,16 +839,16 @@ (goto-char (point-min)) (if (search-forward texinfo-master-menu-header nil t) - (progn - (goto-char (match-beginning 0)) - ;; Check if @detailmenu kludge is used; - ;; if so, leave point before @detailmenu. - (search-backward "\n@detailmenu" + (progn + (goto-char (match-beginning 0)) + ;; Check if @detailmenu kludge is used; + ;; if so, leave point before @detailmenu. + (search-backward "\n@detailmenu" (save-excursion (forward-line -3) (point)) t) - (insert "\n") - (delete-blank-lines) - (goto-char (point-min)))) + (insert "\n") + (delete-blank-lines) + (goto-char (point-min)))) (re-search-forward "^@menu") (forward-line -1) @@ -874,10 +878,10 @@ (let (master-menu-list) (while (texinfo-locate-menu-p) (setq master-menu-list - (cons (list - (texinfo-copy-menu) - (texinfo-copy-menu-title)) - master-menu-list))) + (cons (list + (texinfo-copy-menu) + (texinfo-copy-menu-title)) + master-menu-list))) (reverse master-menu-list))) (defun texinfo-insert-master-menu-list (master-menu-list) @@ -888,10 +892,10 @@ (if (not (re-search-forward "^@node [ \t]*top[ \t]*\\(,\\|$\\)" nil t)) (error "This buffer needs a Top node!")) (let ((first-chapter - (save-excursion (re-search-forward "^@node\\|^@include") (point)))) + (save-excursion (re-search-forward "^@node\\|^@include") (point)))) (if (not (re-search-forward "^@menu" first-chapter t)) - (error - "Buffer lacks ordinary `Top' menu in which to insert master."))) + (error + "Buffer lacks ordinary `Top' menu in which to insert master."))) (beginning-of-line) (delete-region ; buffer must have ordinary top menu (point) @@ -908,15 +912,15 @@ ;; Tell user what is going on. (message "Inserting chapter menu entry: %s ... " this-very-menu-list) (while this-very-menu-list - (insert "* " (car this-very-menu-list) "\n") - (setq this-very-menu-list (cdr this-very-menu-list))) + (insert "* " (car this-very-menu-list) "\n") + (setq this-very-menu-list (cdr this-very-menu-list))) (setq master-menu-list (cdr master-menu-list)) ;; Only insert detailed master menu if there is one.... (if (car (car master-menu-list)) - (progn (setq master-menu-inserted-p t) - (insert (concat "\n@detailmenu\n" + (progn (setq master-menu-inserted-p t) + (insert (concat "\n@detailmenu\n" texinfo-master-menu-header)))) ;; @detailmenu added 5 Sept 1996 to `texinfo-master-menu-header' @@ -935,25 +939,25 @@ (while master-menu-list - (message - "Inserting menu for %s .... " (car (cdr (car master-menu-list)))) - ;; insert title of menu section - (insert "\n" (car (cdr (car master-menu-list))) "\n\n") + (message + "Inserting menu for %s .... " (car (cdr (car master-menu-list)))) + ;; insert title of menu section + (insert "\n" (car (cdr (car master-menu-list))) "\n\n") - ;; insert each menu entry - (setq this-very-menu-list (reverse (car (car master-menu-list)))) - (while this-very-menu-list - (insert "* " (car this-very-menu-list) "\n") - (setq this-very-menu-list (cdr this-very-menu-list))) + ;; insert each menu entry + (setq this-very-menu-list (reverse (car (car master-menu-list)))) + (while this-very-menu-list + (insert "* " (car this-very-menu-list) "\n") + (setq this-very-menu-list (cdr this-very-menu-list))) - (setq master-menu-list (cdr master-menu-list))) + (setq master-menu-list (cdr master-menu-list))) ;; Finish menu ;; @detailmenu (see note above) ;; Only insert @end detailmenu if a master menu was inserted. (if master-menu-inserted-p - (insert "\n@end detailmenu")) + (insert "\n@end detailmenu")) (insert "\n@end menu\n\n")))) (defun texinfo-locate-menu-p () @@ -969,47 +973,47 @@ (let ((case-fold-search t)) (save-excursion (if (re-search-backward - (concat - "\\(^@top" - "\\|" ; or - texinfo-section-types-regexp ; all other section types - "\\)") - nil - t) - (progn - (beginning-of-line) - (forward-word 1) ; skip over section type - (skip-chars-forward " \t") ; and over spaces - (buffer-substring - (point) - (progn (end-of-line) (point)))) - "")))) + (concat + "\\(^@top" + "\\|" ; or + texinfo-section-types-regexp ; all other section types + "\\)") + nil + t) + (progn + (beginning-of-line) + (forward-word 1) ; skip over section type + (skip-chars-forward " \t") ; and over spaces + (buffer-substring + (point) + (progn (end-of-line) (point)))) + "")))) (defun texinfo-copy-menu () "Return the entries of an existing menu as a list. Start with point just after the word `menu' in the `@menu' line and leave point on the line before the `@end menu' line." (let* (this-menu-list - (end-of-menu (texinfo-menu-end)) ; position of end of `@end menu' - (last-entry (save-excursion ; position of beginning of - ; last `* ' entry - (goto-char end-of-menu) - ;; handle multi-line description - (if (not (re-search-backward "^\\* " nil t)) - (error "No entries in menu.")) - (point)))) + (end-of-menu (texinfo-menu-end)) ; position of end of `@end menu' + (last-entry (save-excursion ; position of beginning of + ; last `* ' entry + (goto-char end-of-menu) + ;; handle multi-line description + (if (not (re-search-backward "^\\* " nil t)) + (error "No entries in menu.")) + (point)))) (while (< (point) last-entry) (if (re-search-forward "^\\* " end-of-menu t) - (progn - (setq this-menu-list - (cons - (buffer-substring - (point) - ;; copy multi-line descriptions - (save-excursion - (re-search-forward "\\(^\\* \\|^@e\\)" nil t) - (- (point) 3))) - this-menu-list))))) + (progn + (setq this-menu-list + (cons + (buffer-substring + (point) + ;; copy multi-line descriptions + (save-excursion + (re-search-forward "\\(^\\* \\|^@e\\)" nil t) + (- (point) 3))) + this-menu-list))))) this-menu-list)) @@ -1030,26 +1034,26 @@ ;;; (save-excursion ;;; (end-of-line) ;;; (point)) - nil - t) - "top") + nil + t) + "top") ((re-search-forward texinfo-section-types-regexp nil t) - (buffer-substring-no-properties + (buffer-substring-no-properties (progn (beginning-of-line) ; copy its name (1+ (point))) (progn (forward-word 1) (point)))) (t - (error - "texinfo-specific-section-type: Chapter or section not found.")))))) + (error + "texinfo-specific-section-type: Chapter or section not found.")))))) (defun texinfo-hierarchic-level () "Return the general hierarchal level of the next node in a texinfo file. Thus, a subheading or appendixsubsec is of type subsection." (let ((case-fold-search t)) (cdr (assoc - (texinfo-specific-section-type) - texinfo-section-to-generic-alist)))) + (texinfo-specific-section-type) + texinfo-section-to-generic-alist)))) ;;; Locating the major positions @@ -1065,25 +1069,25 @@ ;; higher level section. (cond ((or (string-equal "top" level) - (string-equal "chapter" level)) + (string-equal "chapter" level)) (save-excursion - (goto-char (point-min)) - (re-search-forward "^@node [ \t]*top[ \t]*\\(,\\|$\\)" nil t) - (beginning-of-line) - (point))) + (goto-char (point-min)) + (re-search-forward "^@node [ \t]*top[ \t]*\\(,\\|$\\)" nil t) + (beginning-of-line) + (point))) (t (save-excursion - (re-search-backward - (concat - "\\(^@node\\).*\n" ; match node line - "\\(\\(\\(^@c\\).*\n\\)" ; match comment line, if any - "\\|" ; or - "\\(^@ifinfo[ ]*\n\\)\\)?" ; ifinfo line, if any - (eval - (cdr (assoc level texinfo-update-menu-higher-regexps)))) - nil - 'goto-beginning) - (point)))))) + (re-search-backward + (concat + "\\(^@node\\).*\n" ; match node line + "\\(\\(\\(^@c\\).*\n\\)" ; match comment line, if any + "\\|" ; or + "\\(^@ifinfo[ ]*\n\\)\\)?" ; ifinfo line, if any + (eval + (cdr (assoc level texinfo-update-menu-higher-regexps)))) + nil + 'goto-beginning) + (point)))))) (defun texinfo-update-menu-region-end (level) "Locate end of higher level section this section is within. @@ -1094,18 +1098,18 @@ (let ((case-fold-search t)) (save-excursion (if (re-search-forward - (concat - "\\(^@node\\).*\n" ; match node line - "\\(\\(\\(^@c\\).*\n\\)" ; match comment line, if any - "\\|" ; or - "\\(^@ifinfo[ ]*\n\\)\\)?" ; ifinfo line, if any - (eval - ;; Never finds end of level above chapter so goes to end. - (cdr (assoc level texinfo-update-menu-higher-regexps)))) - nil - 'goto-end) - (match-beginning 1) - (point-max))))) + (concat + "\\(^@node\\).*\n" ; match node line + "\\(\\(\\(^@c\\).*\n\\)" ; match comment line, if any + "\\|" ; or + "\\(^@ifinfo[ ]*\n\\)\\)?" ; ifinfo line, if any + (eval + ;; Never finds end of level above chapter so goes to end. + (cdr (assoc level texinfo-update-menu-higher-regexps)))) + nil + 'goto-end) + (match-beginning 1) + (point-max))))) (defun texinfo-menu-first-node (beginning end) "Locate first node of the section the menu will be placed in. @@ -1284,10 +1288,10 @@ (if (null beginning) ;; Update a single node. (let ((auto-fill-function nil) (auto-fill-hook nil)) - (if (not (re-search-backward "^@node" (point-min) t)) - (error "Node line not found before this position")) - (texinfo-update-the-node) - (message "Done...updated the node. You may save the buffer.")) + (if (not (re-search-backward "^@node" (point-min) t)) + (error "Node line not found before this position")) + (texinfo-update-the-node) + (message "Done...updated the node. You may save the buffer.")) ;; else (let ((auto-fill-function nil) (auto-fill-hook nil)) @@ -1318,17 +1322,17 @@ (save-restriction (widen) (let* - ((case-fold-search t) - (level (texinfo-hierarchic-level)) - (beginning (texinfo-update-menu-region-beginning level)) - (end (texinfo-update-menu-region-end level))) + ((case-fold-search t) + (level (texinfo-hierarchic-level)) + (beginning (texinfo-update-menu-region-beginning level)) + (end (texinfo-update-menu-region-end level))) (if (string-equal level "top") - (texinfo-top-pointer-case) - ;; else - (texinfo-insert-pointer beginning end level 'next) - (texinfo-insert-pointer beginning end level 'previous) - (texinfo-insert-pointer beginning end level 'up) - (texinfo-clean-up-node-line))))) + (texinfo-top-pointer-case) + ;; else + (texinfo-insert-pointer beginning end level 'next) + (texinfo-insert-pointer beginning end level 'previous) + (texinfo-insert-pointer beginning end level 'up) + (texinfo-clean-up-node-line))))) (defun texinfo-top-pointer-case () "Insert pointers in the Top node. This is a special case. @@ -1340,18 +1344,18 @@ (texinfo-clean-up-node-line) (insert ", " - (save-excursion - ;; There may be an @chapter or other such command between - ;; the top node line and the next node line, as a title - ;; for an `ifinfo' section. This @chapter command must - ;; must be skipped. So the procedure is to search for - ;; the next `@node' line, and then copy its name. - (if (re-search-forward "^@node" nil t) - (progn - (beginning-of-line) - (texinfo-copy-node-name)) - " ")) - ", (dir), (dir)")) + (save-excursion + ;; There may be an @chapter or other such command between + ;; the top node line and the next node line, as a title + ;; for an `ifinfo' section. This @chapter command must + ;; must be skipped. So the procedure is to search for + ;; the next `@node' line, and then copy its name. + (if (re-search-forward "^@node" nil t) + (progn + (beginning-of-line) + (texinfo-copy-node-name)) + " ")) + ", (dir), (dir)")) (defun texinfo-check-for-node-name () "Determine whether the node has a node name. Prompt for one if not. @@ -1362,12 +1366,12 @@ (forward-word 1) ; skip over node command (skip-chars-forward " \t") ; and over spaces (if (not (looking-at "[^,\t\n ]+")) ; regexp based on what Info looks for - ; alternatively, use "[a-zA-Z]+" - (let ((node-name - (read-from-minibuffer - "Node name (use no @, commas, colons, or apostrophes): " - initial))) - (insert " " node-name)))))) + ; alternatively, use "[a-zA-Z]+" + (let ((node-name + (read-from-minibuffer + "Node name (use no @, commas, colons, or apostrophes): " + initial))) + (insert " " node-name)))))) (defun texinfo-delete-existing-pointers () "Delete `Next', `Previous', and `Up' pointers. @@ -1376,7 +1380,7 @@ line, including the comma. Leaves point at beginning of line." (let ((eol-point (save-excursion (end-of-line) (point)))) (if (search-forward "," eol-point t) - (delete-region (1- (point)) eol-point))) + (delete-region (1- (point)) eol-point))) (beginning-of-line)) (defun texinfo-find-pointer (beginning end level direction) @@ -1396,84 +1400,84 @@ `Next', `Previous', or `Up' pointer." (let ((case-fold-search t)) (cond ((eq direction 'next) - (forward-line 3) ; skip over current node - ;; Search for section commands accompanied by node lines; - ;; ignore section commands in the middle of nodes. - (if (re-search-forward - ;; A `Top' node is never a next pointer, so won't find it. - (concat - ;; Match node line. - "\\(^@node\\).*\n" - ;; Match comment or ifinfo line, if any - "\\(\\(\\(^@c\\).*\n\\)\\|\\(^@ifinfo[ ]*\n\\)\\)?" - (eval - (cdr (assoc level texinfo-update-menu-same-level-regexps)))) - end - t) - 'normal - 'no-pointer)) - ((eq direction 'previous) - (if (re-search-backward - (concat - "\\(" - ;; Match node line. - "\\(^@node\\).*\n" - ;; Match comment or ifinfo line, if any - "\\(\\(\\(^@c\\).*\n\\)\\|\\(^@ifinfo[ ]*\n\\)\\)?" - (eval - (cdr (assoc level texinfo-update-menu-same-level-regexps))) - "\\|" - ;; Match node line. - "\\(^@node\\).*\n" - ;; Match comment or ifinfo line, if any - "\\(\\(\\(^@c\\).*\n\\)\\|\\(^@ifinfo[ ]*\n\\)\\)?" - (eval - (cdr (assoc level texinfo-update-menu-higher-regexps))) - "\\|" - ;; Handle `Top' node specially. - "^@node [ \t]*top[ \t]*\\(,\\|$\\)" - "\\)") - beginning - t) - 'normal - 'no-pointer)) - ((eq direction 'up) - (if (re-search-backward - (concat - "\\(" - ;; Match node line. - "\\(^@node\\).*\n" - ;; Match comment or ifinfo line, if any - "\\(\\(\\(^@c\\).*\n\\)\\|\\(^@ifinfo[ ]*\n\\)\\)?" - (eval (cdr (assoc level texinfo-update-menu-higher-regexps))) - "\\|" - ;; Handle `Top' node specially. - "^@node [ \t]*top[ \t]*\\(,\\|$\\)" - "\\)") - (save-excursion - (goto-char beginning) - (beginning-of-line) - (point)) - t) - 'normal - 'no-pointer)) - (t - (error "texinfo-find-pointer: lack proper arguments"))))) + (forward-line 3) ; skip over current node + ;; Search for section commands accompanied by node lines; + ;; ignore section commands in the middle of nodes. + (if (re-search-forward + ;; A `Top' node is never a next pointer, so won't find it. + (concat + ;; Match node line. + "\\(^@node\\).*\n" + ;; Match comment or ifinfo line, if any + "\\(\\(\\(^@c\\).*\n\\)\\|\\(^@ifinfo[ ]*\n\\)\\)?" + (eval + (cdr (assoc level texinfo-update-menu-same-level-regexps)))) + end + t) + 'normal + 'no-pointer)) + ((eq direction 'previous) + (if (re-search-backward + (concat + "\\(" + ;; Match node line. + "\\(^@node\\).*\n" + ;; Match comment or ifinfo line, if any + "\\(\\(\\(^@c\\).*\n\\)\\|\\(^@ifinfo[ ]*\n\\)\\)?" + (eval + (cdr (assoc level texinfo-update-menu-same-level-regexps))) + "\\|" + ;; Match node line. + "\\(^@node\\).*\n" + ;; Match comment or ifinfo line, if any + "\\(\\(\\(^@c\\).*\n\\)\\|\\(^@ifinfo[ ]*\n\\)\\)?" + (eval + (cdr (assoc level texinfo-update-menu-higher-regexps))) + "\\|" + ;; Handle `Top' node specially. + "^@node [ \t]*top[ \t]*\\(,\\|$\\)" + "\\)") + beginning + t) + 'normal + 'no-pointer)) + ((eq direction 'up) + (if (re-search-backward + (concat + "\\(" + ;; Match node line. + "\\(^@node\\).*\n" + ;; Match comment or ifinfo line, if any + "\\(\\(\\(^@c\\).*\n\\)\\|\\(^@ifinfo[ ]*\n\\)\\)?" + (eval (cdr (assoc level texinfo-update-menu-higher-regexps))) + "\\|" + ;; Handle `Top' node specially. + "^@node [ \t]*top[ \t]*\\(,\\|$\\)" + "\\)") + (save-excursion + (goto-char beginning) + (beginning-of-line) + (point)) + t) + 'normal + 'no-pointer)) + (t + (error "texinfo-find-pointer: lack proper arguments"))))) (defun texinfo-pointer-name (kind) "Return the node name preceding the section command. The argument is the kind of section, either `normal' or `no-pointer'." (let (name) (cond ((eq kind 'normal) - (end-of-line) ; this handles prev node top case - (re-search-backward ; when point is already - "^@node" ; at the beginning of @node line - (save-excursion (forward-line -3)) - t) - (setq name (texinfo-copy-node-name))) + (end-of-line) ; this handles prev node top case + (re-search-backward ; when point is already + "^@node" ; at the beginning of @node line + (save-excursion (forward-line -3)) + t) + (setq name (texinfo-copy-node-name))) ((eq kind 'no-pointer) - ;; Don't need to put a blank in the pointer slot, - ;; since insert "' " always has a space + ;; Don't need to put a blank in the pointer slot, + ;; since insert "' " always has a space (setq name " "))) ; put a blank in the pointer slot name)) @@ -1532,49 +1536,49 @@ (if (not region-p) ;; update a single node (let ((auto-fill-function nil) (auto-fill-hook nil)) - (if (not (re-search-backward "^@node" (point-min) t)) - (error "Node line not found before this position.")) - (texinfo-sequentially-update-the-node) - (message - "Done...sequentially updated the node . You may save the buffer.")) + (if (not (re-search-backward "^@node" (point-min) t)) + (error "Node line not found before this position.")) + (texinfo-sequentially-update-the-node) + (message + "Done...sequentially updated the node . You may save the buffer.")) ;; else (let ((auto-fill-function nil) (auto-fill-hook nil) - (beginning (region-beginning)) - (end (region-end))) + (beginning (region-beginning)) + (end (region-end))) (if (= end beginning) - (error "Please mark a region!")) + (error "Please mark a region!")) (save-restriction - (narrow-to-region beginning end) - (goto-char beginning) - (push-mark (point) t) - (while (re-search-forward "^@node" (point-max) t) - (beginning-of-line) - (texinfo-sequentially-update-the-node)) - (message - "Done...updated the nodes in sequence. You may save the buffer."))))) + (narrow-to-region beginning end) + (goto-char beginning) + (push-mark (point) t) + (while (re-search-forward "^@node" (point-max) t) + (beginning-of-line) + (texinfo-sequentially-update-the-node)) + (message + "Done...updated the nodes in sequence. You may save the buffer."))))) (defun texinfo-sequentially-update-the-node () "Update one node such that the pointers are sequential. A `Next' or `Previous' pointer points to any preceding or following node, regardless of its hierarchical level." - (texinfo-check-for-node-name) - (texinfo-delete-existing-pointers) - (message - "Sequentially updating node: %s ... " (texinfo-copy-node-name)) - (save-restriction - (widen) - (let* - ((case-fold-search t) - (level (texinfo-hierarchic-level))) - (if (string-equal level "top") - (texinfo-top-pointer-case) - ;; else - (texinfo-sequentially-insert-pointer level 'next) - (texinfo-sequentially-insert-pointer level 'previous) - (texinfo-sequentially-insert-pointer level 'up) - (texinfo-clean-up-node-line))))) + (texinfo-check-for-node-name) + (texinfo-delete-existing-pointers) + (message + "Sequentially updating node: %s ... " (texinfo-copy-node-name)) + (save-restriction + (widen) + (let* + ((case-fold-search t) + (level (texinfo-hierarchic-level))) + (if (string-equal level "top") + (texinfo-top-pointer-case) + ;; else + (texinfo-sequentially-insert-pointer level 'next) + (texinfo-sequentially-insert-pointer level 'previous) + (texinfo-sequentially-insert-pointer level 'up) + (texinfo-clean-up-node-line))))) (defun texinfo-sequentially-find-pointer (level direction) "Find next or previous pointer sequentially in Texinfo file, or up pointer. @@ -1591,29 +1595,29 @@ or `Up' pointer." (let ((case-fold-search t)) (cond ((eq direction 'next) - (forward-line 3) ; skip over current node - (if (re-search-forward - texinfo-section-types-regexp - (point-max) - t) - 'normal - 'no-pointer)) - ((eq direction 'previous) - (if (re-search-backward - texinfo-section-types-regexp - (point-min) - t) - 'normal - 'no-pointer)) - ((eq direction 'up) - (if (re-search-backward - (eval (cdr (assoc level texinfo-update-menu-higher-regexps))) - beginning - t) - 'normal - 'no-pointer)) - (t - (error "texinfo-sequential-find-pointer: lack proper arguments"))))) + (forward-line 3) ; skip over current node + (if (re-search-forward + texinfo-section-types-regexp + (point-max) + t) + 'normal + 'no-pointer)) + ((eq direction 'previous) + (if (re-search-backward + texinfo-section-types-regexp + (point-min) + t) + 'normal + 'no-pointer)) + ((eq direction 'up) + (if (re-search-backward + (eval (cdr (assoc level texinfo-update-menu-higher-regexps))) + beginning + t) + 'normal + 'no-pointer)) + (t + (error "texinfo-sequential-find-pointer: lack proper arguments"))))) (defun texinfo-sequentially-insert-pointer (level direction) "Insert the `Next', `Previous' or `Up' node name at point. @@ -1654,46 +1658,46 @@ (goto-char beginning) (while (re-search-forward - texinfo-section-types-regexp - end-marker - 'end) + texinfo-section-types-regexp + end-marker + 'end) ;; Copy title if desired. (if title-p - (progn - (beginning-of-line) - (forward-word 1) - (skip-chars-forward " \t") - (setq title (buffer-substring - (point) - (save-excursion (end-of-line) (point)))))) + (progn + (beginning-of-line) + (forward-word 1) + (skip-chars-forward " \t") + (setq title (buffer-substring + (point) + (save-excursion (end-of-line) (point)))))) ;; Insert node line if necessary. (if (re-search-backward - "^@node" - ;; Avoid finding previous node line if node lines are close. - (or last-section-position - (save-excursion (forward-line -2) (point))) t) - ;; @node is present, and point at beginning of that line - (forward-word 1) ; Leave point just after @node. - ;; Else @node missing; insert one. - (beginning-of-line) ; Beginning of `@section' line. - (insert "@node\n") - (backward-char 1)) ; Leave point just after `@node'. + "^@node" + ;; Avoid finding previous node line if node lines are close. + (or last-section-position + (save-excursion (forward-line -2) (point))) t) + ;; @node is present, and point at beginning of that line + (forward-word 1) ; Leave point just after @node. + ;; Else @node missing; insert one. + (beginning-of-line) ; Beginning of `@section' line. + (insert "@node\n") + (backward-char 1)) ; Leave point just after `@node'. ;; Insert title if desired. (if title-p - (progn - (skip-chars-forward " \t") - ;; Use regexp based on what info looks for - ;; (alternatively, use "[a-zA-Z]+"); - ;; this means we only insert a title if none exists. - (if (not (looking-at "[^,\t\n ]+")) - (progn - (beginning-of-line) - (forward-word 1) - (insert " " title) - (message "Inserted title %s ... " title))))) + (progn + (skip-chars-forward " \t") + ;; Use regexp based on what info looks for + ;; (alternatively, use "[a-zA-Z]+"); + ;; this means we only insert a title if none exists. + (if (not (looking-at "[^,\t\n ]+")) + (progn + (beginning-of-line) + (forward-word 1) + (insert " " title) + (message "Inserted title %s ... " title))))) ;; Go forward beyond current section title. (re-search-forward texinfo-section-types-regexp - (save-excursion (forward-line 3) (point)) t) + (save-excursion (forward-line 3) (point)) t) (setq last-section-position (point)) (forward-line 1)) @@ -1740,19 +1744,19 @@ (defun texinfo-multi-file-included-list (outer-file) "Return a list of the included files in OUTER-FILE." (let ((included-file-list (list outer-file)) - start) + start) (save-excursion (switch-to-buffer (find-file-noselect outer-file)) (widen) (goto-char (point-min)) (while (re-search-forward "^@include" nil t) - (skip-chars-forward " \t") - (setq start (point)) - (end-of-line) - (skip-chars-backward " \t") - (setq included-file-list - (cons (buffer-substring start (point)) - included-file-list))) + (skip-chars-forward " \t") + (setq start (point)) + (end-of-line) + (skip-chars-backward " \t") + (setq included-file-list + (cons (buffer-substring start (point)) + included-file-list))) (nreverse included-file-list)))) (defun texinfo-copy-next-section-title () @@ -1764,22 +1768,22 @@ (save-excursion (end-of-line) (let ((node-end (or - (save-excursion - (if (re-search-forward "\\(^@node\\)" nil t) - (match-beginning 0))) - (point-max)))) + (save-excursion + (if (re-search-forward "\\(^@node\\)" nil t) + (match-beginning 0))) + (point-max)))) (if (re-search-forward texinfo-section-types-regexp node-end t) - (progn - (beginning-of-line) - ;; copy title - (let ((title - (buffer-substring - (progn (forward-word 1) ; skip over section type - (skip-chars-forward " \t") ; and over spaces - (point)) - (progn (end-of-line) (point))))) - title)) - "")))) + (progn + (beginning-of-line) + ;; copy title + (let ((title + (buffer-substring + (progn (forward-word 1) ; skip over section type + (skip-chars-forward " \t") ; and over spaces + (point)) + (progn (end-of-line) (point))))) + title)) + "")))) (defun texinfo-multi-file-update (files &optional update-everything) "Update first node pointers in each file in FILES. @@ -1814,31 +1818,31 @@ ;; description slot of a menu as a description. (let ((case-fold-search t) - menu-list) + menu-list) ;; Find the name of the first node of the first included file. (switch-to-buffer (find-file-noselect (car (cdr files)))) (widen) (goto-char (point-min)) (if (not (re-search-forward "^@node" nil t)) - (error "No `@node' line found in %s !" (buffer-name))) + (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)) (setq menu-list - (cons (cons - next-node-name - (prog1 "" (forward-line 1))) - ;; Use following to insert section titles automatically. - ;; (texinfo-copy-next-section-title) - menu-list)) + (cons (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 (switch-to-buffer (find-file-noselect (car files))) (goto-char (point-min)) (if (not (re-search-forward "^@node [ \t]*top[ \t]*\\(,\\|$\\)" nil t)) - (error "This buffer needs a Top node!")) + (error "This buffer needs a Top node!")) (beginning-of-line) (texinfo-delete-existing-pointers) (end-of-line) @@ -1850,31 +1854,31 @@ (while files (if (not (cdr files)) - ;; No next file - (setq next-node-name "") - ;; Else, - ;; find the name of the first node in the next file. - (switch-to-buffer (find-file-noselect (car (cdr files)))) - (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)) - (setq menu-list - (cons (cons - next-node-name - (prog1 "" (forward-line 1))) - ;; Use following to insert section titles automatically. - ;; (texinfo-copy-next-section-title) - menu-list))) + ;; No next file + (setq next-node-name "") + ;; Else, + ;; find the name of the first node in the next file. + (switch-to-buffer (find-file-noselect (car (cdr files)))) + (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)) + (setq menu-list + (cons (cons + next-node-name + (prog1 "" (forward-line 1))) + ;; Use following to insert section titles automatically. + ;; (texinfo-copy-next-section-title) + menu-list))) ;; Go to node to be updated. (switch-to-buffer (find-file-noselect (car files))) (goto-char (point-min)) (if (not (re-search-forward "^@node" nil t)) - (error "No `@node' line found in %s !" (buffer-name))) + (error "No `@node' line found in %s !" (buffer-name))) (beginning-of-line) ;; Update other menus and nodes if requested. @@ -1904,18 +1908,18 @@ ;; Insert the node name (and menu entry name, if present). (let ((node-part (car (car menu-list)))) (if (stringp node-part) - ;; "Double colon" entry line; menu entry and node name are the same, - (insert (format "%s::" node-part)) - ;; "Single colon" entry line; menu entry and node name are different. - (insert (format "%s: %s." (car node-part) (cdr node-part))))) + ;; "Double colon" entry line; menu entry and node name are the same, + (insert (format "%s::" node-part)) + ;; "Single colon" entry line; menu entry and node name are different. + (insert (format "%s: %s." (car node-part) (cdr node-part))))) ;; Insert the description, if present. (if (cdr (car menu-list)) - (progn - ;; Move to right place. - (indent-to texinfo-column-for-description 2) - ;; Insert description. - (insert (format "%s" (cdr (car menu-list)))))) + (progn + ;; Move to right place. + (indent-to texinfo-column-for-description 2) + ;; Insert description. + (insert (format "%s" (cdr (car menu-list)))))) (insert "\n") ; end this menu entry (setq menu-list (cdr menu-list))) @@ -1930,12 +1934,12 @@ (save-excursion (let (master-menu-list) (while files-list - (switch-to-buffer (find-file-noselect (car files-list))) - (message "Working on: %s " (current-buffer)) - (goto-char (point-min)) - (setq master-menu-list - (append master-menu-list (texinfo-master-menu-list))) - (setq files-list (cdr files-list))) + (switch-to-buffer (find-file-noselect (car files-list))) + (message "Working on: %s " (current-buffer)) + (goto-char (point-min)) + (setq master-menu-list + (append master-menu-list (texinfo-master-menu-list))) + (setq files-list (cdr files-list))) master-menu-list))) @@ -1981,23 +1985,23 @@ chapter." (interactive (cons - (read-string - "Name of outer `include' file: " - (buffer-file-name)) - (cond ((not current-prefix-arg) - '(nil nil)) - ((listp current-prefix-arg) - '(t nil)) ; make-master-menu - ((numberp current-prefix-arg) - '(t t)) ; update-everything - ))) + (read-string + "Name of outer `include' file: " + (buffer-file-name)) + (cond ((not current-prefix-arg) + '(nil nil)) + ((listp current-prefix-arg) + '(t nil)) ; make-master-menu + ((numberp current-prefix-arg) + '(t t)) ; update-everything + ))) (let* ((included-file-list (texinfo-multi-file-included-list outer-file)) - (files included-file-list) - main-menu-list - next-node-name - previous-node-name - (up-node-name "Top")) + (files included-file-list) + main-menu-list + next-node-name + previous-node-name + (up-node-name "Top")) ;;; Update the pointers ;;; and collect the names of the nodes and titles @@ -2010,20 +2014,20 @@ (if (texinfo-old-menu-p (point-min) (save-excursion - (re-search-forward "^@include") - (beginning-of-line) - (point))) + (re-search-forward "^@include") + (beginning-of-line) + (point))) ;; If found, leave point after word `menu' on the `@menu' line. (progn - (texinfo-incorporate-descriptions main-menu-list) - ;; Delete existing menu. - (beginning-of-line) - (delete-region - (point) - (save-excursion (re-search-forward "^@end menu") (point))) - ;; Insert main menu - (texinfo-multi-files-insert-main-menu main-menu-list)) + (texinfo-incorporate-descriptions main-menu-list) + ;; Delete existing menu. + (beginning-of-line) + (delete-region + (point) + (save-excursion (re-search-forward "^@end menu") (point))) + ;; Insert main menu + (texinfo-multi-files-insert-main-menu main-menu-list)) ;; Else no current menu; insert it before `@include' (texinfo-multi-files-insert-main-menu main-menu-list)) @@ -2032,28 +2036,28 @@ (if make-master-menu (progn - ;; First, removing detailed part of any pre-existing master menu - (goto-char (point-min)) - (if (search-forward texinfo-master-menu-header nil t) - (progn - (goto-char (match-beginning 0)) + ;; First, removing detailed part of any pre-existing master menu + (goto-char (point-min)) + (if (search-forward texinfo-master-menu-header nil t) + (progn + (goto-char (match-beginning 0)) ;; Check if @detailmenu kludge is used; ;; if so, leave point before @detailmenu. (search-backward "\n@detailmenu" (save-excursion (forward-line -3) (point)) t) ;; Remove detailed master menu listing - (let ((end-of-detailed-menu-descriptions - (save-excursion ; beginning of end menu line - (goto-char (texinfo-menu-end)) - (beginning-of-line) (forward-char -1) - (point)))) - (delete-region (point) end-of-detailed-menu-descriptions)))) + (let ((end-of-detailed-menu-descriptions + (save-excursion ; beginning of end menu line + (goto-char (texinfo-menu-end)) + (beginning-of-line) (forward-char -1) + (point)))) + (delete-region (point) end-of-detailed-menu-descriptions)))) - ;; Create a master menu and insert it - (texinfo-insert-master-menu-list - (texinfo-multi-file-master-menu-list - included-file-list))))) + ;; Create a master menu and insert it + (texinfo-insert-master-menu-list + (texinfo-multi-file-master-menu-list + included-file-list))))) ;; Remove unwanted extra lines. (save-excursion