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