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