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