annotate lisp/packages/texnfo-tex.el @ 199:169c0442b401 r20-3b26

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