annotate lisp/packages/texnfo-upd.el @ 2:ac2d302a0011 r19-15b2

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