Mercurial > hg > xemacs-beta
comparison lisp/packages/texnfo-upd.el @ 2:ac2d302a0011 r19-15b2
Import from CVS: tag r19-15b2
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:46:35 +0200 |
parents | 376386a54a3c |
children | b82b59fe008d |
comparison
equal
deleted
inserted
replaced
1:c0c6a60d29db | 2:ac2d302a0011 |
---|---|
1 ;;; Texinfo mode utilities for updating nodes and menus in Texinfo files. | 1 ;;; texnfo-upd.el --- utilities for updating nodes and menus in Texinfo files |
2 ;;; Copyright 1989, 1990, 1991, 1992 Free Software Foundation | 2 |
3 ;; Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc. | |
3 | 4 |
4 ;; Author: Robert J. Chassell | 5 ;; Author: Robert J. Chassell |
5 ;; Maintainer: bug-texinfo@prep.ai.mit.edu | 6 ;; Maintainer: bug-texinfo@prep.ai.mit.edu |
6 ;; Keywords: maint, tex, docs | 7 ;; Keywords: maint, tex, docs |
7 | 8 |
8 ;; This file is part of GNU Emacs. | 9 ;; This file is part of XEmacs. |
9 | 10 |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | 11 ;; XEmacs is free software; you can redistribute it and/or modify |
11 ;; it under the terms of the GNU General Public License as published by | 12 ;; it under the terms of the GNU General Public License as published by |
12 ;; the Free Software Foundation; either version 2, or (at your option) | 13 ;; the Free Software Foundation; either version 2, or (at your option) |
13 ;; any later version. | 14 ;; any later version. |
14 | 15 |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | 16 ;; XEmacs is distributed in the hope that it will be useful, but |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | 17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
18 ;; GNU General Public License for more details. | 19 ;; General Public License for more details. |
19 | 20 |
20 ;; You should have received a copy of the GNU General Public License | 21 ;; You should have received a copy of the GNU General Public License |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to | 22 ;; along with XEmacs; see the file COPYING. If not, write to the Free |
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | 23 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
23 | 24 ;; 02111-1307, USA. |
24 ;;; Synched up with: FSF 19.29. | 25 |
26 ;;; Synched up with: FSF 19.34. | |
25 | 27 |
26 ;;; Commentary: | 28 ;;; Commentary: |
27 | 29 |
28 ;;; Known bug: update commands fail to ignore @ignore. | 30 ;; Known bug: update commands fail to ignore @ignore. |
29 | 31 |
30 ;;; Summary: how to use the updating commands | 32 ;; Summary: how to use the updating commands |
31 | 33 |
32 ; The node and menu updating functions automatically | 34 ;; The node and menu updating functions automatically |
33 | 35 |
34 ; * insert missing `@node' lines, | 36 ;; * insert missing `@node' lines, |
35 ; * insert the `Next', `Previous' and `Up' pointers of a node, | 37 ;; * insert the `Next', `Previous' and `Up' pointers of a node, |
36 ; * insert or update the menu for a section, | 38 ;; * insert or update the menu for a section, |
37 ; * create a master menu for a Texinfo source file. | 39 ;; * create a master menu for a Texinfo source file. |
38 ; | 40 ;; |
39 ; Passed an argument, the `texinfo-update-node' and | 41 ;; Passed an argument, the `texinfo-update-node' and |
40 ; `texinfo-make-menu' functions do their jobs in the region. | 42 ;; `texinfo-make-menu' functions do their jobs in the region. |
41 ; | 43 ;; |
42 ; In brief, the functions for creating or updating nodes and menus, are: | 44 ;; In brief, the functions for creating or updating nodes and menus, are: |
43 ; | 45 ;; |
44 ; texinfo-update-node (&optional region-p) | 46 ;; texinfo-update-node (&optional region-p) |
45 ; texinfo-every-node-update () | 47 ;; texinfo-every-node-update () |
46 ; texinfo-sequential-node-update (&optional region-p) | 48 ;; texinfo-sequential-node-update (&optional region-p) |
47 ; | 49 ;; |
48 ; texinfo-make-menu (&optional region-p) | 50 ;; texinfo-make-menu (&optional region-p) |
49 ; texinfo-all-menus-update () | 51 ;; texinfo-all-menus-update () |
50 ; texinfo-master-menu () | 52 ;; texinfo-master-menu () |
51 ; | 53 ;; |
52 ; texinfo-insert-node-lines (&optional title-p) | 54 ;; texinfo-insert-node-lines (&optional title-p) |
53 ; | 55 ;; |
54 ; texinfo-indent-menu-description (column &optional region-p) | 56 ;; texinfo-indent-menu-description (column &optional region-p) |
55 | 57 |
56 ; The `texinfo-column-for-description' variable specifies the column to | 58 ;; The `texinfo-column-for-description' variable specifies the column to |
57 ; which menu descriptions are indented. | 59 ;; which menu descriptions are indented. |
58 | 60 |
59 ; Texinfo file structure | 61 ;; Texinfo file structure |
60 ; ---------------------- | 62 ;; ---------------------- |
61 | 63 |
62 ; To use the updating commands, you must structure your Texinfo file | 64 ;; To use the updating commands, you must structure your Texinfo file |
63 ; hierarchically. Each `@node' line, with the exception of the top | 65 ;; hierarchically. Each `@node' line, with the exception of the top |
64 ; node, must be accompanied by some kind of section line, such as an | 66 ;; node, must be accompanied by some kind of section line, such as an |
65 ; `@chapter' or `@section' line. Each node-line/section-line | 67 ;; `@chapter' or `@section' line. Each node-line/section-line |
66 ; combination must look like this: | 68 ;; combination must look like this: |
67 | 69 |
68 ; @node Lists and Tables, Cross References, Structuring, Top | 70 ;; @node Lists and Tables, Cross References, Structuring, Top |
69 ; @comment node-name, next, previous, up | 71 ;; @comment node-name, next, previous, up |
70 ; @chapter Making Lists and Tables | 72 ;; @chapter Making Lists and Tables |
71 | 73 |
72 ; or like this (without the `@comment' line): | 74 ;; or like this (without the `@comment' line): |
73 | 75 |
74 ; @node Lists and Tables, Cross References, Structuring, Top | 76 ;; @node Lists and Tables, Cross References, Structuring, Top |
75 ; @chapter Making Lists and Tables | 77 ;; @chapter Making Lists and Tables |
76 | 78 |
77 ; If the file has a `top' node, it must be called `top' or `Top' and | 79 ;; If the file has a `top' node, it must be called `top' or `Top' and |
78 ; be the first node in the file. | 80 ;; be the first node in the file. |
79 | 81 |
80 | 82 |
81 ;;; The update node functions described in detail | 83 ;;; The update node functions described in detail |
82 | 84 |
83 ; The `texinfo-update-node' function without an argument inserts | 85 ;; The `texinfo-update-node' function without an argument inserts |
84 ; the correct next, previous and up pointers for the node in which | 86 ;; the correct next, previous and up pointers for the node in which |
85 ; point is located (i.e., for the node preceding point). | 87 ;; point is located (i.e., for the node preceding point). |
86 | 88 |
87 ; With an argument, the `texinfo-update-node' function inserts the | 89 ;; With an argument, the `texinfo-update-node' function inserts the |
88 ; correct next, previous and up pointers for the nodes inside the | 90 ;; correct next, previous and up pointers for the nodes inside the |
89 ; region. | 91 ;; region. |
90 | 92 |
91 ; It does not matter whether the `@node' line has pre-existing | 93 ;; It does not matter whether the `@node' line has pre-existing |
92 ; `Next', `Previous', or `Up' pointers in it. They are removed. | 94 ;; `Next', `Previous', or `Up' pointers in it. They are removed. |
93 | 95 |
94 ; The `texinfo-every-node-update' function runs `texinfo-update-node' | 96 ;; The `texinfo-every-node-update' function runs `texinfo-update-node' |
95 ; on the whole buffer. | 97 ;; on the whole buffer. |
96 | 98 |
97 ; The `texinfo-sequential-node-update' function inserts the | 99 ;; The `texinfo-sequential-node-update' function inserts the |
98 ; immediately following and preceding node into the `Next' or | 100 ;; immediately following and preceding node into the `Next' or |
99 ; `Previous' pointers regardless of their hierarchical level. This is | 101 ;; `Previous' pointers regardless of their hierarchical level. This is |
100 ; only useful for certain kinds of text, like a novel, which you go | 102 ;; only useful for certain kinds of text, like a novel, which you go |
101 ; through sequentially. | 103 ;; through sequentially. |
102 | 104 |
103 | 105 |
104 ;;; The menu making functions described in detail | 106 ;;; The menu making functions described in detail |
105 | 107 |
106 ; The `texinfo-make-menu' function without an argument creates or | 108 ;; The `texinfo-make-menu' function without an argument creates or |
107 ; updates a menu for the section encompassing the node that follows | 109 ;; updates a menu for the section encompassing the node that follows |
108 ; point. With an argument, it makes or updates menus for the nodes | 110 ;; point. With an argument, it makes or updates menus for the nodes |
109 ; within or part of the marked region. | 111 ;; within or part of the marked region. |
110 | 112 |
111 ; Whenever an existing menu is updated, the descriptions from | 113 ;; Whenever an existing menu is updated, the descriptions from |
112 ; that menu are incorporated into the new menu. This is done by copying | 114 ;; that menu are incorporated into the new menu. This is done by copying |
113 ; descriptions from the existing menu to the entries in the new menu | 115 ;; descriptions from the existing menu to the entries in the new menu |
114 ; that have the same node names. If the node names are different, the | 116 ;; that have the same node names. If the node names are different, the |
115 ; descriptions are not copied to the new menu. | 117 ;; descriptions are not copied to the new menu. |
116 | 118 |
117 ; Menu entries that refer to other Info files are removed since they | 119 ;; Menu entries that refer to other Info files are removed since they |
118 ; are not a node within current buffer. This is a deficiency. | 120 ;; are not a node within current buffer. This is a deficiency. |
119 | 121 |
120 ; The `texinfo-all-menus-update' function runs `texinfo-make-menu' | 122 ;; The `texinfo-all-menus-update' function runs `texinfo-make-menu' |
121 ; on the whole buffer. | 123 ;; on the whole buffer. |
122 | 124 |
123 ; The `texinfo-master-menu' function creates an extended menu located | 125 ;; The `texinfo-master-menu' function creates an extended menu located |
124 ; after the top node. (The file must have a top node.) The function | 126 ;; after the top node. (The file must have a top node.) The function |
125 ; first updates all the regular menus in the buffer (incorporating the | 127 ;; first updates all the regular menus in the buffer (incorporating the |
126 ; descriptions from pre-existing menus), and then constructs a master | 128 ;; descriptions from pre-existing menus), and then constructs a master |
127 ; menu that includes every entry from every other menu. (However, the | 129 ;; menu that includes every entry from every other menu. (However, the |
128 ; function cannot update an already existing master menu; if one | 130 ;; function cannot update an already existing master menu; if one |
129 ; exists, it must be removed before calling the function.) | 131 ;; exists, it must be removed before calling the function.) |
130 | 132 |
131 ; The `texinfo-indent-menu-description' function indents every | 133 ;; The `texinfo-indent-menu-description' function indents every |
132 ; description in the menu following point, to the specified column. | 134 ;; description in the menu following point, to the specified column. |
133 ; Non-nil argument (prefix, if interactive) means indent every | 135 ;; Non-nil argument (prefix, if interactive) means indent every |
134 ; description in every menu in the region. This function does not | 136 ;; description in every menu in the region. This function does not |
135 ; indent second and subsequent lines of a multi-line description. | 137 ;; indent second and subsequent lines of a multi-line description. |
136 | 138 |
137 ; The `texinfo-insert-node-lines' function inserts `@node' before the | 139 ;; The `texinfo-insert-node-lines' function inserts `@node' before the |
138 ; `@chapter', `@section', and such like lines of a region in a Texinfo | 140 ;; `@chapter', `@section', and such like lines of a region in a Texinfo |
139 ; file where the `@node' lines are missing. | 141 ;; file where the `@node' lines are missing. |
140 ; | 142 ;; |
141 ; With a non-nil argument (prefix, if interactive), the function not | 143 ;; With a non-nil argument (prefix, if interactive), the function not |
142 ; only inserts `@node' lines but also inserts the chapter or section | 144 ;; only inserts `@node' lines but also inserts the chapter or section |
143 ; titles as the names of the corresponding nodes; and inserts titles | 145 ;; titles as the names of the corresponding nodes; and inserts titles |
144 ; as node names in pre-existing `@node' lines that lack names. | 146 ;; as node names in pre-existing `@node' lines that lack names. |
145 ; | 147 ;; |
146 ; Since node names should be more concise than section or chapter | 148 ;; Since node names should be more concise than section or chapter |
147 ; titles, node names so inserted will need to be edited manually. | 149 ;; titles, node names so inserted will need to be edited manually. |
148 | 150 |
149 | 151 |
150 ;;; Code: | 152 ;;; Code: |
151 | 153 |
152 ;;; The menu making functions | 154 ;;; The menu making functions |
748 If called with a non-nil argument, this function first updates all the | 750 If called with a non-nil argument, this function first updates all the |
749 menus in the buffer (incorporating descriptions from pre-existing | 751 menus in the buffer (incorporating descriptions from pre-existing |
750 menus) before it constructs the master menu. | 752 menus) before it constructs the master menu. |
751 | 753 |
752 The function removes the detailed part of an already existing master | 754 The function removes the detailed part of an already existing master |
753 menu. This action depends on the pre-exisitng master menu using the | 755 menu. This action depends on the pre-existing master menu using the |
754 standard `texinfo-master-menu-header'. | 756 standard `texinfo-master-menu-header'. |
755 | 757 |
756 The master menu has the following format, which is adapted from the | 758 The master menu has the following format, which is adapted from the |
757 recommendation in the Texinfo Manual: | 759 recommendation in the Texinfo Manual: |
758 | 760 |
962 (end-of-menu (texinfo-menu-end)) ; position of end of `@end menu' | 964 (end-of-menu (texinfo-menu-end)) ; position of end of `@end menu' |
963 (last-entry (save-excursion ; position of beginning of | 965 (last-entry (save-excursion ; position of beginning of |
964 ; last `* ' entry | 966 ; last `* ' entry |
965 (goto-char end-of-menu) | 967 (goto-char end-of-menu) |
966 ;; handle multi-line description | 968 ;; handle multi-line description |
967 (if (not (re-search-backward "^\* " nil t)) | 969 (if (not (re-search-backward "^\\* " nil t)) |
968 (error "No entries in menu.")) | 970 (error "No entries in menu.")) |
969 (point)))) | 971 (point)))) |
970 (while (< (point) last-entry) | 972 (while (< (point) last-entry) |
971 (if (re-search-forward "^\* " end-of-menu t) | 973 (if (re-search-forward "^\\* " end-of-menu t) |
972 (progn | 974 (progn |
973 (setq this-menu-list | 975 (setq this-menu-list |
974 (cons | 976 (cons |
975 (buffer-substring | 977 (buffer-substring |
976 (point) | 978 (point) |
977 ;; copy multi-line descriptions | 979 ;; copy multi-line descriptions |
978 (save-excursion | 980 (save-excursion |
979 (re-search-forward "\\(^\* \\|^@e\\)" nil t) | 981 (re-search-forward "\\(^\\* \\|^@e\\)" nil t) |
980 (- (point) 3))) | 982 (- (point) 3))) |
981 this-menu-list))))) | 983 this-menu-list))))) |
982 this-menu-list)) | 984 this-menu-list)) |
983 | 985 |
984 | 986 |
1001 ;;; (point)) | 1003 ;;; (point)) |
1002 nil | 1004 nil |
1003 t) | 1005 t) |
1004 "top") | 1006 "top") |
1005 ((re-search-forward texinfo-section-types-regexp nil t) | 1007 ((re-search-forward texinfo-section-types-regexp nil t) |
1006 (buffer-substring (progn (beginning-of-line) ; copy its name | 1008 (buffer-substring-no-properties |
1007 (1+ (point))) | 1009 (progn (beginning-of-line) ; copy its name |
1008 (progn (forward-word 1) | 1010 (1+ (point))) |
1009 (point)))) | 1011 (progn (forward-word 1) |
1012 (point)))) | |
1010 (t | 1013 (t |
1011 (error | 1014 (error |
1012 "texinfo-specific-section-type: Chapter or section not found.")))))) | 1015 "texinfo-specific-section-type: Chapter or section not found.")))))) |
1013 | 1016 |
1014 (defun texinfo-hierarchic-level () | 1017 (defun texinfo-hierarchic-level () |
1359 Return type of pointer (either 'normal or 'no-pointer). | 1362 Return type of pointer (either 'normal or 'no-pointer). |
1360 | 1363 |
1361 The first and second arguments bound the search for a pointer to the | 1364 The first and second arguments bound the search for a pointer to the |
1362 beginning and end, respectively, of the enclosing higher level | 1365 beginning and end, respectively, of the enclosing higher level |
1363 section. The third argument is a string specifying the general kind | 1366 section. The third argument is a string specifying the general kind |
1364 of section such as \"chapter\ or \"section\". When looking for the | 1367 of section such as \"chapter\" or \"section\". When looking for the |
1365 `Next' pointer, the section found will be at the same hierarchical | 1368 `Next' pointer, the section found will be at the same hierarchical |
1366 level in the Texinfo file; when looking for the `Previous' pointer, | 1369 level in the Texinfo file; when looking for the `Previous' pointer, |
1367 the section found will be at the same or higher hierarchical level in | 1370 the section found will be at the same or higher hierarchical level in |
1368 the Texinfo file; when looking for the `Up' pointer, the section found | 1371 the Texinfo file; when looking for the `Up' pointer, the section found |
1369 will be at some level higher in the Texinfo file. The fourth argument | 1372 will be at some level higher in the Texinfo file. The fourth argument |
1556 it is in a different section. | 1559 it is in a different section. |
1557 | 1560 |
1558 Return type of pointer (either 'normal or 'no-pointer). | 1561 Return type of pointer (either 'normal or 'no-pointer). |
1559 | 1562 |
1560 The first argument is a string specifying the general kind of section | 1563 The first argument is a string specifying the general kind of section |
1561 such as \"chapter\ or \"section\". The section found will be at the | 1564 such as \"chapter\" or \"section\". The section found will be at the |
1562 same hierarchical level in the Texinfo file, or, in the case of the up | 1565 same hierarchical level in the Texinfo file, or, in the case of the up |
1563 pointer, some level higher. The second argument (one of 'next, | 1566 pointer, some level higher. The second argument (one of 'next, |
1564 'previous, or 'up) specifies whether to find the `Next', `Previous', | 1567 'previous, or 'up) specifies whether to find the `Next', `Previous', |
1565 or `Up' pointer." | 1568 or `Up' pointer." |
1566 (let ((case-fold-search t)) | 1569 (let ((case-fold-search t)) |