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