Mercurial > emacs
annotate lisp/textmodes/texnfo-upd.el @ 3345:38168270a9ca
(do-install): Copy the DOC-* files from the build
etc directory, as well as lots of things from ${srcdir}/etc.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 31 May 1993 06:07:08 +0000 |
parents | 2cdce064065f |
children | 507f64624555 |
rev | line source |
---|---|
657
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
1 ;;; texnfo-upd.el --- a utility for updating nodes and menus in Texinfo files. |
107 | 2 |
841 | 3 ;;;; Copyright 1989, 1990, 1992 Free Software Foundation |
4 | |
775
1ca26ccad38e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
732
diff
changeset
|
5 ;; Author: Bob Chassell <bob@gnu.ai.mit.edu> |
1ca26ccad38e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
732
diff
changeset
|
6 ;; Version: 2.00 |
814
38b2499cb3e9
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
775
diff
changeset
|
7 ;; Keywords: maint, tex, docs |
107 | 8 |
9 ;; This file is part of GNU Emacs. | |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
732 | 13 ;; the Free Software Foundation; either version 2, or (at your option) |
107 | 14 ;; any later version. |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
22 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
23 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
24 | |
775
1ca26ccad38e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
732
diff
changeset
|
25 ;;; Commentary: |
107 | 26 |
27 ;;;; Summary | |
28 | |
29 ; (Much of the following commentary ought eventually be incorporated | |
30 ; into the Texinfo Manual.) | |
31 | |
32 ; The node and menu updating functions automatically | |
33 | |
34 ; * insert missing `@node' lines, | |
35 ; * insert the `Next', `Previous' and `Up' pointers of a node, | |
36 ; * insert or update the menu for a section, | |
37 ; * create a master menu for a Texinfo source file. | |
38 | |
39 ; Passed an argument, the `texinfo-update-node' and | |
40 ; `texinfo-make-menu' functions do their jobs in the region. | |
41 | |
42 ; These functions replace doing these jobs by hand. | |
43 ; You may find them helpful. | |
44 | |
45 ; In brief, the functions for creating or updating nodes and menus, are: | |
46 ; | |
47 ; texinfo-update-node (&optional region-p) | |
48 ; texinfo-every-node-update () | |
49 ; texinfo-sequential-node-update (&optional region-p) | |
50 ; | |
51 ; texinfo-make-menu (&optional region-p) | |
52 ; texinfo-all-menus-update () | |
53 ; texinfo-master-menu () | |
54 ; | |
55 ; texinfo-insert-node-lines (&optional title-p) | |
56 ; | |
57 ; texinfo-indent-menu-description (column &optional region-p) | |
58 | |
59 ; The `texinfo-column-for-description' variable specifies the column to | |
60 ; which menu descriptions are indented. | |
61 | |
62 ; Texinfo file structure | |
63 ; ---------------------- | |
64 | |
65 ; To use the updating commands, you must structure your Texinfo file | |
66 ; hierarchically. Each `@node' line, with the exception of the top | |
67 ; node, must be accompanied by some kind of section line, such as an | |
68 ; `@chapter' or `@section' line. Each node-line/section-line | |
69 ; combination must look like this: | |
70 | |
71 ; @node Lists and Tables, Cross References, Structuring, Top | |
72 ; @comment node-name, next, previous, up | |
73 ; @chapter Making Lists and Tables | |
74 | |
75 ; or like this (without the `@comment' line): | |
76 | |
77 ; @node Lists and Tables, Cross References, Structuring, Top | |
78 ; @chapter Making Lists and Tables | |
79 | |
80 ; If the file has a `top' node, it must be called `top' or `Top' and | |
81 ; be the first node in the file. | |
82 | |
83 | |
84 ;;;; The updating functions in detail | |
85 ; -------------------------------- | |
86 | |
87 ; The `texinfo-update-node' function without an argument inserts | |
88 ; the correct next, previous and up pointers for the node in which | |
89 ; point is located (i.e., for the node preceding point). | |
90 | |
91 ; With an argument, the `texinfo-update-node' function inserts the | |
92 ; correct next, previous and up pointers for the nodes inside the | |
93 ; region. | |
94 | |
95 ; It does not matter whether the `@node' line has pre-existing | |
96 ; `Next', `Previous', or `Up' pointers in it. They are removed. | |
97 | |
98 ; The `texinfo-every-node-update' function runs `texinfo-update-node' | |
99 ; on the whole buffer. | |
100 | |
101 ; The `texinfo-update-node' function inserts the immediately following | |
102 ; and preceding node into the `Next' or `Previous' pointers regardless | |
103 ; of their hierarchical level. This is only useful for certain kinds | |
104 ; of text, like a novel, which you go through sequentially. | |
105 | |
106 ; The `texinfo-make-menu' function without an argument creates or | |
107 ; updates a menu for the section encompassing the node that follows | |
108 ; point. With an argument, it makes or updates menus for the nodes | |
109 ; within or part of the marked region. | |
110 | |
111 ; Whenever an existing menu is updated, the descriptions from | |
112 ; that menu are incorporated into the new menu. This is done by copying | |
113 ; descriptions from the existing menu to the entries in the new menu | |
114 ; that have the same node names. If the node names are different, the | |
115 ; descriptions are not copied to the new menu. | |
116 | |
117 ; Menu entries that refer to other Info files are removed since they | |
118 ; are not a node within current buffer. This is a deficiency. | |
119 | |
120 ; The `texinfo-all-menus-update' function runs `texinfo-make-menu' | |
121 ; on the whole buffer. | |
122 | |
123 ; The `texinfo-master-menu' function creates an extended menu located | |
124 ; after the top node. (The file must have a top node.) The function | |
125 ; first updates all the regular menus in the buffer (incorporating the | |
126 ; descriptions from pre-existing menus), and then constructs a master | |
127 ; menu that includes every entry from every other menu. (However, the | |
128 ; function cannot update an already existing master menu; if one | |
129 ; exists, it must be removed before calling the function.) | |
130 | |
131 ; The `texinfo-indent-menu-description' function indents every | |
132 ; description in the menu following point, to the specified column. | |
133 ; Non-nil argument (prefix, if interactive) means indent every | |
134 ; description in every menu in the region. This function does not | |
135 ; indent second and subsequent lines of a multi-line description. | |
136 | |
137 ; The `texinfo-insert-node-lines' function inserts `@node' before the | |
138 ; `@chapter', `@section', and such like lines of a region in a Texinfo | |
139 ; file where the `@node' lines are missing. | |
140 ; | |
141 ; With a non-nil argument (prefix, if interactive), the function not | |
142 ; only inserts `@node' lines but also inserts the chapter or section | |
143 ; titles as the names of the corresponding nodes; and inserts titles | |
144 ; as node names in pre-existing `@node' lines that lack names. | |
145 ; | |
146 ; Since node names should be more concise than section or chapter | |
147 ; titles, node names so inserted will need to be edited manually. | |
148 | |
775
1ca26ccad38e
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
732
diff
changeset
|
149 ;;; Code: |
107 | 150 |
151 ;;;; Menu Making Functions | |
152 | |
153 (defun texinfo-make-menu (&optional region-p) | |
154 "Without any prefix argument, make or update a menu. | |
155 Make the menu for the section enclosing the node found following point. | |
156 | |
157 Non-nil argument (prefix, if interactive) means make or update menus | |
158 for nodes within or part of the marked region. | |
159 | |
160 Whenever a menu exists, and is being updated, the descriptions that | |
161 are associated with node names in the pre-existing menu are | |
162 incorporated into the new menu. Otherwise, the nodes' section titles | |
163 are inserted as descriptions." | |
164 | |
165 (interactive "P") | |
166 (if (not region-p) | |
167 (let ((level (texinfo-hierarchic-level))) | |
168 (texinfo-make-one-menu level) | |
169 (message "Done...updated the menu. You may save the buffer.")) | |
170 ;; else | |
171 (message "Making or updating menus... ") | |
172 (let ((beginning (region-beginning)) | |
173 (region-end (region-end)) | |
174 (level (progn ; find section type following point | |
175 (goto-char (region-beginning)) | |
176 (texinfo-hierarchic-level)))) | |
177 (if (= region-end beginning) | |
178 (error "Please mark a region!")) | |
179 (save-excursion | |
180 (save-restriction | |
181 (widen) | |
182 | |
183 (while (texinfo-find-lower-level-node level region-end) | |
184 (setq level (texinfo-hierarchic-level)) ; new, lower level | |
185 (texinfo-make-one-menu level)) | |
186 | |
187 (while (and (< (point) region-end) | |
188 (texinfo-find-higher-level-node level region-end)) | |
189 (setq level (texinfo-hierarchic-level)) | |
190 (while (texinfo-find-lower-level-node level region-end) | |
191 (setq level (texinfo-hierarchic-level)) ; new, lower level | |
192 (texinfo-make-one-menu level)))))) | |
193 (message "Done...updated menus. You may save the buffer."))) | |
194 | |
195 (defun texinfo-make-one-menu (level) | |
196 "Make a menu of all the appropriate nodes in this section. | |
197 `Appropriate nodes' are those associated with sections that are | |
198 at the level specified by LEVEL. Point is left at the end of menu." | |
199 (let* | |
200 ((case-fold-search t) | |
143 | 201 (beginning |
202 (save-excursion | |
203 (goto-char (texinfo-update-menu-region-beginning level)) | |
204 (end-of-line) | |
205 (point))) | |
107 | 206 (end (texinfo-update-menu-region-end level)) |
207 (first (texinfo-menu-first-node beginning end)) | |
208 (node-name (progn | |
209 (goto-char beginning) | |
210 (texinfo-copy-node-name))) | |
211 (new-menu-list (texinfo-make-menu-list beginning end level))) | |
212 (if (texinfo-old-menu-p beginning first) | |
213 (progn | |
214 (texinfo-incorporate-descriptions new-menu-list) | |
215 (texinfo-delete-old-menu beginning first))) | |
216 (texinfo-insert-menu new-menu-list node-name))) | |
217 | |
218 (defun texinfo-all-menus-update (&optional update-all-nodes-p) | |
219 "Update every regular menu in a Texinfo file. | |
220 You must remove the detailed part of a pre-existing master menu before | |
221 running this command, lest it be partly duplicated. | |
222 | |
223 If called with a non-nil argument, this function first updates all the | |
224 nodes in the buffer before updating the menus." | |
225 (interactive "P") | |
226 (save-excursion | |
227 (mark-whole-buffer) | |
228 (message "Checking for a master menu... ") | |
229 (save-excursion | |
230 (if (re-search-forward texinfo-master-menu-header nil t) | |
231 (error | |
232 "Please remove existing master menu, lest it be partly duplicated!"))) | |
233 | |
234 (if update-all-nodes-p | |
235 (progn | |
236 (message "First updating all nodes... ") | |
237 (sleep-for 2) | |
238 (mark-whole-buffer) | |
239 (texinfo-update-node t))) | |
240 | |
241 (message "Updating all menus... ") | |
242 (sleep-for 2) | |
243 (texinfo-make-menu t) | |
244 (message "Done...updated all the menus. You may save the buffer."))) | |
245 | |
246 (defun texinfo-find-lower-level-node (level region-end) | |
247 "Search forward from point for node at any level lower than LEVEL. | |
248 Search is limited to the end of the marked region, REGION-END, | |
249 and to the end of the menu region for the level. | |
250 | |
251 Return t if the node is found, else nil. Leave point at the beginning | |
252 of the node if one is found; else do not move point." | |
253 | |
254 (if (and (< (point) region-end) | |
255 (re-search-forward | |
256 (concat | |
257 "\\(^@node\\).*\n" ; match node line | |
258 "\\(\\(\\(^@c\\).*\n\\)" ; match comment line, if any | |
259 "\\|" ; or | |
260 "\\(^@ifinfo[ ]*\n\\)\\)?" ; ifinfo line, if any | |
261 (eval (cdr (assoc level texinfo-update-menu-lower-regexps)))) | |
262 ;; the next higher level node marks the end of this | |
263 ;; section, and no lower level node will be found beyond | |
264 ;; this position even if region-end is farther off | |
265 (texinfo-update-menu-region-end level) | |
266 t)) | |
267 (goto-char (match-beginning 1)))) | |
268 | |
269 (defun texinfo-find-higher-level-node (level region-end) | |
270 "Search forward from point for node at any higher level than argument LEVEL. | |
271 Search is limited to the end of the marked region, REGION-END. | |
272 | |
273 Return t if the node is found, else nil. Leave point at the beginning | |
274 of the node if one is found; else do not move point." | |
275 | |
276 (if (and (< (point) region-end) | |
277 (re-search-forward | |
278 (concat | |
279 "\\(^@node\\).*\n" ; match node line | |
280 "\\(\\(\\(^@c\\).*\n\\)" ; match comment line, if any | |
281 "\\|" ; or | |
282 "\\(^@ifinfo[ ]*\n\\)\\)?" ; ifinfo line, if any | |
283 (eval ; (won't ever find a `top' node) | |
284 (cdr (assoc level texinfo-update-menu-higher-regexps)))) | |
285 nil | |
286 t)) | |
287 (goto-char (match-beginning 1)))) | |
288 | |
289 | |
290 ;;;; Making the list of new menu entries | |
291 | |
292 (defun texinfo-make-menu-list (beginning end level) | |
293 "Make a list of node names and their descriptions. | |
294 Point is left at the end of the menu region, but the menu is not inserted. | |
295 | |
296 First argument is position from which to start making menu list; | |
297 second argument is end of region in which to try to locate entries; | |
298 third argument is the level of the nodes that are the entries. | |
299 | |
300 Node names and descriptions are dotted pairs of strings. Each pair is | |
301 an element of the list. If the description does not exist, the | |
302 element consists only of the node name." | |
303 (goto-char beginning) | |
304 (let (new-menu-list) | |
305 (while (texinfo-menu-locate-entry-p level end) | |
306 (setq new-menu-list | |
307 (cons (cons | |
308 (texinfo-copy-node-name) | |
309 (texinfo-copy-section-title)) | |
310 new-menu-list))) | |
311 (reverse new-menu-list))) | |
312 | |
313 (defun texinfo-menu-locate-entry-p (level search-end) | |
314 "Find a node that will be part of menu for this section. | |
315 First argument is a string such as \"section\" specifying the general | |
316 hierarchical level of the menu; second argument is a postion | |
317 specifying the end of the search. | |
318 | |
319 The function returns t if the node is found, else nil. It searches | |
320 forward from point, and leaves point at the beginning of the node. | |
321 | |
322 The function finds entries of the same type. Thus `subsections' and | |
323 `unnumberedsubsecs' will appear in the same menu." | |
324 (if (re-search-forward | |
325 (concat | |
326 "\\(^@node\\).*\n" ; match node line | |
327 "\\(\\(\\(^@c\\).*\n\\)" ; match comment line, if any | |
328 "\\|" ; or | |
329 "\\(^@ifinfo[ ]*\n\\)\\)?" ; ifinfo line, if any | |
330 (eval | |
331 (cdr (assoc level texinfo-update-menu-same-level-regexps)))) | |
332 search-end | |
333 t) | |
334 (goto-char (match-beginning 1)))) | |
335 | |
336 (defun texinfo-copy-node-name () | |
337 "Return the node name as a string. | |
338 | |
339 Start with point at the beginning of the node line; copy the text | |
340 after the node command up to the first comma on the line, if any, and | |
341 return the text as a string. Leaves point at the beginning of the | |
342 line. If there is no node name, returns an empty string." | |
343 | |
344 (save-excursion | |
345 (buffer-substring | |
346 (progn (forward-word 1) ; skip over node command | |
347 (skip-chars-forward " \t") ; and over spaces | |
348 (point)) | |
349 (if (search-forward | |
350 "," | |
351 (save-excursion (end-of-line) (point)) t) ; bound search | |
352 (1- (point)) | |
353 (end-of-line) (point))))) | |
354 | |
355 (defun texinfo-copy-section-title () | |
356 "Return the title of the section as a string. | |
357 The title is used as a description line in the menu when one does not | |
358 already exist. | |
359 | |
360 Move point to the beginning of the appropriate section line by going | |
361 to the start of the text matched by last regexp searched for, which | |
362 must have been done by `texinfo-menu-locate-entry-p'." | |
363 | |
364 ;; could use the same re-search as in `texinfo-menu-locate-entry-p' | |
365 ;; instead of using `match-beginning'; such a variation would be | |
366 ;; more general, but would waste information already collected | |
367 | |
368 (goto-char (match-beginning 7)) ; match section name | |
369 | |
370 (buffer-substring | |
371 (progn (forward-word 1) ; skip over section type | |
372 (skip-chars-forward " \t") ; and over spaces | |
373 (point)) | |
374 (progn (end-of-line) (point)))) | |
375 | |
376 | |
377 ;;;; Handling the old menu | |
378 | |
379 (defun texinfo-old-menu-p (beginning first) | |
380 "Move point to the beginning of the menu for this section, if any. | |
381 Otherwise move point to the end of the first node of this section. | |
382 Return t if a menu is found, nil otherwise. | |
383 | |
384 First argument is the position of the beginning of the section in which | |
385 the menu will be located; second argument is the position of the first | |
386 node within the section. | |
387 | |
388 If no menu is found, the function inserts two newlines just before the | |
389 end of the section, and leaves point there where a menu ought to be." | |
390 (goto-char beginning) | |
391 (if (not (re-search-forward "^@menu" first 'goto-end)) | |
392 (progn (insert "\n\n") (forward-line -2) nil) | |
393 t)) | |
394 | |
395 (defun texinfo-incorporate-descriptions (new-menu-list) | |
396 "Copy the old menu line descriptions that exist to the new menu. | |
397 | |
398 Point must be at beginning of old menu. | |
399 | |
400 If the node-name of the new menu entry cannot be found in the old | |
401 menu, use the new section title for the description, but if the | |
402 node-name of the new menu is found in the old menu, replace the | |
403 section title with the old description, whatever it may be. | |
404 | |
405 For this function, the new menu is a list made up of lists of dotted | |
406 pairs in which the first element of the pair is the node name and the | |
407 second element the description. The new menu is changed destructively. | |
408 The old menu is the menu as it appears in the texinfo file." | |
409 | |
410 (let ((new-menu-list-pointer new-menu-list) | |
411 (end-of-menu (texinfo-menu-end))) | |
412 (while new-menu-list | |
413 (save-excursion ; keep point at beginning of menu | |
414 (if (search-forward | |
415 (concat "\* " ; so only menu entries are found | |
416 (car (car new-menu-list)) | |
417 ":") ; so only complete entries are found | |
418 end-of-menu | |
419 t) | |
420 (setcdr (car new-menu-list) | |
421 (texinfo-menu-copy-old-description end-of-menu)))) | |
422 (setq new-menu-list (cdr new-menu-list))) | |
423 (setq new-menu-list new-menu-list-pointer))) | |
424 | |
425 (defun texinfo-menu-copy-old-description (end-of-menu) | |
426 "Return description field of old menu line as string. | |
427 Point must be located just after the node name. Point left before description. | |
428 Single argument, END-OF-MENU, is position limiting search." | |
429 (skip-chars-forward "[:.,\t\n ]+") | |
430 ;; don't copy a carriage return at line beginning with asterisk! | |
431 ;; do copy a description that begins with an `@'! | |
432 (if (and (looking-at "\\(\\w+\\|@\\)") | |
433 (not (looking-at "\\(^\\* \\|^@end menu\\)"))) | |
434 (buffer-substring | |
435 (point) | |
436 (save-excursion | |
437 (re-search-forward "\\(^\\* \\|^@end menu\\)" end-of-menu t) | |
438 (forward-line -1) | |
439 (end-of-line) ; go to end of last description line | |
440 (point))) | |
441 "")) | |
442 | |
443 (defun texinfo-menu-end () | |
444 "Return position of end of menu. Does not change location of point. | |
445 Signal an error if not end of menu." | |
446 (save-excursion | |
447 (if (re-search-forward "^@end menu" nil t) | |
448 (point) | |
449 (error "Menu does not have an end.")))) | |
450 | |
451 (defun texinfo-delete-old-menu (beginning first) | |
452 "Delete the old menu. Point must be in or after menu. | |
453 First argument is position of the beginning of the section in which | |
454 the menu will be located; second argument is the position of the first | |
455 node within the section." | |
456 ;; No third arg to search, so error if search fails. | |
457 (re-search-backward "^@menu" beginning) | |
458 (delete-region (point) | |
459 (save-excursion | |
460 (re-search-forward "^@end menu" first) | |
461 (point)))) | |
462 | |
463 | |
464 ;;;; Inserting new menu | |
465 | |
466 ;; try 32, but perhaps 24 is better | |
467 (defvar texinfo-column-for-description 32 | |
468 "*Column at which descriptions start in a Texinfo menu.") | |
469 | |
470 (defun texinfo-insert-menu (menu-list node-name) | |
471 "Insert formatted menu at point. | |
472 Indents the first line of the description, if any, to the value of | |
473 texinfo-column-for-description. | |
474 | |
475 MENU-LIST has form: | |
476 | |
477 \(\(\"node-name1\" . \"description\"\) | |
478 \(\"node-name\" . \"description\"\) ... \) | |
479 | |
480 However, there does not need to be a description field." | |
481 | |
482 (insert "@menu\n") | |
483 (while menu-list | |
484 (if (cdr (car menu-list)) ; menu-list has description entry | |
485 (progn | |
486 (insert | |
487 (format "* %s::" (car (car menu-list)))) ; node-name entry | |
488 (indent-to texinfo-column-for-description 2) | |
489 (insert | |
490 (format "%s\n" (cdr (car menu-list))))) ; description entry | |
491 ;; else menu-list lacks description entry | |
492 (insert | |
493 (format "* %s::\n" (car (car menu-list))))) ; node-name entry | |
494 (setq menu-list (cdr menu-list))) | |
495 (insert "@end menu") | |
496 (message | |
497 "Updated \"%s\" level menu following node: %s ... " | |
498 level node-name)) | |
499 | |
500 | |
501 ;;;; Handling description indentation | |
502 | |
503 ; Since the make-menu functions indent descriptions, these functions | |
504 ; are useful primarily for indenting a single menu specially. | |
505 | |
506 (defun texinfo-indent-menu-description (column &optional region-p) | |
507 "Indent every description in menu following point to COLUMN. | |
508 Non-nil argument (prefix, if interactive) means indent every | |
509 description in every menu in the region. Does not indent second and | |
510 subsequent lines of a multi-line description." | |
511 | |
512 (interactive | |
513 "nIndent menu descriptions to (column number): \nP") | |
514 (save-excursion | |
515 (save-restriction | |
516 (widen) | |
517 (if (not region-p) | |
518 (progn | |
519 (re-search-forward "^@menu") | |
520 (texinfo-menu-indent-description column) | |
521 (message | |
522 "Indented descriptions in menu. You may save the buffer.")) | |
523 ;;else | |
524 (message "Indenting every menu description in region... ") | |
525 (goto-char (region-beginning)) | |
526 (while (and (< (point) (region-end)) | |
527 (texinfo-locate-menu-p)) | |
528 (forward-line 1) | |
529 (texinfo-menu-indent-description column)) | |
530 (message "Indenting done. You may save the buffer."))))) | |
531 | |
532 (defun texinfo-menu-indent-description (to-column-number) | |
533 "Indent the Texinfo file menu description to TO-COLUMN-NUMBER. | |
534 Start with point just after the word `menu' in the `@menu' line and | |
535 leave point on the line before the `@end menu' line. Does not indent | |
536 second and subsequent lines of a multi-line description." | |
537 (let* ((beginning-of-next-line (point))) | |
538 (while (< beginning-of-next-line | |
539 (save-excursion ; beginning of end menu line | |
540 (goto-char (texinfo-menu-end)) | |
541 (beginning-of-line) | |
542 (point))) | |
543 (if (search-forward "::" (texinfo-menu-end) t) | |
544 (progn | |
545 (let ((beginning-white-space (point))) | |
546 (skip-chars-forward " \t") ; skip over spaces | |
547 (if (looking-at "\\(@\\|\\w\\)+") ; if there is text | |
548 (progn | |
549 ;; remove pre-existing indentation | |
550 (delete-region beginning-white-space (point)) | |
551 (indent-to-column to-column-number)))))) | |
552 ;; position point at beginning of next line | |
553 (forward-line 1) | |
554 (setq beginning-of-next-line (point))))) | |
555 | |
556 | |
557 ;;;; Making the master menu | |
558 | |
559 (defun texinfo-master-menu (update-all-nodes-menus-p) | |
560 "Make a master menu for a whole Texinfo file. | |
561 Non-nil argument (prefix, if interactive) means first update all | |
562 existing nodes and menus. Remove pre-existing master menu, if there is one. | |
563 | |
564 This function creates a master menu that follows the top node. The | |
565 master menu includes every entry from all the other menus. It | |
566 replaces any existing ordinary menu that follows the top node. | |
567 | |
568 If called with a non-nil argument, this function first updates all the | |
569 menus in the buffer (incorporating descriptions from pre-existing | |
570 menus) before it constructs the master menu. | |
571 | |
572 The function removes the detailed part of an already existing master | |
573 menu. This action depends on the pre-exisitng master menu using the | |
574 standard `texinfo-master-menu-header'. | |
575 | |
576 The master menu has the following format, which is adapted from the | |
577 recommendation in the Texinfo Manual: | |
578 | |
579 * The first part contains the major nodes in the Texinfo file: the | |
580 nodes for the chapters, chapter-like sections, and the major | |
581 appendices. This includes the indices, so long as they are in | |
582 chapter-like sections, such as unnumbered sections. | |
583 | |
584 * The second and subsequent parts contain a listing of the other, | |
585 lower level menus, in order. This way, an inquirer can go | |
586 directly to a particular node if he or she is searching for | |
587 specific information. | |
588 | |
589 Each of the menus in the detailed node listing is introduced by the | |
590 title of the section containing the menu." | |
591 | |
592 (interactive "P") | |
593 (widen) | |
594 (goto-char (point-min)) | |
595 | |
596 ;; Move point to location after `top'. | |
143 | 597 (if (not (re-search-forward "^@node [ \t]*top[ \t]*\\(,\\|$\\)" nil t)) |
107 | 598 (error "This buffer needs a Top node!")) |
599 | |
600 (let ((first-chapter | |
601 (save-excursion (re-search-forward "^@node") (point)))) | |
602 (if (re-search-forward texinfo-master-menu-header first-chapter t) | |
603 ;; Remove detailed master menu listing | |
604 (progn | |
605 (goto-char (match-beginning 0)) | |
606 (let ((end-of-detailed-menu-descriptions | |
607 (save-excursion ; beginning of end menu line | |
608 (goto-char (texinfo-menu-end)) | |
609 (beginning-of-line) (forward-char -1) | |
610 (point)))) | |
611 (delete-region (point) end-of-detailed-menu-descriptions))))) | |
612 | |
613 (if update-all-nodes-menus-p | |
614 (progn | |
615 (message "Making a master menu...first updating all nodes... ") | |
616 (sleep-for 2) | |
617 (mark-whole-buffer) | |
618 (texinfo-update-node t) | |
619 | |
620 (message "Updating all menus... ") | |
621 (sleep-for 2) | |
622 (mark-whole-buffer) | |
623 (texinfo-make-menu t))) | |
624 | |
625 (message "Now making the master menu... ") | |
626 (sleep-for 2) | |
627 (goto-char (point-min)) | |
628 (texinfo-insert-master-menu-list | |
629 (texinfo-master-menu-list)) | |
630 | |
631 ;; Remove extra newlines that texinfo-insert-master-menu-list | |
632 ;; may have inserted. | |
633 | |
634 (save-excursion | |
635 (goto-char (point-min)) | |
636 | |
637 (re-search-forward texinfo-master-menu-header) | |
638 (goto-char (match-beginning 0)) | |
639 (insert "\n") | |
640 (delete-blank-lines) | |
641 | |
642 (re-search-backward "^@menu") | |
643 (forward-line -1) | |
644 (delete-blank-lines) | |
645 | |
646 (re-search-forward "^@end menu") | |
647 (forward-line 1) | |
648 (delete-blank-lines)) | |
649 | |
650 (message "Done...completed making master menu. You may save the buffer.")) | |
651 | |
652 (defun texinfo-master-menu-list () | |
653 "Return a list of menu entries and header lines for the master menu. | |
654 | |
655 Start with the menu for chapters and indices and then find each | |
656 following menu and the title of the node preceding that menu. | |
657 | |
658 The master menu list has this form: | |
659 | |
660 \(\(\(... \"entry-1-2\" \"entry-1\"\) \"title-1\"\) | |
661 \(\(... \"entry-2-2\" \"entry-2-1\"\) \"title-2\"\) | |
662 ...\) | |
663 | |
664 However, there does not need to be a title field." | |
665 | |
666 (let (master-menu-list) | |
667 (while (texinfo-locate-menu-p) | |
668 (setq master-menu-list | |
669 (cons (list | |
670 (texinfo-copy-menu) | |
671 (texinfo-copy-menu-title)) | |
672 master-menu-list))) | |
673 (reverse master-menu-list))) | |
674 | |
675 (defun texinfo-insert-master-menu-list (master-menu-list) | |
676 "Format and insert the master menu in the current buffer." | |
677 (goto-char (point-min)) | |
678 (re-search-forward "^@menu") | |
679 (beginning-of-line) | |
680 (delete-region (point) ; buffer must have ordinary top menu | |
681 (save-excursion | |
682 (re-search-forward "^@end menu") | |
683 (point))) | |
684 | |
685 (save-excursion ; leave point at beginning of menu | |
686 ;; Handle top of menu | |
687 (insert "\n@menu\n") | |
688 ;; Insert chapter menu entries | |
689 (setq this-very-menu-list (reverse (car (car master-menu-list)))) | |
690 ;;; Tell user what is going on. | |
691 (message "Inserting chapter menu entry: %s ... " this-very-menu-list) | |
692 (while this-very-menu-list | |
693 (insert "* " (car this-very-menu-list) "\n") | |
694 (setq this-very-menu-list (cdr this-very-menu-list))) | |
695 | |
696 (setq master-menu-list (cdr master-menu-list)) | |
697 | |
698 (insert texinfo-master-menu-header) | |
699 | |
700 ;; Now, insert all the other menus | |
701 | |
702 ;; The menu master-menu-list has a form like this: | |
703 ;; ((("beta" "alpha") "title-A") | |
704 ;; (("delta" "gamma") "title-B")) | |
705 | |
706 (while master-menu-list | |
707 | |
708 (message | |
709 "Inserting menu for %s .... " (car (cdr (car master-menu-list)))) | |
710 ;; insert title of menu section | |
711 (insert "\n" (car (cdr (car master-menu-list))) "\n\n") | |
712 | |
713 ;; insert each menu entry | |
714 (setq this-very-menu-list (reverse (car (car master-menu-list)))) | |
715 (while this-very-menu-list | |
716 (insert "* " (car this-very-menu-list) "\n") | |
717 (setq this-very-menu-list (cdr this-very-menu-list))) | |
718 | |
719 (setq master-menu-list (cdr master-menu-list))) | |
720 | |
721 ;; Finish menu | |
722 (insert "@end menu\n\n"))) | |
723 | |
724 (defvar texinfo-master-menu-header | |
725 "\n --- The Detailed Node Listing ---\n" | |
726 "String inserted before lower level entries in Texinfo master menu. | |
727 It comes after the chapter-level menu entries.") | |
728 | |
729 (defun texinfo-locate-menu-p () | |
730 "Find the next menu in the texinfo file. | |
731 If found, leave point after word `menu' on the `@menu' line, and return t. | |
732 If a menu is not found, do not move point and return nil." | |
733 (re-search-forward "\\(^@menu\\)" nil t)) | |
734 | |
735 (defun texinfo-copy-menu-title () | |
736 "Return the title of the section preceding the menu as a string. | |
737 If such a title cannot be found, return an empty string. Do not move | |
738 point." | |
739 (save-excursion | |
740 (if (re-search-backward | |
741 (concat | |
742 "\\(^@node\\).*\n" ; match node line | |
743 "\\(\\(\\(^@c\\).*\n\\)" ; match comment line, if any | |
744 "\\|" ; or | |
745 "\\(^@ifinfo[ ]*\n\\)\\)?" ; ifinfo line, if any | |
746 (eval | |
747 (cdr | |
748 (assoc (texinfo-hierarchic-level) | |
749 texinfo-update-menu-higher-regexps)))) | |
750 nil | |
751 t) | |
752 (texinfo-copy-section-title) | |
753 " "))) | |
754 | |
755 (defun texinfo-copy-menu () | |
756 "Return the entries of an existing menu as a list. | |
757 Start with point just after the word `menu' in the `@menu' line | |
758 and leave point on the line before the `@end menu' line." | |
759 (let* (this-menu-list | |
760 (end-of-menu (texinfo-menu-end)) ; position of end of `@end menu' | |
761 (last-entry (save-excursion ; position of beginning of | |
762 ; last `* ' entry | |
763 (goto-char end-of-menu) | |
764 (re-search-backward "^\* ") ; handle multi-line desc. | |
765 (point)))) | |
766 (while (< (point) last-entry) | |
767 (if (re-search-forward "^\* " end-of-menu t) | |
768 (progn | |
769 (setq this-menu-list | |
770 (cons | |
771 (buffer-substring | |
772 (point) | |
773 ;; copy multi-line descriptions | |
774 (save-excursion | |
775 (re-search-forward "\\(^\* \\|^@e\\)" nil t) | |
776 (- (point) 3))) | |
777 this-menu-list))))) | |
778 this-menu-list)) | |
779 | |
780 | |
781 ;;;; Determining the hierarchical level in the texinfo file | |
782 | |
783 (defun texinfo-specific-section-type () | |
784 "Return the specific type of next section, as a string. | |
785 For example, \"unnumberedsubsec\". Return \"top\" for top node. | |
786 | |
787 Searches forward for a section. Hence, point must be before the | |
788 section whose type will be found. Does not move point. Signal an | |
789 error if the node is not the top node and a section is not found." | |
790 (save-excursion | |
791 (cond | |
143 | 792 ((re-search-forward "^@node [ \t]*top[ \t]*\\(,\\|$\\)" |
793 (save-excursion | |
794 (end-of-line) | |
795 (point)) | |
796 t) | |
107 | 797 "top") |
798 ((re-search-forward texinfo-section-types-regexp nil t) | |
799 (buffer-substring (progn (beginning-of-line) ; copy its name | |
800 (1+ (point))) | |
801 (progn (forward-word 1) | |
802 (point)))) | |
803 (t | |
804 (error | |
805 "texinfo-specific-section-type: Chapter or section not found."))))) | |
806 | |
807 (defun texinfo-hierarchic-level () | |
808 "Return the general hierarchal level of the next node in a texinfo file. | |
809 Thus, a subheading or appendixsubsec is of type subsection." | |
810 (cdr (assoc | |
811 (texinfo-specific-section-type) | |
812 texinfo-section-to-generic-alist))) | |
813 | |
814 | |
815 ;;;; Locating the major positions | |
816 | |
817 (defun texinfo-update-menu-region-beginning (level) | |
818 "Locate beginning of higher level section this section is within. | |
819 Return position of the beginning of the node line; do not move point. | |
820 Thus, if this level is subsection, searches backwards for section node. | |
821 Only argument is a string of the general type of section." | |
822 | |
823 (cond | |
143 | 824 ((or (string-equal "top" level) |
825 (string-equal "chapter" level)) | |
107 | 826 (save-excursion |
143 | 827 (goto-char (point-min)) |
828 (re-search-forward "^@node [ \t]*top[ \t]*\\(,\\|$\\)" nil t) | |
829 (beginning-of-line) | |
107 | 830 (point))) |
831 (t | |
832 (save-excursion | |
833 (re-search-backward | |
834 (concat | |
835 "\\(^@node\\).*\n" ; match node line | |
836 "\\(\\(\\(^@c\\).*\n\\)" ; match comment line, if any | |
837 "\\|" ; or | |
838 "\\(^@ifinfo[ ]*\n\\)\\)?" ; ifinfo line, if any | |
839 (eval | |
840 (cdr (assoc level texinfo-update-menu-higher-regexps)))) | |
841 nil | |
842 'goto-beginning) | |
843 (point))))) | |
844 | |
845 (defun texinfo-update-menu-region-end (level) | |
846 "Locate end of higher level section this section is within. | |
847 Return position; do not move point. Thus, if this level is a | |
848 subsection, find the node for the section this subsection is within. | |
849 If level is top or chapter, returns end of file. Only argument is a | |
850 string of the general type of section." | |
851 | |
852 (save-excursion | |
853 (if (re-search-forward | |
854 (concat | |
855 "\\(^@node\\).*\n" ; match node line | |
856 "\\(\\(\\(^@c\\).*\n\\)" ; match comment line, if any | |
857 "\\|" ; or | |
858 "\\(^@ifinfo[ ]*\n\\)\\)?" ; ifinfo line, if any | |
859 (eval | |
860 (cdr (assoc level texinfo-update-menu-higher-regexps)))) | |
861 nil | |
862 'goto-end) | |
863 (match-beginning 1) | |
864 (point-max)))) | |
865 | |
866 (defun texinfo-menu-first-node (beginning end) | |
867 "Locate first node of the section the menu will be placed in. | |
868 Return position; do not move point. | |
869 The menu will be located just before this position. | |
870 | |
871 First argument is the position of the beginning of the section in | |
872 which the menu will be located; second argument is the position of the | |
873 end of that region; it limits the search." | |
874 | |
875 (save-excursion | |
876 (goto-char beginning) | |
877 (forward-line 1) | |
878 (re-search-forward "^@node" end t) | |
879 (beginning-of-line) | |
880 (point))) | |
881 | |
882 | |
883 ;;;; Alists and regular expressions for defining hierarchical levels | |
884 | |
885 (defvar texinfo-section-to-generic-alist | |
886 '(("top" . "top") | |
887 | |
888 ("chapter" . "chapter") | |
889 ("unnumbered" . "chapter") | |
890 ("majorheading" . "chapter") | |
891 ("chapheading" . "chapter") | |
892 ("appendix" . "chapter") | |
893 | |
894 ("section" . "section") | |
895 ("unnumberedsec" . "section") | |
896 ("heading" . "section") | |
897 ("appendixsec" . "section") | |
898 | |
899 ("subsection" . "subsection") | |
900 ("unnumberedsubsec" . "subsection") | |
901 ("subheading" . "subsection") | |
902 ("appendixsubsec" . "subsection") | |
903 | |
904 ("subsubsection" . "subsubsection") | |
905 ("unnumberedsubsubsec" . "subsubsection") | |
906 ("subsubheading" . "subsubsection") | |
907 ("appendixsubsubsec" . "subsubsection")) | |
908 "*An alist of specific and corresponding generic Texinfo section types. | |
909 The keys are strings specifying specific types of section; the values | |
910 are strings of their corresponding general types.") | |
911 | |
912 (defvar texinfo-section-types-regexp | |
913 "^@\\(chapter \\|sect\\|sub\\|unnum\\|major\\|chapheading \\|heading \\|appendix\\)" | |
914 "Regexp matching chapter, section, other headings (but not the top node).") | |
915 | |
916 (defvar texinfo-chapter-level-regexp | |
917 "chapter\\|unnumbered \\|appendix \\|majorheading\\|chapheading" | |
918 "Regular expression matching just the Texinfo chapter level headings.") | |
919 | |
920 (defvar texinfo-section-level-regexp | |
921 "section\\|unnumberedsec\\|heading \\|appendixsec" | |
922 "Regular expression matching just the Texinfo section level headings.") | |
923 | |
924 (defvar texinfo-subsection-level-regexp | |
925 "subsection\\|unnumberedsubsec\\|subheading\\|appendixsubsec" | |
926 "Regular expression matching just the Texinfo subsection level headings.") | |
927 | |
928 (defvar texinfo-subsubsection-level-regexp | |
929 "subsubsection\\|unnumberedsubsubsec\\|subsubheading\\|appendixsubsubsec" | |
930 "Regular expression matching just the Texinfo subsubsection level headings.") | |
931 | |
932 (defvar texinfo-update-menu-same-level-regexps | |
933 '(("top" . "top[ \t]+") | |
934 ("chapter" . | |
935 (concat "\\(^@\\)\\(" texinfo-chapter-level-regexp "\\)[ \t]*")) | |
936 ("section" . | |
937 (concat "\\(^@\\)\\(" texinfo-section-level-regexp "\\)[ \t]*")) | |
938 ("subsection" . | |
939 (concat "\\(^@\\)\\(" texinfo-subsection-level-regexp "\\)[ \t]+")) | |
940 ("subsubsection" . | |
941 (concat "\\(^@\\)\\(" texinfo-subsubsection-level-regexp "\\)[ \t]+"))) | |
942 "*Regexps for searching for same level sections in a Texinfo file. | |
943 The keys are strings specifying the general hierarchical level in the | |
944 document; the values are regular expressions.") | |
945 | |
946 (defvar texinfo-update-menu-higher-regexps | |
947 '(("top" . "^@node [ \t]*DIR") | |
143 | 948 ("chapter" . "^@node [ \t]*top[ \t]*\\(,\\|$\\)") |
107 | 949 ("section" . |
950 (concat | |
951 "\\(^@\\(" | |
952 texinfo-chapter-level-regexp | |
953 "\\)[ \t]*\\)")) | |
954 ("subsection" . | |
955 (concat | |
956 "\\(^@\\(" | |
957 texinfo-section-level-regexp | |
958 "\\|" | |
959 texinfo-chapter-level-regexp | |
960 "\\)[ \t]*\\)")) | |
961 ("subsubsection" . | |
962 (concat | |
963 "\\(^@\\(" | |
964 texinfo-subsection-level-regexp | |
965 "\\|" | |
966 texinfo-section-level-regexp | |
967 "\\|" | |
968 texinfo-chapter-level-regexp | |
969 "\\)[ \t]*\\)"))) | |
970 "*Regexps for searching for higher level sections in a Texinfo file. | |
971 The keys are strings specifying the general hierarchical level in the | |
972 document; the values are regular expressions.") | |
973 | |
974 (defvar texinfo-update-menu-lower-regexps | |
975 '(("top" . | |
976 (concat | |
977 "\\(^@\\(" | |
978 texinfo-chapter-level-regexp | |
979 "\\|" | |
980 texinfo-section-level-regexp | |
981 "\\|" | |
982 texinfo-subsection-level-regexp | |
983 "\\|" | |
984 texinfo-subsubsection-level-regexp | |
985 "\\)[ \t]*\\)")) | |
986 ("chapter" . | |
987 (concat | |
988 "\\(^@\\(" | |
989 texinfo-section-level-regexp | |
990 "\\|" | |
991 texinfo-subsection-level-regexp | |
992 "\\|" | |
993 texinfo-subsubsection-level-regexp | |
994 "\\)[ \t]*\\)")) | |
995 ("section" . | |
996 (concat | |
997 "\\(^@\\(" | |
998 texinfo-subsection-level-regexp | |
999 "\\|" | |
1000 texinfo-subsubsection-level-regexp | |
1001 "\\)[ \t]+\\)")) | |
1002 ("subsection" . | |
1003 (concat | |
1004 "\\(^@\\(" | |
1005 texinfo-subsubsection-level-regexp | |
1006 "\\)[ \t]+\\)")) | |
1007 ("subsubsection" . "nothing lower")) | |
1008 "*Regexps for searching for lower level sections in a Texinfo file. | |
1009 The keys are strings specifying the general hierarchical level in the | |
1010 document; the values are regular expressions.") | |
1011 | |
1012 | |
1013 ;;;; Updating a Node | |
1014 | |
1015 (defun texinfo-update-node (&optional region-p) | |
1016 "Without any prefix argument, update the node in which point is located. | |
1017 Non-nil argument (prefix, if interactive) means update the nodes in the | |
1018 marked region. | |
1019 | |
1020 The functions for creating or updating nodes and menus, and their | |
1021 keybindings, are: | |
1022 | |
1023 texinfo-update-node (&optional region-p) \\[texinfo-update-node] | |
1024 texinfo-every-node-update () \\[texinfo-every-node-update] | |
1025 texinfo-sequential-node-update (&optional region-p) | |
1026 | |
1027 texinfo-make-menu (&optional region-p) \\[texinfo-make-menu] | |
1028 texinfo-all-menus-update () \\[texinfo-all-menus-update] | |
1029 texinfo-master-menu () | |
1030 | |
1031 texinfo-indent-menu-description (column &optional region-p) | |
1032 | |
1033 The `texinfo-column-for-description' variable specifies the column to | |
1034 which menu descriptions are indented. Its default value is 24." | |
1035 | |
1036 (interactive "P") | |
1037 (if (not region-p) | |
732 | 1038 (let ((auto-fill-function nil)) ; update a single node |
107 | 1039 (if (not (re-search-backward "^@node" (point-min) t)) |
1040 (error "Node line not found before this position.")) | |
1041 (texinfo-update-the-node) | |
1042 (message "Done...updated the node. You may save the buffer.")) | |
1043 ;; else | |
732 | 1044 (let ((auto-fill-function nil) |
107 | 1045 (beginning (region-beginning)) |
1046 (end (region-end))) | |
1047 (if (= end beginning) | |
1048 (error "Please mark a region!")) | |
1049 (save-restriction | |
1050 (narrow-to-region beginning end) | |
1051 (goto-char beginning) | |
1052 (push-mark) | |
1053 (while (re-search-forward "^@node" (point-max) t) | |
1054 (beginning-of-line) | |
1055 (texinfo-update-the-node)) | |
1056 (message "Done...updated nodes in region. You may save the buffer."))))) | |
1057 | |
1058 (defun texinfo-every-node-update () | |
1059 "Update every node in a Texinfo file." | |
1060 (interactive) | |
1061 (save-excursion | |
1062 (mark-whole-buffer) | |
1063 (texinfo-update-node t) | |
1064 (message "Done...updated every node. You may save the buffer."))) | |
1065 | |
1066 (defun texinfo-update-the-node () | |
1067 "Update one node. Point must be at the beginning of node line. | |
1068 Leave point at the end of the node line." | |
1069 (texinfo-check-for-node-name) | |
1070 (texinfo-delete-existing-pointers) | |
1071 (message "Updating node: %s ... " (texinfo-copy-node-name)) | |
1072 (save-restriction | |
1073 (widen) | |
1074 (let* | |
1075 ((case-fold-search t) | |
1076 (level (texinfo-hierarchic-level)) | |
1077 (beginning (texinfo-update-menu-region-beginning level)) | |
1078 (end (texinfo-update-menu-region-end level))) | |
1079 (if (string-equal level "top") | |
1080 (texinfo-top-pointer-case) | |
1081 ;; else | |
1082 (texinfo-insert-pointer beginning end level 'next) | |
1083 (texinfo-insert-pointer beginning end level 'previous) | |
1084 (texinfo-insert-pointer beginning end level 'up) | |
1085 (texinfo-clean-up-node-line))))) | |
1086 | |
1087 (defun texinfo-top-pointer-case () | |
1088 "Insert pointers in the Top node. This is a special case. | |
1089 | |
1090 The `Next' pointer is a pointer to a chapter or section at a lower | |
1091 hierarchical level in the file. The `Previous' and `Up' pointers are | |
1092 to `(dir)'. Point must be at the beginning of the node line, and is | |
1093 left at the end of the node line." | |
1094 | |
1095 (texinfo-clean-up-node-line) | |
1096 (insert ", " | |
1097 (save-excursion | |
1098 ;; There may be an @chapter or other such command between | |
1099 ;; the top node line and the next node line, as a title | |
1100 ;; for an `ifinfo' section. This @chapter command must | |
1101 ;; must be skipped. So the procedure is to search for | |
1102 ;; the next `@node' line, and then copy its name. | |
1103 (if (re-search-forward "^@node" nil t) | |
1104 (progn | |
1105 (beginning-of-line) | |
1106 (texinfo-copy-node-name)) | |
1107 " ")) | |
1108 ", (dir), (dir)")) | |
1109 | |
1110 (defun texinfo-check-for-node-name () | |
1111 "Determine whether the node has a node name. Prompt for one if not. | |
1112 Point must be at beginning of node line. Does not move point." | |
1113 (save-excursion | |
1114 (forward-word 1) ; skip over node command | |
1115 (skip-chars-forward " \t") ; and over spaces | |
1116 (if (not (looking-at "[^,\t\n ]+")) ; regexp based on what info looks for | |
1117 ; alternatively, use "[a-zA-Z]+" | |
1118 (let ((node-name (read-from-minibuffer "Node name: "))) | |
1119 (insert " " node-name))))) | |
1120 | |
1121 (defun texinfo-delete-existing-pointers () | |
1122 "Delete `Next', `Previous', and `Up' pointers. | |
1123 Starts from the current position of the cursor, and searches forward | |
1124 on the line for a comma and if one is found, deletes the rest of the | |
1125 line, including the comma. Leaves point at beginning of line." | |
1126 (if (search-forward "," (save-excursion (end-of-line) (point)) t) | |
1127 (progn | |
1128 (goto-char (1- (point))) | |
1129 (kill-line nil))) | |
1130 (beginning-of-line)) | |
1131 | |
1132 (defun texinfo-find-pointer (beginning end level direction) | |
1133 "Move point to section associated with next, previous, or up pointer. | |
1134 Return type of pointer (either 'normal or 'no-pointer). | |
1135 | |
1136 The first and second arguments bound the search for a pointer to the | |
1137 beginning and end, respectively, of the enclosing higher level | |
1138 section. The third argument is a string specifying the general kind | |
1139 of section such as \"chapter\ or \"section\". When looking for the | |
1140 `Next' pointer, the section found will be at the same hierarchical | |
1141 level in the Texinfo file; when looking for the `Previous' pointer, | |
1142 the section found will be at the same or higher hierarchical level in | |
1143 the Texinfo file; when looking for the `Up' pointer, the section found | |
1144 will be at some level higher in the Texinfo file. The fourth argument | |
1145 \(one of 'next, 'previous, or 'up\) specifies whether to find the | |
1146 `Next', `Previous', or `Up' pointer." | |
1147 | |
1148 (cond ((eq direction 'next) | |
1149 (forward-line 3) ; skip over current node | |
1150 (if (re-search-forward | |
1151 (eval | |
1152 (cdr (assoc level texinfo-update-menu-same-level-regexps))) | |
1153 end | |
1154 t) | |
1155 'normal | |
1156 'no-pointer)) | |
1157 ((eq direction 'previous) | |
1158 (if (re-search-backward | |
1159 (concat | |
1160 "\\(" | |
1161 (eval | |
1162 (cdr (assoc level texinfo-update-menu-same-level-regexps))) | |
1163 "\\|" | |
1164 (eval | |
1165 (cdr (assoc level texinfo-update-menu-higher-regexps))) | |
1166 "\\)") | |
1167 beginning | |
1168 t) | |
1169 'normal | |
1170 'no-pointer)) | |
1171 ((eq direction 'up) | |
1172 (if (re-search-backward | |
1173 (eval (cdr (assoc level texinfo-update-menu-higher-regexps))) | |
1174 (save-excursion | |
1175 (goto-char beginning) | |
1176 (beginning-of-line) | |
1177 (point)) | |
1178 t) | |
1179 'normal | |
1180 'no-pointer)) | |
1181 (t | |
1182 (error "texinfo-find-pointer: lack proper arguments")))) | |
1183 | |
1184 (defun texinfo-pointer-name (kind) | |
1185 "Return the node name preceding the section command. | |
1186 The argument is the kind of section, either normal or no-pointer." | |
1187 (let (name) | |
1188 (cond ((eq kind 'normal) | |
1189 (end-of-line) ; this handles prev node top case | |
1190 (re-search-backward ; when point is already | |
1191 "^@node" ; at the beginning of @node line | |
1192 (save-excursion (forward-line -3)) | |
1193 t) | |
1194 (setq name (texinfo-copy-node-name))) | |
1195 ((eq kind 'no-pointer) | |
1196 (setq name " "))) ; put a blank in the pointer slot | |
1197 name)) | |
1198 | |
1199 (defun texinfo-insert-pointer (beginning end level direction) | |
1200 "Insert the `Next', `Previous' or `Up' node name at point. | |
1201 Move point forward. | |
1202 | |
1203 The first and second arguments bound the search for a pointer to the | |
1204 beginning and end, respectively, of the enclosing higher level | |
1205 section. The third argument is the hierarchical level of the Texinfo | |
1206 file, a string such as \"section\". The fourth argument is direction | |
1207 towards which the pointer is directed, one of `next, `previous, or | |
1208 'up." | |
1209 | |
1210 (end-of-line) | |
1211 (insert | |
1212 ", " | |
1213 (save-excursion | |
1214 (texinfo-pointer-name | |
1215 (texinfo-find-pointer beginning end level direction))))) | |
1216 | |
1217 (defun texinfo-clean-up-node-line () | |
1218 "Remove extra commas, if any, at end of node line." | |
1219 (end-of-line) | |
1220 (skip-chars-backward ", ") | |
1221 (delete-region (point) (save-excursion (end-of-line) (point)))) | |
1222 | |
1223 | |
1224 ;;;; Updating nodes sequentially | |
1225 ; These sequential update functions insert `Next' or `Previous' | |
1226 ; pointers that point to the following or preceding nodes even if they | |
1227 ; are at higher or lower hierarchical levels. This means that if a | |
1228 ; section contains one or more subsections, the section's `Next' | |
1229 ; pointer will point to the subsection and not the following section. | |
1230 ; (The subsection to which `Next' points will most likely be the first | |
1231 ; item on the section's menu.) | |
1232 | |
1233 (defun texinfo-sequential-node-update (&optional region-p) | |
1234 "Update one node (or many) in a Texinfo file with sequential pointers. | |
1235 | |
1236 This function causes the `Next' or `Previous' pointer to point to the | |
1237 immediately preceding or following node, even if it is at a higher or | |
1238 lower hierarchical level in the document. Continually pressing `n' or | |
1239 `p' takes you straight through the file. | |
1240 | |
1241 Without any prefix argument, update the node in which point is located. | |
1242 Non-nil argument (prefix, if interactive) means update the nodes in the | |
1243 marked region. | |
1244 | |
1245 This command makes it awkward to navigate among sections and | |
1246 subsections; it should be used only for those documents that are meant | |
1247 to be read like a novel rather than a reference, and for which the | |
1248 Info `g*' command is inadequate." | |
1249 | |
1250 (interactive "P") | |
1251 (if (not region-p) | |
732 | 1252 (let ((auto-fill-function nil)) ; update a single node |
107 | 1253 (if (not (re-search-backward "^@node" (point-min) t)) |
1254 (error "Node line not found before this position.")) | |
1255 (texinfo-sequentially-update-the-node) | |
1256 (message | |
1257 "Done...sequentially updated the node . You may save the buffer.")) | |
1258 ;; else | |
732 | 1259 (let ((auto-fill-function nil) |
107 | 1260 (beginning (region-beginning)) |
1261 (end (region-end))) | |
1262 (if (= end beginning) | |
1263 (error "Please mark a region!")) | |
1264 (save-restriction | |
1265 (narrow-to-region beginning end) | |
1266 (goto-char beginning) | |
1267 (push-mark) | |
1268 (while (re-search-forward "^@node" (point-max) t) | |
1269 (beginning-of-line) | |
1270 (texinfo-sequentially-update-the-node)) | |
1271 (message | |
1272 "Done...updated the nodes in sequence. You may save the buffer."))))) | |
1273 | |
1274 (defun texinfo-sequentially-update-the-node () | |
1275 "Update one node such that the pointers are sequential. | |
1276 A `Next' or `Previous' pointer points to any preceding or following node, | |
1277 regardless of its hierarchical level." | |
1278 | |
1279 (texinfo-check-for-node-name) | |
1280 (texinfo-delete-existing-pointers) | |
1281 (message | |
1282 "Sequentially updating node: %s ... " (texinfo-copy-node-name)) | |
1283 (save-restriction | |
1284 (widen) | |
1285 (let* | |
1286 ((case-fold-search t) | |
1287 (level (texinfo-hierarchic-level))) | |
1288 (if (string-equal level "top") | |
1289 (texinfo-top-pointer-case) | |
1290 ;; else | |
1291 (texinfo-sequentially-insert-pointer level 'next) | |
1292 (texinfo-sequentially-insert-pointer level 'previous) | |
1293 (texinfo-sequentially-insert-pointer level 'up) | |
1294 (texinfo-clean-up-node-line))))) | |
1295 | |
1296 (defun texinfo-sequentially-find-pointer (level direction) | |
1297 "Find next or previous pointer sequentially in Texinfo file, or up pointer. | |
1298 Move point to section associated with the pointer. Find point even if | |
1299 it is in a different section. | |
1300 | |
1301 Return type of pointer (either 'normal or 'no-pointer). | |
1302 | |
1303 The first argument is a string specifying the general kind of section | |
1304 such as \"chapter\ or \"section\". The section found will be at the | |
1305 same hierarchical level in the Texinfo file, or, in the case of the up | |
1306 pointer, some level higher. The second argument (one of 'next, | |
1307 'previous, or 'up) specifies whether to find the `Next', `Previous', | |
1308 or `Up' pointer." | |
1309 | |
1310 (cond ((eq direction 'next) | |
1311 (forward-line 3) ; skip over current node | |
1312 (if (re-search-forward | |
1313 texinfo-section-types-regexp | |
1314 (point-max) | |
1315 t) | |
1316 'normal | |
1317 'no-pointer)) | |
1318 ((eq direction 'previous) | |
1319 (if (re-search-backward | |
1320 texinfo-section-types-regexp | |
1321 (point-min) | |
1322 t) | |
1323 'normal | |
1324 'no-pointer)) | |
1325 ((eq direction 'up) | |
1326 (if (re-search-backward | |
1327 (eval (cdr (assoc level texinfo-update-menu-higher-regexps))) | |
1328 beginning | |
1329 t) | |
1330 'normal | |
1331 'no-pointer)) | |
1332 (t | |
1333 (error "texinfo-sequential-find-pointer: lack proper arguments")))) | |
1334 | |
1335 (defun texinfo-sequentially-insert-pointer (level direction) | |
1336 "Insert the `Next', `Previous' or `Up' node name at point. | |
1337 Move point forward. | |
1338 | |
1339 The first argument is the hierarchical level of the Texinfo file, a | |
1340 string such as \"section\". The second argument is direction, one of | |
1341 `next, `previous, or 'up." | |
1342 | |
1343 (end-of-line) | |
1344 (insert | |
1345 ", " | |
1346 (save-excursion | |
1347 (texinfo-pointer-name | |
1348 (texinfo-sequentially-find-pointer level direction))))) | |
1349 | |
1350 | |
1351 ;;;; Inserting `@node' lines | |
1352 ; The `texinfo-insert-node-lines' function inserts `@node' lines as needed | |
1353 ; before the `@chapter', `@section', and such like lines of a region | |
1354 ; in a Texinfo file. | |
1355 | |
1356 (defun texinfo-insert-node-lines (&optional title-p) | |
1357 "Insert missing `@node' lines in region of Texinfo file. | |
1358 Non-nil argument (prefix, if interactive) means also to insert the | |
1359 section titles as node names; and also to insert the section titles as | |
1360 node names in pre-existing @node lines that lack names." | |
1361 (interactive "P") | |
1362 (save-excursion | |
1363 (let ((begin-region (region-beginning)) | |
1364 (end-region (region-end))) | |
1365 (goto-char begin-region) | |
1366 (while (< (point) end-region) | |
1367 (re-search-forward texinfo-section-types-regexp nil 'end) | |
1368 ;; copy title, since most often, we will need it | |
1369 (let ((title | |
1370 (progn | |
1371 (beginning-of-line) | |
1372 (forward-word 1) | |
1373 (skip-chars-forward " \t") | |
1374 (buffer-substring | |
1375 (point) | |
1376 (save-excursion (end-of-line) (point)))))) | |
1377 ;; insert a node if necessary | |
1378 (if (re-search-backward | |
1379 "^@node" | |
1380 (save-excursion | |
1381 (forward-line -3) | |
1382 (point)) | |
1383 t) | |
1384 ;; @node present, and point at beginning of that line | |
1385 (forward-word 1) | |
1386 ;; else @node missing, insert one | |
1387 (progn | |
1388 (beginning-of-line) ; beginning of `@section' line | |
1389 (insert "@node\n") | |
1390 (backward-char 1))) ; leave point just after `@node' | |
1391 ;; insert a title if warranted | |
1392 (if title-p | |
1393 (progn | |
1394 (skip-chars-forward " \t") | |
1395 ;; use regexp based on what info looks for | |
1396 ;; (alternatively, use "[a-zA-Z]+") | |
1397 (if (not (looking-at "[^,\t\n ]+")) | |
1398 (progn | |
1399 (beginning-of-line) | |
1400 (forward-word 1) | |
1401 (insert " " title) | |
1402 (message "Inserted title %s ... " title))))) | |
1403 ;; in any case, go forward beyond current section title | |
1404 (forward-line 3))))) | |
1405 (if title-p | |
1406 (message | |
1407 "Done inserting node lines and titles. You may save the buffer.") | |
1408 (message "Done inserting node lines. You may save the buffer."))) | |
1409 | |
1410 | |
1411 ;;;; Update and create menus for multi-file Texinfo sources | |
1412 | |
1413 ;; 1. M-x texinfo-multiple-files-update | |
1414 ;; | |
1415 ;; Read the include file list of an outer Texinfo file and | |
1416 ;; update all highest level nodes in the files listed and insert a | |
1417 ;; main menu in the outer file after its top node. | |
1418 | |
1419 ;; 2. C-u M-x texinfo-multiple-files-update | |
1420 ;; | |
1421 ;; Same as 1, but insert a master menu. (Saves reupdating lower | |
1422 ;; level menus and nodes.) This command simply reads every menu, | |
1423 ;; so if the menus are wrong, the master menu will be wrong. | |
1424 ;; Similarly, if the lower level node pointers are wrong, they | |
1425 ;; will stay wrong. | |
1426 | |
1427 ;; 3. C-u 2 M-x texinfo-multiple-files-update | |
1428 ;; | |
1429 ;; Read the include file list of an outer Texinfo file and | |
1430 ;; update all nodes and menus in the files listed and insert a | |
1431 ;; master menu in the outer file after its top node. | |
1432 | |
1433 ;;; Note: these functions: | |
1434 ;;; | |
1435 ;;; * Do not save or delete any buffers. You may fill up your memory. | |
1436 ;;; * Do not handle any pre-existing nodes in outer file. | |
1437 ;;; Hence, you may need a file for indices. | |
1438 | |
1439 | |
1440 ;;;; Auxiliary functions for multiple file updating | |
1441 | |
1442 (defun texinfo-multi-file-included-list (outer-file) | |
1443 "Return a list of the included files in OUTER-FILE." | |
1444 (let ((included-file-list (list outer-file)) | |
1445 start) | |
1446 (save-excursion | |
1447 (switch-to-buffer (find-file-noselect outer-file)) | |
1448 (widen) | |
1449 (goto-char (point-min)) | |
1450 (while (re-search-forward "^@include" nil t) | |
1451 (skip-chars-forward " \t") | |
1452 (setq start (point)) | |
1453 (end-of-line) | |
1454 (skip-chars-backward " \t") | |
1455 (setq included-file-list | |
1456 (cons (buffer-substring start (point)) | |
1457 included-file-list))) | |
1458 (nreverse included-file-list)))) | |
1459 | |
1460 (defun texinfo-copy-next-section-title () | |
1461 "Return the name of the immediately following section as a string. | |
1462 | |
1463 Start with point at the beginning of the node line. Leave point at the | |
1464 same place. If there is no title, returns an empty string." | |
1465 | |
1466 (save-excursion | |
1467 (end-of-line) | |
1468 (let ((section-end (or | |
1469 (save-excursion | |
1470 (re-search-forward "\\(^@node\\)" nil t) | |
1471 (match-beginning 0)) | |
1472 (point-max)))) | |
1473 (if (re-search-forward texinfo-section-types-regexp section-end t) | |
1474 ;; copy title | |
1475 (let ((title | |
1476 (buffer-substring | |
1477 (progn (forward-word 1) ; skip over section type | |
1478 (skip-chars-forward " \t") ; and over spaces | |
1479 (point)) | |
1480 (progn (end-of-line) (point))))) | |
1481 title) | |
1482 "")))) | |
1483 | |
1484 (defun texinfo-multi-file-update (files &optional update-everything) | |
1485 "Update first node pointers in each file in FILES. | |
1486 Return a list of the node names and the title immediate following them. | |
1487 | |
1488 The first file in the list is an outer file; the remaining are | |
1489 files included in the outer file with `@include' commands. | |
1490 | |
1491 If optional arg UPDATE-EVERYTHING non-nil, update every menu and | |
1492 pointer in each of the included files. | |
1493 | |
1494 Also update the `Top' level node pointers of the outer file. | |
1495 | |
1496 Requirements: | |
1497 | |
1498 * the first file in the FILES list must be the outer file, | |
1499 * each of the included files must contain exactly one highest | |
1500 hierarchical level node, | |
1501 * this node must be the first node in the included file, | |
1502 * each highest hierarchical level node must be of the same type. | |
1503 | |
1504 Thus, normally, each included file contains one, and only one, | |
1505 chapter. | |
1506 | |
1507 The menu-list has the form: | |
1508 | |
1509 \(\(\"node-name1\" . \"title1\"\) | |
1510 \(\"node-name2\" . \"title2\"\) ... \) | |
1511 | |
1512 However, there does not need to be a title field." | |
1513 | |
1514 (let (menu-list) | |
1515 | |
1516 ;; Find the name of the first node of the first included file. | |
1517 (switch-to-buffer (find-file-noselect (car (cdr files)))) | |
1518 (widen) | |
1519 (goto-char (point-min)) | |
1520 (if (not (re-search-forward "^@node" nil t)) | |
1521 (error "No `@node' line found in %s !" (buffer-name))) | |
1522 (beginning-of-line) | |
1523 (texinfo-check-for-node-name) | |
1524 (setq next-node-name (texinfo-copy-node-name)) | |
1525 | |
1526 (setq menu-list | |
1527 (cons (cons | |
1528 next-node-name | |
1529 (texinfo-copy-next-section-title)) | |
1530 menu-list)) | |
1531 | |
1532 ;; Go to outer file | |
1533 (switch-to-buffer (find-file-noselect (car files))) | |
1534 (goto-char (point-min)) | |
143 | 1535 (if (not (re-search-forward "^@node [ \t]*top[ \t]*\\(,\\|$\\)" nil t)) |
107 | 1536 (error "This buffer needs a Top node!")) |
1537 (beginning-of-line) | |
1538 (texinfo-delete-existing-pointers) | |
1539 (end-of-line) | |
1540 (insert ", " next-node-name ", (dir), (dir)") | |
1541 (beginning-of-line) | |
1542 (setq previous-node-name "Top") | |
1543 (setq files (cdr files)) | |
1544 | |
1545 (while files | |
1546 | |
1547 (if (not (cdr files)) | |
1548 ;; No next file | |
1549 (setq next-node-name "") | |
1550 ;; Else, | |
1551 ;; find the name of the first node in the next file. | |
1552 (switch-to-buffer (find-file-noselect (car (cdr files)))) | |
1553 (widen) | |
1554 (goto-char (point-min)) | |
1555 (if (not (re-search-forward "^@node" nil t)) | |
1556 (error "No `@node' line found in %s !" (buffer-name))) | |
1557 (beginning-of-line) | |
1558 (texinfo-check-for-node-name) | |
1559 (setq next-node-name (texinfo-copy-node-name)) | |
1560 (setq menu-list | |
1561 (cons (cons | |
1562 next-node-name | |
1563 (texinfo-copy-next-section-title)) | |
1564 menu-list))) | |
1565 | |
1566 ;; Go to node to be updated. | |
1567 (switch-to-buffer (find-file-noselect (car files))) | |
1568 (goto-char (point-min)) | |
1569 (if (not (re-search-forward "^@node" nil t)) | |
1570 (error "No `@node' line found in %s !" (buffer-name))) | |
1571 (beginning-of-line) | |
1572 (texinfo-delete-existing-pointers) | |
1573 (end-of-line) | |
1574 (insert ", " next-node-name ", " previous-node-name ", " up-node-name) | |
1575 | |
1576 (beginning-of-line) | |
1577 (setq previous-node-name (texinfo-copy-node-name)) | |
1578 | |
1579 ;; Update other menus and nodes if requested. | |
1580 (if update-everything (texinfo-all-menus-update t)) | |
1581 | |
1582 (setq files (cdr files))) | |
1583 (nreverse menu-list))) | |
1584 | |
1585 (defun texinfo-multi-files-insert-main-menu (menu-list) | |
1586 "Insert formatted main menu at point. | |
1587 Indents the first line of the description, if any, to the value of | |
1588 texinfo-column-for-description." | |
1589 | |
1590 (insert "@menu\n") | |
1591 (while menu-list | |
1592 (if (cdr (car menu-list)) ; menu-list has description entry | |
1593 (progn | |
1594 (insert | |
1595 (format "* %s::" (car (car menu-list)))) ; node-name entry | |
1596 (indent-to texinfo-column-for-description 2) | |
1597 (insert | |
1598 (format "%s\n" (cdr (car menu-list))))) ; description entry | |
1599 ;; else menu-list lacks description entry | |
1600 (insert | |
1601 (format "* %s::\n" (car (car menu-list))))) ; node-name entry | |
1602 (setq menu-list (cdr menu-list))) | |
1603 (insert "@end menu")) | |
1604 | |
1605 | |
1606 (defun texinfo-multi-file-master-menu-list (files-list) | |
1607 "Return master menu list from files in FILES-LIST. | |
1608 Menu entries in each file collected using `texinfo-master-menu-list'. | |
1609 | |
1610 The first file in FILES-LIST must be the outer file; the others must | |
1611 be the files included within it. A main menu must already exist." | |
1612 (save-excursion | |
1613 (let (master-menu-list) | |
1614 (while files-list | |
1615 (switch-to-buffer (find-file-noselect (car files-list))) | |
1616 (message "Working on: %s " (current-buffer)) | |
1617 (goto-char (point-min)) | |
1618 (setq master-menu-list | |
1619 (append master-menu-list (texinfo-master-menu-list))) | |
1620 (setq files-list (cdr files-list))) | |
1621 master-menu-list))) | |
1622 | |
1623 | |
1624 ;;;; The multiple-file update function | |
1625 | |
1626 (defun texinfo-multiple-files-update | |
1627 (outer-file &optional update-everything make-master-menu) | |
1628 "Update first node pointers in each file included in OUTER-FILE; | |
1629 create or update main menu in the outer file that refers to such nodes. | |
1630 This does not create or update menus or pointers within the included files. | |
1631 | |
1632 With optional MAKE-MASTER-MENU argument (prefix arg, if interactive), | |
1633 insert a master menu in OUTER-FILE. This does not create or update | |
1634 menus or pointers within the included files. | |
1635 | |
1636 With optional UPDATE-EVERYTHING argument (numeric prefix arg, if | |
1637 interactive), update all the menus and all the `Next', `Previous', and | |
1638 `Up' pointers of all the files included in OUTER-FILE before inserting | |
1639 a master menu in OUTER-FILE. | |
1640 | |
1641 The command also updates the `Top' level node pointers of OUTER-FILE. | |
1642 | |
1643 Notes: | |
1644 | |
1645 * this command does NOT save any files--you must save the | |
1646 outer file and any modified, included files. | |
1647 | |
1648 * except for the `Top' node, this command does NOT handle any | |
1649 pre-existing nodes in the outer file; hence, indices must be | |
1650 enclosed in an included file. | |
1651 | |
1652 Requirements: | |
1653 | |
1654 * each of the included files must contain exactly one highest | |
1655 hierarchical level node, | |
1656 * this highest node must be the first node in the included file, | |
1657 * each highest hierarchical level node must be of the same type. | |
1658 | |
1659 Thus, normally, each included file contains one, and only one, | |
1660 chapter." | |
1661 | |
1662 (interactive "fName of outer `include' file: ") | |
1663 | |
1664 (cond (current-prefix-arg | |
1665 (setq make-master-menu (listp current-prefix-arg)) | |
1666 (setq update-everything (numberp current-prefix-arg)))) | |
1667 | |
1668 (let* ((included-file-list (texinfo-multi-file-included-list outer-file)) | |
1669 (files included-file-list) | |
1670 main-menu-list | |
1671 next-node-name | |
1672 previous-node-name | |
1673 (up-node-name "Top")) | |
1674 | |
1675 ;;; Update the pointers | |
1676 ;;; and collect the names of the nodes and titles | |
1677 (setq main-menu-list (texinfo-multi-file-update files update-everything)) | |
1678 | |
1679 ;;; Insert main menu | |
1680 | |
1681 ;; Go to outer file | |
1682 (switch-to-buffer (find-file-noselect (car included-file-list))) | |
1683 (if (texinfo-old-menu-p | |
1684 (point-min) | |
1685 (save-excursion | |
1686 (re-search-forward "^@include") | |
1687 (beginning-of-line) | |
1688 (point))) | |
1689 | |
1690 ;; If found, leave point after word `menu' on the `@menu' line. | |
1691 (progn | |
1692 (texinfo-incorporate-descriptions main-menu-list) | |
1693 ;; Delete existing menu. | |
1694 (beginning-of-line) | |
1695 (delete-region | |
1696 (point) | |
1697 (save-excursion (re-search-forward "^@end menu") (point))) | |
1698 ;; Insert main menu | |
1699 (texinfo-multi-files-insert-main-menu main-menu-list)) | |
1700 | |
1701 ;; Else no current menu; insert it before `@include' | |
1702 (texinfo-multi-files-insert-main-menu main-menu-list)) | |
1703 | |
1704 ;;; Insert master menu | |
1705 | |
1706 (if make-master-menu | |
1707 (progn | |
1708 ;; First, removing detailed part of any pre-existing master menu | |
1709 (goto-char (point-min)) | |
1710 (if (re-search-forward texinfo-master-menu-header nil t) | |
1711 ;; Remove detailed master menu listing | |
1712 (progn | |
1713 (goto-char (match-beginning 0)) | |
1714 (let ((end-of-detailed-menu-descriptions | |
1715 (save-excursion ; beginning of end menu line | |
1716 (goto-char (texinfo-menu-end)) | |
1717 (beginning-of-line) (forward-char -1) | |
1718 (point)))) | |
1719 (delete-region (point) end-of-detailed-menu-descriptions)))) | |
1720 | |
1721 ;; Create a master menu and insert it | |
1722 (texinfo-insert-master-menu-list | |
1723 (texinfo-multi-file-master-menu-list | |
1724 included-file-list))))) | |
1725 (message "Multiple files updated.")) | |
1726 | |
584 | 1727 (provide 'texnfo-upd) |
1728 | |
657
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
1729 ;;; texnfo-upd.el ends here |