annotate lisp/packages/texnfo-upd.el @ 0:376386a54a3c r19-14

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