Mercurial > emacs
annotate lisp/textmodes/texinfo.el @ 2835:6af690e58256
(texinfo-tex-region): Update name of tex-set-buffer-directory.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 16 May 1993 21:14:05 +0000 |
parents | ce2187c33f4c |
children | 573fc5cd8175 |
rev | line source |
---|---|
2233
fb0ed5a1d0f3
Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1833
diff
changeset
|
1 ;;; texinfo.el --- major mode for editing Texinfo files. |
139
8e1e4ca81016
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
128
diff
changeset
|
2 |
840
113281b361ec
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
814
diff
changeset
|
3 ;; Copyright (C) 1985, 1988, 1989, 1990 Free Software Foundation, Inc. |
113281b361ec
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
814
diff
changeset
|
4 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
5 ;; Author: Bob Chassell <bob@gnu.ai.mit.edu> |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
6 ;; Version: 2.00 |
814
38b2499cb3e9
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
7 ;; Keywords: maint, tex, doc, wp |
139
8e1e4ca81016
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
128
diff
changeset
|
8 |
69 | 9 ;; This file is part of GNU Emacs. |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
13 ;; the Free Software Foundation; either version 2, or (at your option) |
69 | 14 ;; any later version. |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
22 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
23 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
24 | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
25 ;;; Code: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
26 |
2835
6af690e58256
(texinfo-tex-region): Update name of tex-set-buffer-directory.
Richard M. Stallman <rms@gnu.org>
parents:
2834
diff
changeset
|
27 ;;; Don't you dare insert any `require' calls at top level in this file--rms. |
2834
ce2187c33f4c
Don't require tex-mode or texnfo-upd.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
28 |
69 | 29 (defvar texinfo-mode-syntax-table nil) |
30 | |
31 (if texinfo-mode-syntax-table | |
32 nil | |
33 (setq texinfo-mode-syntax-table (make-syntax-table)) | |
34 (modify-syntax-entry ?\" " " texinfo-mode-syntax-table) | |
35 (modify-syntax-entry ?\\ " " texinfo-mode-syntax-table) | |
36 (modify-syntax-entry ?@ "\\" texinfo-mode-syntax-table) | |
37 (modify-syntax-entry ?\^q "\\" texinfo-mode-syntax-table) | |
38 (modify-syntax-entry ?\[ "(]" texinfo-mode-syntax-table) | |
39 (modify-syntax-entry ?\] ")[" texinfo-mode-syntax-table) | |
40 (modify-syntax-entry ?{ "(}" texinfo-mode-syntax-table) | |
41 (modify-syntax-entry ?} "){" texinfo-mode-syntax-table) | |
42 (modify-syntax-entry ?\' "w" texinfo-mode-syntax-table)) | |
43 | |
44 (defvar texinfo-mode-map nil) | |
45 | |
46 ;; Mode documentation displays commands in reverse order | |
47 ;; from how they are listed in the texinfo-mode-map. | |
48 (if texinfo-mode-map | |
49 nil | |
50 (setq texinfo-mode-map (make-sparse-keymap)) | |
51 | |
113
9827cb0af717
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
76
diff
changeset
|
52 (define-key texinfo-mode-map "\C-c\C-t\C-k" 'tex-kill-job) |
9827cb0af717
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
76
diff
changeset
|
53 (define-key texinfo-mode-map "\C-c\C-t\C-l" 'tex-recenter-output-buffer) |
9827cb0af717
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
76
diff
changeset
|
54 (define-key texinfo-mode-map "\C-c\C-t\C-q" 'tex-show-print-queue) |
9827cb0af717
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
76
diff
changeset
|
55 (define-key texinfo-mode-map "\C-c\C-t\C-p" 'texinfo-tex-print) |
1730
f79966ac4f9d
(texinfo-tex-command): Use texi2dvi.
Richard M. Stallman <rms@gnu.org>
parents:
1577
diff
changeset
|
56 ;; (define-key texinfo-mode-map "\C-c\C-t\C-i" 'texinfo-texindex) |
113
9827cb0af717
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
76
diff
changeset
|
57 (define-key texinfo-mode-map "\C-c\C-t\C-t" 'texinfo-tex-buffer) |
9827cb0af717
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
76
diff
changeset
|
58 (define-key texinfo-mode-map "\C-c\C-t\C-r" 'texinfo-tex-region) |
69 | 59 |
113
9827cb0af717
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
76
diff
changeset
|
60 (define-key texinfo-mode-map "\C-c\C-i\C-r" 'texinfo-format-region) |
9827cb0af717
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
76
diff
changeset
|
61 (define-key texinfo-mode-map "\C-c\C-i\C-b" 'texinfo-format-buffer) |
69 | 62 |
113
9827cb0af717
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
76
diff
changeset
|
63 (define-key texinfo-mode-map "\C-c\C-u\C-m" 'texinfo-make-menu) |
9827cb0af717
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
76
diff
changeset
|
64 (define-key texinfo-mode-map "\C-c\C-u\C-n" 'texinfo-update-node) |
9827cb0af717
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
76
diff
changeset
|
65 (define-key texinfo-mode-map "\C-c\C-u\C-e" 'texinfo-every-node-update) |
9827cb0af717
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
76
diff
changeset
|
66 (define-key texinfo-mode-map "\C-c\C-u\C-a" 'texinfo-all-menus-update) |
69 | 67 |
68 (define-key texinfo-mode-map "\C-c\C-s" 'texinfo-show-structure) | |
69 | |
2834
ce2187c33f4c
Don't require tex-mode or texnfo-upd.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
70 ;;; (define-key texinfo-mode-map "\"" 'texinfo-insert-quote) |
893 | 71 (define-key texinfo-mode-map "\C-c}" 'up-list) |
72 (define-key texinfo-mode-map "\C-c{" 'texinfo-insert-braces) | |
69 | 73 |
74 (define-key texinfo-mode-map "\C-c\C-cv" 'texinfo-insert-@var) | |
75 (define-key texinfo-mode-map "\C-c\C-cs" 'texinfo-insert-@samp) | |
76 (define-key texinfo-mode-map "\C-c\C-co" 'texinfo-insert-@noindent) | |
77 (define-key texinfo-mode-map "\C-c\C-cn" 'texinfo-insert-@node) | |
78 (define-key texinfo-mode-map "\C-c\C-ck" 'texinfo-insert-@kbd) | |
79 (define-key texinfo-mode-map "\C-c\C-ci" 'texinfo-insert-@item) | |
80 (define-key texinfo-mode-map "\C-c\C-cx" 'texinfo-insert-@example) | |
81 (define-key texinfo-mode-map "\C-c\C-ce" 'texinfo-insert-@end-example) | |
82 (define-key texinfo-mode-map "\C-c\C-cd" 'texinfo-insert-@dfn) | |
83 (define-key texinfo-mode-map "\C-c\C-cc" 'texinfo-insert-@code)) | |
84 | |
2834
ce2187c33f4c
Don't require tex-mode or texnfo-upd.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
85 ;;; I turned this off because it is inconvenient. |
ce2187c33f4c
Don't require tex-mode or texnfo-upd.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
86 ;;; The real " character is used often in texinfo files. --rms. |
ce2187c33f4c
Don't require tex-mode or texnfo-upd.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
87 ;;;(defun texinfo-insert-quote (arg) |
ce2187c33f4c
Don't require tex-mode or texnfo-upd.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
88 ;;; "Insert the appropriate quote marks for TeX. |
ce2187c33f4c
Don't require tex-mode or texnfo-upd.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
89 ;;;Inserts the value of `tex-open-quote' (normally ``) or `tex-close-quote' |
ce2187c33f4c
Don't require tex-mode or texnfo-upd.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
90 ;;;\(normally '') depending on the context. With prefix argument, always |
ce2187c33f4c
Don't require tex-mode or texnfo-upd.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
91 ;;;inserts \" characters." |
ce2187c33f4c
Don't require tex-mode or texnfo-upd.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
92 ;;; (interactive "*P") |
ce2187c33f4c
Don't require tex-mode or texnfo-upd.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
93 ;;; (if arg |
ce2187c33f4c
Don't require tex-mode or texnfo-upd.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
94 ;;; (self-insert-command (prefix-numeric-value arg)) |
ce2187c33f4c
Don't require tex-mode or texnfo-upd.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
95 ;;; (insert |
ce2187c33f4c
Don't require tex-mode or texnfo-upd.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
96 ;;; (cond ((or (bobp) |
ce2187c33f4c
Don't require tex-mode or texnfo-upd.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
97 ;;; (save-excursion |
ce2187c33f4c
Don't require tex-mode or texnfo-upd.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
98 ;;; (forward-char -1) |
ce2187c33f4c
Don't require tex-mode or texnfo-upd.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
99 ;;; (looking-at "\\s(\\|\\s \\|\\s>"))) |
ce2187c33f4c
Don't require tex-mode or texnfo-upd.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
100 ;;; tex-open-quote) |
ce2187c33f4c
Don't require tex-mode or texnfo-upd.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
101 ;;; ((= (preceding-char) ?\\) |
ce2187c33f4c
Don't require tex-mode or texnfo-upd.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
102 ;;; ?\") |
ce2187c33f4c
Don't require tex-mode or texnfo-upd.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
103 ;;; (t |
ce2187c33f4c
Don't require tex-mode or texnfo-upd.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
104 ;;; tex-close-quote))))) |
ce2187c33f4c
Don't require tex-mode or texnfo-upd.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
105 |
69 | 106 (defun texinfo-insert-@var () |
107 "Insert the string @var in a texinfo buffer." | |
108 (interactive) | |
109 (insert "@var{}") | |
110 (backward-char)) | |
111 | |
112 (defun texinfo-insert-@samp () | |
113 "Insert the string @samp in a texinfo buffer." | |
114 (interactive) | |
115 (insert "@samp{}") | |
116 (backward-char)) | |
117 | |
118 (defun texinfo-insert-@noindent () | |
119 "Insert the string @noindent in a texinfo buffer." | |
120 (interactive) | |
121 (insert "@noindent\n")) | |
122 | |
123 (defun texinfo-insert-@node () | |
124 "Insert the string @node in a texinfo buffer, | |
125 along with a comment indicating the arguments to @node." | |
126 (interactive) | |
127 (insert "@node \n@comment node-name, next, previous, up") | |
128 (forward-line -1) | |
129 (forward-char 6)) | |
130 | |
131 (defun texinfo-insert-@kbd () | |
132 "Insert the string @kbd in a texinfo buffer." | |
133 (interactive) | |
134 (insert "@kbd{}") | |
135 (backward-char)) | |
136 | |
137 (defun texinfo-insert-@item () | |
138 "Insert the string @item in a texinfo buffer." | |
139 (interactive) | |
140 (insert "@item") | |
141 (newline)) | |
142 | |
143 (defun texinfo-insert-@example () | |
144 "Insert the string @example in a texinfo buffer." | |
145 (interactive) | |
146 (insert "@example\n")) | |
147 | |
148 (defun texinfo-insert-@end-example () | |
149 "Insert the string @end example in a texinfo buffer." | |
150 (interactive) | |
151 (insert "@end example\n")) | |
152 | |
153 (defun texinfo-insert-@dfn () | |
154 "Insert the string @dfn in a texinfo buffer." | |
155 (interactive) | |
156 (insert "@dfn{}") | |
157 (backward-char)) | |
158 | |
159 (defun texinfo-insert-@code () | |
160 "Insert the string @code in a texinfo buffer." | |
161 (interactive) | |
162 (insert "@code{}") | |
163 (backward-char)) | |
164 | |
165 (defun texinfo-insert-braces () | |
166 "Make a pair of braces and be poised to type inside of them. | |
167 Use \\[up-list] to move forward out of the braces." | |
168 (interactive) | |
169 (insert "{}") | |
170 (backward-char)) | |
171 | |
258 | 172 ;;;###autoload |
69 | 173 (defun texinfo-mode () |
76
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
174 "Major mode for editing Texinfo files. |
69 | 175 |
176 It has these extra commands: | |
177 \\{texinfo-mode-map} | |
178 | |
76
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
179 These are files that are used as input for TeX to make printed manuals |
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
180 and also to be turned into Info files by \\[texinfo-format-buffer] or |
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
181 `makeinfo'. These files must be written in a very restricted and |
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
182 modified version of TeX input format. |
69 | 183 |
184 Editing commands are like text-mode except that the syntax table is | |
76
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
185 set up so expression commands skip Texinfo bracket groups. To see |
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
186 what the Info version of a region of the Texinfo file will look like, |
69 | 187 use \\[texinfo-format-region]. This command runs Info on the current region |
76
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
188 of the Texinfo file and formats it properly. |
69 | 189 |
76
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
190 You can show the structure of a Texinfo file with \\[texinfo-show-structure]. |
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
191 This command shows the structure of a Texinfo file by listing the |
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
192 lines with the @-sign commands for @chapter, @section, and the like. |
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
193 These lines are displayed in another window called the *Occur* window. |
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
194 In that window, you can position the cursor over one of the lines and |
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
195 use \\[occur-mode-goto-occurrence], to jump to the corresponding spot |
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
196 in the Texinfo file. |
69 | 197 |
76
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
198 In addition, Texinfo mode provides commands that insert various |
69 | 199 frequently used @-sign commands into the buffer. You can use these |
200 commands to save keystrokes. And you can insert balanced braces with | |
201 \\[texinfo-insert-braces] and later use the command \\[up-list] to | |
202 move forward past the closing brace. | |
203 | |
76
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
204 Also, Texinfo mode provides functions for automatically creating or |
69 | 205 updating menus and node pointers. These functions |
206 | |
207 * insert the `Next', `Previous' and `Up' pointers of a node, | |
208 * insert or update the menu for a section, and | |
76
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
209 * create a master menu for a Texinfo source file. |
69 | 210 |
211 Here are the functions: | |
212 | |
213 texinfo-update-node \\[texinfo-update-node] | |
214 texinfo-every-node-update \\[texinfo-every-node-update] | |
215 texinfo-sequential-node-update | |
216 | |
217 texinfo-make-menu \\[texinfo-make-menu] | |
218 texinfo-all-menus-update \\[texinfo-all-menus-update] | |
219 texinfo-master-menu | |
220 | |
221 texinfo-indent-menu-description (column &optional region-p) | |
222 | |
223 The `texinfo-column-for-description' variable specifies the column to | |
224 which menu descriptions are indented. | |
225 | |
226 Passed an argument (a prefix argument, if interactive), the | |
227 `texinfo-update-node' and `texinfo-make-menu' functions do their jobs | |
228 in the region. | |
229 | |
76
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
230 To use the updating commands, you must structure your Texinfo file |
69 | 231 hierarchically, such that each `@node' line, with the exception of the |
76
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
232 Top node, is accompanied by some kind of section line, such as an |
69 | 233 `@chapter' or `@section' line. |
234 | |
235 If the file has a `top' node, it must be called `top' or `Top' and | |
236 be the first node in the file. | |
237 | |
76
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
238 Entering Texinfo mode calls the value of text-mode-hook, and then the |
69 | 239 value of texinfo-mode-hook." |
240 (interactive) | |
241 (text-mode) | |
1188
a6d32838af49
(texinfo-mode): Capitalize the mode name string.
Richard M. Stallman <rms@gnu.org>
parents:
893
diff
changeset
|
242 (setq mode-name "Texinfo") |
69 | 243 (setq major-mode 'texinfo-mode) |
244 (use-local-map texinfo-mode-map) | |
245 (set-syntax-table texinfo-mode-syntax-table) | |
246 (make-local-variable 'require-final-newline) | |
247 (setq require-final-newline t) | |
1833
ce05243e2491
* texinfo.el (texinfo-mode): Make page-delimiter buffer-local, and
Jim Blandy <jimb@redhat.com>
parents:
1730
diff
changeset
|
248 (make-local-variable 'page-delimiter) |
ce05243e2491
* texinfo.el (texinfo-mode): Make page-delimiter buffer-local, and
Jim Blandy <jimb@redhat.com>
parents:
1730
diff
changeset
|
249 (setq page-delimiter texinfo-chapter-level-regexp) |
69 | 250 (make-local-variable 'paragraph-separate) |
251 (setq paragraph-separate (concat "^\b\\|^@[a-zA-Z]*[ \n]\\|" paragraph-separate)) | |
252 (make-local-variable 'paragraph-start) | |
253 (setq paragraph-start (concat "^\b\\|^@[a-zA-Z]*[ \n]\\|" paragraph-start)) | |
254 (make-local-variable 'fill-column) | |
255 (setq fill-column 72) | |
256 (make-local-variable 'comment-start) | |
257 (setq comment-start "@c ") | |
258 (make-local-variable 'comment-start-skip) | |
259 (setq comment-start-skip "@c +") | |
260 (make-local-variable 'words-include-escapes) | |
261 (setq words-include-escapes t) | |
262 (make-local-variable 'tex-start-of-header) | |
263 (setq tex-start-of-header "%**start of header") | |
264 (make-local-variable 'tex-end-of-header) | |
265 (setq tex-end-of-header "%**end of header") | |
266 (make-local-variable 'tex-trailer) | |
267 (setq tex-trailer "@bye\n") | |
268 (run-hooks 'text-mode-hook 'texinfo-mode-hook)) | |
269 | |
270 | |
76
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
271 ;;; Texinfo file structure |
69 | 272 |
273 ; The following is defined in `texnfo-upd.el' | |
274 ; (defvar texinfo-section-types-regexp | |
275 ; "^@\\(chapter \\|sect\\|sub\\|unnum\\|major\\|heading \\|appendix\\)" | |
276 ; "Regexp matching chapter, section, other headings (but not the top node).") | |
277 | |
76
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
278 (defun texinfo-show-structure (&optional nodes-too) |
69 | 279 "Show the structure of a Texinfo file. |
76
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
280 List the lines in the file that begin with the @-sign commands for |
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
281 @chapter, @section, and the like. |
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
282 |
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
283 With optional argument (prefix if interactive), list both the lines |
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
284 with @-sign commands for @chapter, @section, and the like, and list |
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
285 @node lines. |
69 | 286 |
287 Lines with structuring commands beginning in them are displayed in | |
288 another window called the *Occur* window. In that window, you can | |
289 position the cursor over one of the lines and use | |
76
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
290 \\[occur-mode-goto-occurrence], |
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
291 to jump to the corresponding spot in the Texinfo file." |
69 | 292 |
293 (interactive "P") | |
294 (save-excursion | |
295 (goto-char (point-min)) | |
76
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
296 (if nodes-too |
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
297 (occur (concat "\\(^@node\\)\\|" texinfo-section-types-regexp)) |
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
298 (occur texinfo-section-types-regexp))) |
69 | 299 (pop-to-buffer "*Occur*") |
300 (goto-char (point-min)) | |
301 (flush-lines "-----")) | |
302 | |
303 | |
304 ;;; texinfo mode tex and hardcopy printing commands. | |
305 | |
306 ;; These commands are for running tex on a region of a texinfo file in | |
307 ;; GNU Emacs, or on the whole buffer, and for printing the resulting | |
308 ;; .dvi file. The three commands are: | |
309 | |
310 ; texinfo-tex-region to run tex on the current region. | |
311 ; texinfo-tex-buffer to run tex on the current buffer. | |
312 ; texinfo-tex-print to print the .dvi file made by tex | |
313 | |
314 ;;; Other useful functions | |
315 | |
316 ; These functions are provided by `tex-mode.el' but are bound to keys | |
317 ; in texinfo mode. | |
318 | |
319 ; tex-kill-job to kill the currently running tex job | |
320 ; tex-recenter-output-buffer to redisplay tex job output buffer | |
321 ; tex-show-print-queue to show the print queue | |
322 | |
323 ; Various variables are provided by `tex-mode.el' | |
324 | |
325 ; tex mode variable Default Value | |
326 | |
327 ; tex-dvi-print-command "lpr -d" | |
328 ; tex-directory "/tmp/" | |
329 ; tex-show-queue-command "lpq" | |
330 ; tex-shell-cd-command "cd" | |
331 ; tex-zap-file nil (created as needed) | |
332 | |
333 | |
334 ;;; The tex and print function definitions: | |
335 | |
1730
f79966ac4f9d
(texinfo-tex-command): Use texi2dvi.
Richard M. Stallman <rms@gnu.org>
parents:
1577
diff
changeset
|
336 (defvar texinfo-tex-command "texi2dvi" |
69 | 337 "*Command used by texinfo-tex-region to run tex on a region.") |
338 | |
1730
f79966ac4f9d
(texinfo-tex-command): Use texi2dvi.
Richard M. Stallman <rms@gnu.org>
parents:
1577
diff
changeset
|
339 ;;(defvar texinfo-texindex-command "texindex" |
f79966ac4f9d
(texinfo-tex-command): Use texi2dvi.
Richard M. Stallman <rms@gnu.org>
parents:
1577
diff
changeset
|
340 ;; "*Command used by texinfo-texindex to sort unsorted index files.") |
69 | 341 |
342 (defun texinfo-tex-region (beg end) | |
1577 | 343 "Run tex on the current region. |
344 A temporary file (`tex-zap-file') is written in directory `tex-directory', and | |
345 tex is run in that directory. The first line of the file is copied to the | |
346 temporary file; and if the buffer has a header, it is written to the | |
347 temporary file before the region itself. The buffer's header is all lines | |
348 between the strings defined by `tex-start-of-header' and `tex-end-of-header' | |
349 inclusive. The header must start in the first 100 lines. The value of | |
350 tex-trailer is appended to the temporary file after the region." | |
69 | 351 (interactive "r") |
2834
ce2187c33f4c
Don't require tex-mode or texnfo-upd.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
352 (require 'tex-mode) |
69 | 353 (if (get-buffer "*tex-shell*") |
354 (tex-kill-job) | |
355 (tex-start-shell)) | |
356 (or tex-zap-file (setq tex-zap-file (make-temp-name "#tz"))) | |
357 (let ((tex-out-file (concat tex-zap-file ".tex")) | |
358 (temp-buffer (get-buffer-create " tex-Output-Buffer")) | |
359 (zap-directory | |
360 (file-name-as-directory (expand-file-name tex-directory)))) | |
361 (save-excursion | |
362 (save-restriction | |
363 (widen) | |
364 (goto-char (point-min)) | |
365 (forward-line 100) | |
366 (let ((search-end (point)) | |
367 (hbeg (point-min)) (hend (point-min)) | |
368 (default-directory zap-directory)) | |
369 (goto-char (point-min)) | |
370 | |
371 ;; Copy first line, the `\input texinfo' line, to temp file | |
372 (write-region (point) | |
373 (save-excursion (end-of-line) (point)) | |
374 tex-out-file nil nil) | |
375 | |
376 ;; Don't copy first line twice if region includes it. | |
377 (forward-line 1) | |
378 (if (< beg (point)) (setq beg (point))) | |
379 | |
380 ;; Initialize the temp file with either the header or nothing | |
381 (if (search-forward tex-start-of-header search-end t) | |
382 (progn | |
383 (beginning-of-line) | |
384 (setq hbeg (point)) ; Mark beginning of header. | |
385 (if (search-forward tex-end-of-header nil t) | |
386 (progn (beginning-of-line) | |
387 (setq hend (point))) ; Mark end of header. | |
388 (setq hbeg (point-min))))) ; Else no header. | |
389 | |
390 ;; Copy header to temp file. | |
391 (write-region (min hbeg beg) hend tex-out-file t nil) | |
392 | |
393 ;; Copy region to temp file. | |
394 (write-region (max beg hend) end tex-out-file t nil)) | |
395 | |
396 ;; This is a kludge to insert the tex-trailer into the tex-out-file. | |
397 ;; We have to create a special buffer in which to insert | |
398 ;; the tex-trailer first because there is no function with | |
399 ;; which to append a literal string directly to a file. | |
400 (let ((local-tex-trailer tex-trailer)) | |
401 (set-buffer temp-buffer) | |
402 (erase-buffer) | |
403 ;; make sure trailer isn't hidden by a comment | |
404 (insert-string "\n") | |
405 (if local-tex-trailer (insert-string local-tex-trailer)) | |
2835
6af690e58256
(texinfo-tex-region): Update name of tex-set-buffer-directory.
Richard M. Stallman <rms@gnu.org>
parents:
2834
diff
changeset
|
406 (tex-set-buffer-directory temp-buffer zap-directory) |
69 | 407 (write-region (point-min) (point-max) tex-out-file t nil)))) |
408 | |
2835
6af690e58256
(texinfo-tex-region): Update name of tex-set-buffer-directory.
Richard M. Stallman <rms@gnu.org>
parents:
2834
diff
changeset
|
409 (tex-set-buffer-directory "*tex-shell*" zap-directory) |
69 | 410 (send-string "tex-shell" (concat tex-shell-cd-command " " |
411 zap-directory "\n")) | |
412 (send-string "tex-shell" (concat texinfo-tex-command " " | |
413 tex-out-file "\n"))) | |
414 (tex-recenter-output-buffer 0)) | |
415 | |
416 (defun texinfo-tex-buffer () | |
417 "Run tex on current buffer. | |
418 See \\[texinfo-tex-region] for more information." | |
419 (interactive) | |
420 (texinfo-tex-region (point-min) (point-max))) | |
421 | |
1730
f79966ac4f9d
(texinfo-tex-command): Use texi2dvi.
Richard M. Stallman <rms@gnu.org>
parents:
1577
diff
changeset
|
422 ;;(defun texinfo-texindex () |
f79966ac4f9d
(texinfo-tex-command): Use texi2dvi.
Richard M. Stallman <rms@gnu.org>
parents:
1577
diff
changeset
|
423 ;; "Run texindex on unsorted index files. |
f79966ac4f9d
(texinfo-tex-command): Use texi2dvi.
Richard M. Stallman <rms@gnu.org>
parents:
1577
diff
changeset
|
424 ;;The index files are made by \\[texinfo-tex-region] or \\[texinfo-tex-buffer]. |
f79966ac4f9d
(texinfo-tex-command): Use texi2dvi.
Richard M. Stallman <rms@gnu.org>
parents:
1577
diff
changeset
|
425 ;;Runs the shell command defined by `texinfo-texindex-command'." |
f79966ac4f9d
(texinfo-tex-command): Use texi2dvi.
Richard M. Stallman <rms@gnu.org>
parents:
1577
diff
changeset
|
426 ;; (interactive) |
f79966ac4f9d
(texinfo-tex-command): Use texi2dvi.
Richard M. Stallman <rms@gnu.org>
parents:
1577
diff
changeset
|
427 ;; (send-string "tex-shell" |
f79966ac4f9d
(texinfo-tex-command): Use texi2dvi.
Richard M. Stallman <rms@gnu.org>
parents:
1577
diff
changeset
|
428 ;; (concat texinfo-texindex-command |
f79966ac4f9d
(texinfo-tex-command): Use texi2dvi.
Richard M. Stallman <rms@gnu.org>
parents:
1577
diff
changeset
|
429 ;; " " tex-zap-file ".??" "\n")) |
f79966ac4f9d
(texinfo-tex-command): Use texi2dvi.
Richard M. Stallman <rms@gnu.org>
parents:
1577
diff
changeset
|
430 ;; (tex-recenter-output-buffer nil)) |
69 | 431 |
432 (defun texinfo-tex-print () | |
433 "Print .dvi file made by \\[texinfo-tex-region] or \\[texinfo-tex-buffer]. | |
1577 | 434 Runs the shell command defined by `tex-dvi-print-command'." |
69 | 435 (interactive) |
2834
ce2187c33f4c
Don't require tex-mode or texnfo-upd.
Richard M. Stallman <rms@gnu.org>
parents:
2233
diff
changeset
|
436 (require 'tex-mode) |
69 | 437 (send-string "tex-shell" |
438 (concat tex-dvi-print-command | |
439 " " tex-zap-file ".dvi" "\n")) | |
440 (tex-recenter-output-buffer nil)) | |
441 | |
584 | 442 (provide 'texinfo) |
443 | |
657
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
444 ;;; texinfo.el ends here |