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