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