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