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