annotate lisp/packages/texnfo-tex.el @ 110:fe104dbd9147 r20-1b7

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