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