annotate lisp/packages/texnfo-tex.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children 0293115a14e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;;; texnfo-tex.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;;; Texinfo mode TeX and hardcopy printing commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; These commands are for running TeX on a region of a Texinfo file in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; GNU Emacs, or on the whole buffer, and for printing the resulting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; DVI file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;;; Version 2.07 22 October 1991
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;; Robert J. Chassell
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;;; Please send bug reports to: bug-texinfo@prep.ai.mit.edu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;; Copyright (C) 1989, 1990, 1991 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;; along with XEmacs; see the file COPYING. If not, write to the Free
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;;; Synched up with: Not in FSF.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;;; The Texinfo mode TeX related commands are:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ; texinfo-tex-region to run tex on the current region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ; texinfo-tex-buffer to run tex on the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ; texinfo-texindex to sort unsorted index files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ; texinfo-tex-print to print the .dvi file made by tex.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ; texinfo-kill-tex-job to kill the currently running tex job.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ; texinfo-recenter-tex-output-buffer to redisplay tex output buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ; texinfo-show-tex-print-queue to show the print queue.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;;; Keys common both to Texinfo mode and to TeX shell.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;; Defined in `texinfo.el'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ; (defun texinfo-define-common-keys (keymap)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ; "Define the keys both in Texinfo mode and in the texinfo-tex-shell."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ; (define-key keymap "\C-c\C-t\C-k" 'texinfo-kill-tex-job)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ; (define-key keymap "\C-c\C-t\C-x" 'texinfo-quit-tex-job)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ; (define-key keymap "\C-c\C-t\C-l" 'texinfo-recenter-tex-output-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ; (define-key keymap "\C-c\C-t\C-d" 'texinfo-delete-from-tex-print-queue)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ; (define-key keymap "\C-c\C-t\C-q" 'texinfo-show-tex-print-queue)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ; (define-key keymap "\C-c\C-t\C-p" 'texinfo-tex-print)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ; (define-key keymap "\C-c\C-t\C-i" 'texinfo-texindex)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ; (define-key keymap "\C-c\C-t\C-r" 'texinfo-tex-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ; (define-key keymap "\C-c\C-t\C-b" 'texinfo-tex-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;; See also texinfo-tex-start-shell.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;; The following is executed in the `texinfo.el' file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;(texinfo-define-common-keys texinfo-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;;; Variable definitions:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (require 'shell)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (defvar texinfo-tex-shell-cd-command "cd"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 "Command to give to shell running TeX to change directory.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (defvar texinfo-tex-command "tex"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 "*Command used by texinfo-tex-region to run tex on a region.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (defvar texinfo-texindex-command "texindex"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 "*Command used by texinfo-texindex to sort unsorted index files.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (defvar texinfo-tex-dvi-print-command "lpr -d"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 "*Command string used by \\[tex-print] to print a .dvi file.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (defvar texinfo-show-tex-queue-command "lpq"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 "*Command string used to show the Texinfo TeX print queue.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 Command is used by \\[texinfo-show-tex-print-queue] and it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 should show the queue that \\[texinfo-tex-print] puts jobs on.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (defvar texinfo-delete-from-print-queue-command "lprm"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 "*Command string used to delete a job from the line printer queue.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 Command is used by \\[texinfo-delete-from-tex-print-queue] based on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 number provided by a previous \\[texinfo-show-tex-print-queue]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 command.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (defvar texinfo-tex-trailer "@bye"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 "String appended after a region sent to TeX by texinfo-tex-region.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (defvar texinfo-tex-original-file ""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 "Original name of file on which to run TeX.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (defvar texinfo-tex-temp-file nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 "Temporary file name used for text being sent as input to TeX.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (defvar texinfo-tex-root-temp-file nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 "Temporary file name used for text being sent as input to TeX.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ;;; Texinfo TeX main functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (defun texinfo-tex-region (beginning end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 "Run tex on the current region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 A temporary file is written in the default directory, and tex is run
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 in that directory. The first line of the file is copied to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 temporary file; and if the buffer has a header, it is written to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 temporary file before the region itself. The buffer's header is all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 lines between the strings defined by texinfo-start-of-header and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 texinfo-end-of-header inclusive. The header must start in the first 100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 lines. The value of texinfo-tex-trailer is appended to the temporary file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 after the region."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (interactive "r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (if (get-buffer "*texinfo-tex-shell*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (quit-process (get-process "texinfo-tex-shell") t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (texinfo-tex-start-shell))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (setq texinfo-tex-root-temp-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (expand-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (make-temp-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (prin1-to-string (read (buffer-name))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (let ((texinfo-tex-temp-file (concat texinfo-tex-root-temp-file ".tex")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (forward-line 100)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (let ((search-end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (header-beginning (point-min)) (header-end (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 ;; Copy first line, the `\input texinfo' line, to temp file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (write-region (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (save-excursion (forward-line 1) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 texinfo-tex-temp-file nil nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 ;; Don't copy first line twice if region includes it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (if (< beginning (point)) (setq beginning (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 ;; Initialize the temp file with either the header or nothing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (if (search-forward texinfo-start-of-header search-end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (setq header-beginning (point)) ; Mark beginning of header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (if (search-forward texinfo-end-of-header nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (progn (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (setq header-end (point))) ; Mark end of header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (setq header-beginning (point-min))))) ; Else no header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 ;; Copy header to temp file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (write-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (min header-beginning beginning )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 header-end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 texinfo-tex-temp-file t nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 ;; Copy region to temp file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (write-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (max beginning header-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 texinfo-tex-temp-file t nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 ;; This is a kludge to insert the texinfo-tex-trailer into the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 ;; texinfo-tex-temp-file. We have to create a special buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 ;; in which to insert the texinfo-tex-trailer first because there is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 ;; no function with which to append a literal string directly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 ;; to a file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (let ((local-tex-trailer texinfo-tex-trailer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (temp-buffer (get-buffer-create " texinfo-trailer-buffer")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (set-buffer temp-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 ;; make sure trailer isn't hidden by a comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (insert-string "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (if local-tex-trailer (insert local-tex-trailer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (write-region (point-min) (point-max)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 texinfo-tex-temp-file t nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (set-process-sentinel (get-process "texinfo-tex-shell")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 'texinfo-tex-shell-sentinel)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (send-string "texinfo-tex-shell"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (concat texinfo-tex-shell-cd-command " "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 default-directory "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (send-string "texinfo-tex-shell"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (concat texinfo-tex-command " "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 texinfo-tex-temp-file "\n "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (texinfo-recenter-tex-output-buffer 0)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (defun texinfo-tex-buffer (buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 "Run TeX on current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 After running TeX the first time, you may have to run \\[texinfo-texindex]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 and then \\[texinfo-tex-buffer] again."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 ;; Sometimes you put point into *texinfo-tex-shell*; this prompts
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 ;; you for the correct file regardless.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (if (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (string= (buffer-name (current-buffer)) "*texinfo-tex-shell*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 texinfo-tex-root-temp-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (read-string (format "Run TeX on: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 texinfo-tex-original-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (read-string (format "Run TeX on: ") (buffer-name (current-buffer))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 ;; Set to original buffer if in *texinfo-tex-shell*; otherwise,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 ;; record name of current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (if (string= (buffer-name (current-buffer)) "*texinfo-tex-shell*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (setq texinfo-tex-original-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (buffer-name (current-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (if (get-buffer "*texinfo-tex-shell*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (quit-process (get-process "texinfo-tex-shell") t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (texinfo-tex-start-shell))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (cond ((null buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (error "Buffer not visiting any file!"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 ((buffer-modified-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (error "Buffer has been modified since last saved!"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (t (set-process-sentinel (get-process "texinfo-tex-shell")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 'texinfo-tex-shell-sentinel)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (send-string "texinfo-tex-shell"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (concat texinfo-tex-shell-cd-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 " "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (file-name-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (buffer-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (get-buffer buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (send-string "texinfo-tex-shell"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (concat texinfo-tex-command " " buffer "\n "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 ;; so the texinfo-tex-print command works
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (setq texinfo-tex-root-temp-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (substring buffer 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (or (string-match "\\.tex" buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (length buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (texinfo-recenter-tex-output-buffer 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (defun texinfo-texindex ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 "Run texindex on unsorted index files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 The index files are made by \\[texinfo-tex-region] or \\[texinfo-tex-buffer].
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 Runs the shell command defined by texinfo-texindex-command."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (send-string "texinfo-tex-shell"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (concat texinfo-texindex-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 " " texinfo-tex-root-temp-file ".??" "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (texinfo-recenter-tex-output-buffer nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (defun texinfo-tex-print ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 "Print .dvi file made by \\[texinfo-tex-region] or \\[texinfo-tex-buffer].
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 Runs the shell command defined by texinfo-tex-dvi-print-command."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (send-string "texinfo-tex-shell"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (concat texinfo-tex-dvi-print-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 " " texinfo-tex-root-temp-file ".dvi" "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (texinfo-recenter-tex-output-buffer nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 ;;; Texinfo TeX utility functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (defun texinfo-tex-start-shell ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (require 'texinfo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (set-buffer (if (fboundp 'make-shell)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (make-shell "texinfo-tex-shell" "/bin/sh" nil "-v")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (make-comint "texinfo-tex-shell" "/bin/sh" nil "-v")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (setq texinfo-tex-shell-map (copy-keymap shell-mode-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (texinfo-define-common-keys texinfo-tex-shell-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (use-local-map texinfo-tex-shell-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (run-hooks 'texinfo-tex-shell-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (if (zerop (buffer-size))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (sleep-for 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (defun texinfo-quit-tex-job ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 "Quit currently running TeX job, by sending an `x' to it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (if (not (get-process "texinfo-tex-shell"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (error "No TeX shell running."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (set-buffer (get-buffer "*texinfo-tex-shell*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (insert "x")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (shell-send-input)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (defun texinfo-kill-tex-job ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 "Kill the currently running TeX job."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (if (get-process "texinfo-tex-shell")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 ;; Use `texinfo-tex-shell-sentinel' to restart
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 ;; texinfo-tex-shell after it is killed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (kill-process (get-process "texinfo-tex-shell"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (defun texinfo-tex-shell-sentinel (process event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 "Restart texinfo-tex-shell after it is killed."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (if (equal event "killed\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (set-buffer "*texinfo-tex-shell*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (texinfo-tex-start-shell))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (defun texinfo-recenter-tex-output-buffer (linenum)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 "Redisplay buffer of TeX job output so that most recent output can be seen.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 The last line of the buffer is displayed on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 line LINE of the window, or centered if LINE is nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (let ((texinfo-tex-shell (get-buffer "*texinfo-tex-shell*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (old-buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (if (null texinfo-tex-shell)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (message "No TeX output buffer")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (pop-to-buffer texinfo-tex-shell)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (bury-buffer texinfo-tex-shell)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (recenter (if linenum
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (prefix-numeric-value linenum)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (/ (window-height) 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (pop-to-buffer old-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (defun texinfo-show-tex-print-queue ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 "Show the print queue that \\[texinfo-tex-print] put your job on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 Runs the shell command defined by texinfo-show-tex-queue-command."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (if (not (texinfo-tex-shell-running-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (texinfo-tex-start-shell))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (send-string "texinfo-tex-shell"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (concat texinfo-show-tex-queue-command "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (texinfo-recenter-tex-output-buffer nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (defun texinfo-delete-from-tex-print-queue (job-number)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 "Delete job from the line printer spooling queue.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 You are prompted for the job number (shown by a previous
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 \\[texinfo-show-tex-print-queue] command."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (interactive "nPrinter job number for deletion: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (if (texinfo-tex-shell-running-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (texinfo-kill-tex-job)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (texinfo-tex-start-shell))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (send-string "texinfo-tex-shell"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 texinfo-delete-from-print-queue-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 " "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 job-number"\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (texinfo-recenter-tex-output-buffer nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (defun texinfo-tex-shell-running-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (and (get-process "texinfo-tex-shell")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (eq (process-status (get-process "texinfo-tex-shell")) 'run)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 ;;; Place `provide' at end of file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (provide 'texnfo-tex)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 ;;;;;;;;;;;;;;;; end texnfo-tex.el ;;;;;;;;;;;;;;;;