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