annotate lisp/textmodes/texnfo-upd.el @ 41609:f1391a41ece3

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