Mercurial > emacs
annotate lisp/textmodes/texinfo.el @ 2594:e1277aec1738
(gud-format-command): Fix %f expansuuin to send ondly the basename of
files to gdb.
author | Eric S. Raymond <esr@snark.thyrsus.com> |
---|---|
date | Tue, 27 Apr 1993 21:59:46 +0000 |
parents | fb0ed5a1d0f3 |
children | ce2187c33f4c |
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 |
69 | 27 (require 'texnfo-upd) |
28 (require 'tex-mode) | |
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 | |
76
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
70 (define-key texinfo-mode-map "\"" 'tex-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 | |
85 (defun texinfo-insert-@var () | |
86 "Insert the string @var in a texinfo buffer." | |
87 (interactive) | |
88 (insert "@var{}") | |
89 (backward-char)) | |
90 | |
91 (defun texinfo-insert-@samp () | |
92 "Insert the string @samp in a texinfo buffer." | |
93 (interactive) | |
94 (insert "@samp{}") | |
95 (backward-char)) | |
96 | |
97 (defun texinfo-insert-@noindent () | |
98 "Insert the string @noindent in a texinfo buffer." | |
99 (interactive) | |
100 (insert "@noindent\n")) | |
101 | |
102 (defun texinfo-insert-@node () | |
103 "Insert the string @node in a texinfo buffer, | |
104 along with a comment indicating the arguments to @node." | |
105 (interactive) | |
106 (insert "@node \n@comment node-name, next, previous, up") | |
107 (forward-line -1) | |
108 (forward-char 6)) | |
109 | |
110 (defun texinfo-insert-@kbd () | |
111 "Insert the string @kbd in a texinfo buffer." | |
112 (interactive) | |
113 (insert "@kbd{}") | |
114 (backward-char)) | |
115 | |
116 (defun texinfo-insert-@item () | |
117 "Insert the string @item in a texinfo buffer." | |
118 (interactive) | |
119 (insert "@item") | |
120 (newline)) | |
121 | |
122 (defun texinfo-insert-@example () | |
123 "Insert the string @example in a texinfo buffer." | |
124 (interactive) | |
125 (insert "@example\n")) | |
126 | |
127 (defun texinfo-insert-@end-example () | |
128 "Insert the string @end example in a texinfo buffer." | |
129 (interactive) | |
130 (insert "@end example\n")) | |
131 | |
132 (defun texinfo-insert-@dfn () | |
133 "Insert the string @dfn in a texinfo buffer." | |
134 (interactive) | |
135 (insert "@dfn{}") | |
136 (backward-char)) | |
137 | |
138 (defun texinfo-insert-@code () | |
139 "Insert the string @code in a texinfo buffer." | |
140 (interactive) | |
141 (insert "@code{}") | |
142 (backward-char)) | |
143 | |
144 (defun texinfo-insert-braces () | |
145 "Make a pair of braces and be poised to type inside of them. | |
146 Use \\[up-list] to move forward out of the braces." | |
147 (interactive) | |
148 (insert "{}") | |
149 (backward-char)) | |
150 | |
258 | 151 ;;;###autoload |
69 | 152 (defun texinfo-mode () |
76
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
153 "Major mode for editing Texinfo files. |
69 | 154 |
155 It has these extra commands: | |
156 \\{texinfo-mode-map} | |
157 | |
76
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
158 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
|
159 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
|
160 `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
|
161 modified version of TeX input format. |
69 | 162 |
163 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
|
164 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
|
165 what the Info version of a region of the Texinfo file will look like, |
69 | 166 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
|
167 of the Texinfo file and formats it properly. |
69 | 168 |
76
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
169 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
|
170 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
|
171 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
|
172 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
|
173 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
|
174 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
|
175 in the Texinfo file. |
69 | 176 |
76
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
177 In addition, Texinfo mode provides commands that insert various |
69 | 178 frequently used @-sign commands into the buffer. You can use these |
179 commands to save keystrokes. And you can insert balanced braces with | |
180 \\[texinfo-insert-braces] and later use the command \\[up-list] to | |
181 move forward past the closing brace. | |
182 | |
76
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
183 Also, Texinfo mode provides functions for automatically creating or |
69 | 184 updating menus and node pointers. These functions |
185 | |
186 * insert the `Next', `Previous' and `Up' pointers of a node, | |
187 * insert or update the menu for a section, and | |
76
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
188 * create a master menu for a Texinfo source file. |
69 | 189 |
190 Here are the functions: | |
191 | |
192 texinfo-update-node \\[texinfo-update-node] | |
193 texinfo-every-node-update \\[texinfo-every-node-update] | |
194 texinfo-sequential-node-update | |
195 | |
196 texinfo-make-menu \\[texinfo-make-menu] | |
197 texinfo-all-menus-update \\[texinfo-all-menus-update] | |
198 texinfo-master-menu | |
199 | |
200 texinfo-indent-menu-description (column &optional region-p) | |
201 | |
202 The `texinfo-column-for-description' variable specifies the column to | |
203 which menu descriptions are indented. | |
204 | |
205 Passed an argument (a prefix argument, if interactive), the | |
206 `texinfo-update-node' and `texinfo-make-menu' functions do their jobs | |
207 in the region. | |
208 | |
76
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
209 To use the updating commands, you must structure your Texinfo file |
69 | 210 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
|
211 Top node, is accompanied by some kind of section line, such as an |
69 | 212 `@chapter' or `@section' line. |
213 | |
214 If the file has a `top' node, it must be called `top' or `Top' and | |
215 be the first node in the file. | |
216 | |
76
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
217 Entering Texinfo mode calls the value of text-mode-hook, and then the |
69 | 218 value of texinfo-mode-hook." |
219 (interactive) | |
220 (text-mode) | |
1188
a6d32838af49
(texinfo-mode): Capitalize the mode name string.
Richard M. Stallman <rms@gnu.org>
parents:
893
diff
changeset
|
221 (setq mode-name "Texinfo") |
69 | 222 (setq major-mode 'texinfo-mode) |
223 (use-local-map texinfo-mode-map) | |
224 (set-syntax-table texinfo-mode-syntax-table) | |
225 (make-local-variable 'require-final-newline) | |
226 (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
|
227 (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
|
228 (setq page-delimiter texinfo-chapter-level-regexp) |
69 | 229 (make-local-variable 'paragraph-separate) |
230 (setq paragraph-separate (concat "^\b\\|^@[a-zA-Z]*[ \n]\\|" paragraph-separate)) | |
231 (make-local-variable 'paragraph-start) | |
232 (setq paragraph-start (concat "^\b\\|^@[a-zA-Z]*[ \n]\\|" paragraph-start)) | |
233 (make-local-variable 'fill-column) | |
234 (setq fill-column 72) | |
235 (make-local-variable 'comment-start) | |
236 (setq comment-start "@c ") | |
237 (make-local-variable 'comment-start-skip) | |
238 (setq comment-start-skip "@c +") | |
239 (make-local-variable 'words-include-escapes) | |
240 (setq words-include-escapes t) | |
241 (make-local-variable 'tex-start-of-header) | |
242 (setq tex-start-of-header "%**start of header") | |
243 (make-local-variable 'tex-end-of-header) | |
244 (setq tex-end-of-header "%**end of header") | |
245 (make-local-variable 'tex-trailer) | |
246 (setq tex-trailer "@bye\n") | |
247 (run-hooks 'text-mode-hook 'texinfo-mode-hook)) | |
248 | |
249 | |
76
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
250 ;;; Texinfo file structure |
69 | 251 |
252 ; The following is defined in `texnfo-upd.el' | |
253 ; (defvar texinfo-section-types-regexp | |
254 ; "^@\\(chapter \\|sect\\|sub\\|unnum\\|major\\|heading \\|appendix\\)" | |
255 ; "Regexp matching chapter, section, other headings (but not the top node).") | |
256 | |
76
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
257 (defun texinfo-show-structure (&optional nodes-too) |
69 | 258 "Show the structure of a Texinfo file. |
76
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
259 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
|
260 @chapter, @section, and the like. |
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
261 |
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
262 With optional argument (prefix if interactive), list both the lines |
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
263 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
|
264 @node lines. |
69 | 265 |
266 Lines with structuring commands beginning in them are displayed in | |
267 another window called the *Occur* window. In that window, you can | |
268 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
|
269 \\[occur-mode-goto-occurrence], |
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
270 to jump to the corresponding spot in the Texinfo file." |
69 | 271 |
272 (interactive "P") | |
273 (save-excursion | |
274 (goto-char (point-min)) | |
76
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
275 (if nodes-too |
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
276 (occur (concat "\\(^@node\\)\\|" texinfo-section-types-regexp)) |
a983e9bbadc1
*** empty log message ***
Robert J. Chassell <bob@rattlesnake.com>
parents:
69
diff
changeset
|
277 (occur texinfo-section-types-regexp))) |
69 | 278 (pop-to-buffer "*Occur*") |
279 (goto-char (point-min)) | |
280 (flush-lines "-----")) | |
281 | |
282 | |
283 ;;; texinfo mode tex and hardcopy printing commands. | |
284 | |
285 ;; These commands are for running tex on a region of a texinfo file in | |
286 ;; GNU Emacs, or on the whole buffer, and for printing the resulting | |
287 ;; .dvi file. The three commands are: | |
288 | |
289 ; texinfo-tex-region to run tex on the current region. | |
290 ; texinfo-tex-buffer to run tex on the current buffer. | |
291 ; texinfo-tex-print to print the .dvi file made by tex | |
292 | |
293 ;;; Other useful functions | |
294 | |
295 ; These functions are provided by `tex-mode.el' but are bound to keys | |
296 ; in texinfo mode. | |
297 | |
298 ; tex-kill-job to kill the currently running tex job | |
299 ; tex-recenter-output-buffer to redisplay tex job output buffer | |
300 ; tex-show-print-queue to show the print queue | |
301 | |
302 ; Various variables are provided by `tex-mode.el' | |
303 | |
304 ; tex mode variable Default Value | |
305 | |
306 ; tex-dvi-print-command "lpr -d" | |
307 ; tex-directory "/tmp/" | |
308 ; tex-show-queue-command "lpq" | |
309 ; tex-shell-cd-command "cd" | |
310 ; tex-zap-file nil (created as needed) | |
311 | |
312 | |
313 ;;; The tex and print function definitions: | |
314 | |
1730
f79966ac4f9d
(texinfo-tex-command): Use texi2dvi.
Richard M. Stallman <rms@gnu.org>
parents:
1577
diff
changeset
|
315 (defvar texinfo-tex-command "texi2dvi" |
69 | 316 "*Command used by texinfo-tex-region to run tex on a region.") |
317 | |
1730
f79966ac4f9d
(texinfo-tex-command): Use texi2dvi.
Richard M. Stallman <rms@gnu.org>
parents:
1577
diff
changeset
|
318 ;;(defvar texinfo-texindex-command "texindex" |
f79966ac4f9d
(texinfo-tex-command): Use texi2dvi.
Richard M. Stallman <rms@gnu.org>
parents:
1577
diff
changeset
|
319 ;; "*Command used by texinfo-texindex to sort unsorted index files.") |
69 | 320 |
321 (defun texinfo-tex-region (beg end) | |
1577 | 322 "Run tex on the current region. |
323 A temporary file (`tex-zap-file') is written in directory `tex-directory', and | |
324 tex is run in that directory. The first line of the file is copied to the | |
325 temporary file; and if the buffer has a header, it is written to the | |
326 temporary file before the region itself. The buffer's header is all lines | |
327 between the strings defined by `tex-start-of-header' and `tex-end-of-header' | |
328 inclusive. The header must start in the first 100 lines. The value of | |
329 tex-trailer is appended to the temporary file after the region." | |
69 | 330 (interactive "r") |
331 (if (get-buffer "*tex-shell*") | |
332 (tex-kill-job) | |
333 (tex-start-shell)) | |
334 (or tex-zap-file (setq tex-zap-file (make-temp-name "#tz"))) | |
335 (let ((tex-out-file (concat tex-zap-file ".tex")) | |
336 (temp-buffer (get-buffer-create " tex-Output-Buffer")) | |
337 (zap-directory | |
338 (file-name-as-directory (expand-file-name tex-directory)))) | |
339 (save-excursion | |
340 (save-restriction | |
341 (widen) | |
342 (goto-char (point-min)) | |
343 (forward-line 100) | |
344 (let ((search-end (point)) | |
345 (hbeg (point-min)) (hend (point-min)) | |
346 (default-directory zap-directory)) | |
347 (goto-char (point-min)) | |
348 | |
349 ;; Copy first line, the `\input texinfo' line, to temp file | |
350 (write-region (point) | |
351 (save-excursion (end-of-line) (point)) | |
352 tex-out-file nil nil) | |
353 | |
354 ;; Don't copy first line twice if region includes it. | |
355 (forward-line 1) | |
356 (if (< beg (point)) (setq beg (point))) | |
357 | |
358 ;; Initialize the temp file with either the header or nothing | |
359 (if (search-forward tex-start-of-header search-end t) | |
360 (progn | |
361 (beginning-of-line) | |
362 (setq hbeg (point)) ; Mark beginning of header. | |
363 (if (search-forward tex-end-of-header nil t) | |
364 (progn (beginning-of-line) | |
365 (setq hend (point))) ; Mark end of header. | |
366 (setq hbeg (point-min))))) ; Else no header. | |
367 | |
368 ;; Copy header to temp file. | |
369 (write-region (min hbeg beg) hend tex-out-file t nil) | |
370 | |
371 ;; Copy region to temp file. | |
372 (write-region (max beg hend) end tex-out-file t nil)) | |
373 | |
374 ;; This is a kludge to insert the tex-trailer into the tex-out-file. | |
375 ;; We have to create a special buffer in which to insert | |
376 ;; the tex-trailer first because there is no function with | |
377 ;; which to append a literal string directly to a file. | |
378 (let ((local-tex-trailer tex-trailer)) | |
379 (set-buffer temp-buffer) | |
380 (erase-buffer) | |
381 ;; make sure trailer isn't hidden by a comment | |
382 (insert-string "\n") | |
383 (if local-tex-trailer (insert-string local-tex-trailer)) | |
384 (set-buffer-directory temp-buffer zap-directory) | |
385 (write-region (point-min) (point-max) tex-out-file t nil)))) | |
386 | |
387 (set-buffer-directory "*tex-shell*" zap-directory) | |
388 (send-string "tex-shell" (concat tex-shell-cd-command " " | |
389 zap-directory "\n")) | |
390 (send-string "tex-shell" (concat texinfo-tex-command " " | |
391 tex-out-file "\n"))) | |
392 (tex-recenter-output-buffer 0)) | |
393 | |
394 (defun texinfo-tex-buffer () | |
395 "Run tex on current buffer. | |
396 See \\[texinfo-tex-region] for more information." | |
397 (interactive) | |
398 (texinfo-tex-region (point-min) (point-max))) | |
399 | |
1730
f79966ac4f9d
(texinfo-tex-command): Use texi2dvi.
Richard M. Stallman <rms@gnu.org>
parents:
1577
diff
changeset
|
400 ;;(defun texinfo-texindex () |
f79966ac4f9d
(texinfo-tex-command): Use texi2dvi.
Richard M. Stallman <rms@gnu.org>
parents:
1577
diff
changeset
|
401 ;; "Run texindex on unsorted index files. |
f79966ac4f9d
(texinfo-tex-command): Use texi2dvi.
Richard M. Stallman <rms@gnu.org>
parents:
1577
diff
changeset
|
402 ;;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
|
403 ;;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
|
404 ;; (interactive) |
f79966ac4f9d
(texinfo-tex-command): Use texi2dvi.
Richard M. Stallman <rms@gnu.org>
parents:
1577
diff
changeset
|
405 ;; (send-string "tex-shell" |
f79966ac4f9d
(texinfo-tex-command): Use texi2dvi.
Richard M. Stallman <rms@gnu.org>
parents:
1577
diff
changeset
|
406 ;; (concat texinfo-texindex-command |
f79966ac4f9d
(texinfo-tex-command): Use texi2dvi.
Richard M. Stallman <rms@gnu.org>
parents:
1577
diff
changeset
|
407 ;; " " tex-zap-file ".??" "\n")) |
f79966ac4f9d
(texinfo-tex-command): Use texi2dvi.
Richard M. Stallman <rms@gnu.org>
parents:
1577
diff
changeset
|
408 ;; (tex-recenter-output-buffer nil)) |
69 | 409 |
410 (defun texinfo-tex-print () | |
411 "Print .dvi file made by \\[texinfo-tex-region] or \\[texinfo-tex-buffer]. | |
1577 | 412 Runs the shell command defined by `tex-dvi-print-command'." |
69 | 413 (interactive) |
414 (send-string "tex-shell" | |
415 (concat tex-dvi-print-command | |
416 " " tex-zap-file ".dvi" "\n")) | |
417 (tex-recenter-output-buffer nil)) | |
418 | |
584 | 419 (provide 'texinfo) |
420 | |
657
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
421 ;;; texinfo.el ends here |