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