annotate lisp/textmodes/texnfo-upd.el @ 3373:4177a984e5c0

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