annotate lisp/auctex/tex-buf.el @ 26:441bb1e64a06 r19-15b96

Import from CVS: tag r19-15b96
author cvs
date Mon, 13 Aug 2007 08:51:32 +0200
parents 4103f0995bd7
children ec9a17fef872
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1 ;;; tex-buf.el - External commands for AUC TeX.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
2 ;;
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
3 ;; Maintainer: Per Abrahamsen <auc-tex@sunsite.auc.dk>
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
4 ;; Version: 9.7k
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
5
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
6 ;; Copyright (C) 1991 Kresten Krab Thorup
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
7 ;; Copyright (C) 1993, 1996 Per Abrahamsen
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
8 ;;
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
9 ;; This program is free software; you can redistribute it and/or modify
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
10 ;; it under the terms of the GNU General Public License as published by
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
11 ;; the Free Software Foundation; either version 1, or (at your option)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
12 ;; any later version.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
13 ;;
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
14 ;; This program is distributed in the hope that it will be useful,
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
17 ;; GNU General Public License for more details.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
18 ;;
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
20 ;; along with this program; if not, write to the Free Software
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
21 ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
22
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
23 ;;; Code:
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
25 (defvar no-doc
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
26 "This function is part of AUC TeX, but has not yet been loaded.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
27 Full documentation will be available after autoloading the function."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
28 "Documentation for autoload functions.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
29
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
30 ;;; Customization:
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
31
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
32 (defvar TeX-process-asynchronous (not (eq system-type 'ms-dos))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
33 "*Use asynchronous processes.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
34
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
35 (defvar TeX-shell
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
36 (if (memq system-type '(ms-dos emx windows-nt))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
37 shell-file-name
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
38 "/bin/sh")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
39 "Name of shell used to parse TeX commands.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
40
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
41 (defvar TeX-shell-command-option
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
42 (cond ((memq system-type '(ms-dos emx windows-nt) )
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
43 (cond ((boundp 'shell-command-option)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
44 shell-command-option)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
45 ((boundp 'shell-command-switch)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
46 shell-command-switch)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
47 (t
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
48 "/c")))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
49 (t ;Unix & EMX (Emacs 19 port to OS/2)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
50 "-c"))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
51 "Shell argument indicating that next argument is the command.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
52
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
53 ;;; Interactive Commands
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
54 ;;
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
55 ;; The general idea is, that there is one process and process buffer
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
56 ;; associated with each master file, and one process and process buffer
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
57 ;; for running TeX on a region. Thus, if you have N master files, you
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
58 ;; can run N + 1 processes simultaneously.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
59 ;;
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
60 ;; Some user commands operates on ``the'' process. The following
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
61 ;; algorithm determine what ``the'' process is.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
62 ;;
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
63 ;; IF last process started was on a region
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
64 ;; THEN ``the'' process is the region process
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
65 ;; ELSE ``the'' process is the master file (of the current buffer) process
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
66
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
67 (defun TeX-save-document (name)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
68 "Save all files belonging to the current document.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
69 Return non-nil if document need to be re-TeX'ed."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
70 (interactive (list (TeX-master-file)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
71 (if (string-equal name "")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
72 (setq name (TeX-master-file)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
73
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
74 (TeX-check-files (concat name ".dvi")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
75 (cons name (TeX-style-list))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
76 TeX-file-extensions))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
77
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
78 (defun TeX-command-master ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
79 "Run command on the current document."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
80 (interactive)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
81 (TeX-command (TeX-command-query (TeX-master-file)) 'TeX-master-file))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
82
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
83 (defvar TeX-command-region-begin nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
84 (defvar TeX-command-region-end nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
85 ;; Used for marking the last region.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
86
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
87 (make-variable-buffer-local 'TeX-command-region-begin)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
88 (make-variable-buffer-local 'TeX-command-region-end)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
89
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
90 (defun TeX-command-region (&optional old)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
91 "Run TeX on the current region.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
92
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
93 Query the user for a command to run on the temporary file specified by
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
94 the variable TeX-region. If the chosen command is so marked in
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
95 TeX-command-list, and no argument (or nil) is given to the command,
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
96 the region file file be recreated with the current region. If mark is
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
97 not active, the new text in the previous used region will be used.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
98
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
99 If the master file for the document has a header, it is written to the
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
100 temporary file before the region itself. The document's header is all
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
101 text before TeX-header-end.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
102
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
103 If the master file for the document has a trailer, it is written to
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
104 the temporary file before the region itself. The document's trailer is
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
105 all text after TeX-trailer-start."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
106 (interactive "P")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
107 (if (and (TeX-mark-active) (not old))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
108 (let ((begin (min (point) (mark)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
109 (end (max (point) (mark))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
110 (if TeX-command-region-begin
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
111 ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
112 (setq TeX-command-region-begin (make-marker)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
113 TeX-command-region-end (make-marker)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
114 (set-marker TeX-command-region-begin begin)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
115 (set-marker TeX-command-region-end end)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
116 (if (null TeX-command-region-begin)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
117 (error "Mark not set"))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
118 (let ((begin (marker-position TeX-command-region-begin))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
119 (end (marker-position TeX-command-region-end)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
120 (TeX-region-create (TeX-region-file TeX-default-extension)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
121 (buffer-substring begin end)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
122 (file-name-nondirectory (buffer-file-name))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
123 (count-lines (save-restriction (widen) (point-min))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
124 begin)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
125 (TeX-command (TeX-command-query (TeX-region-file)) 'TeX-region-file))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
126
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
127 (defun TeX-command-buffer ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
128 "Run TeX on the current buffer.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
129
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
130 Query the user for a command to run on the temporary file specified by
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
131 the variable TeX-region. The region file file be recreated from the
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
132 visible part of the buffer."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
133 (interactive)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
134 (let ((TeX-command-region-begin (point-min-marker))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
135 (TeX-command-region-end (point-max-marker)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
136 (TeX-command-region t)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
137
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
138 (defun TeX-recenter-output-buffer (line)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
139 "Redisplay buffer of TeX job output so that most recent output can be seen.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
140 The last line of the buffer is displayed on line LINE of the window, or
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
141 at bottom if LINE is nil."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
142 (interactive "P")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
143 (let ((buffer (TeX-active-buffer)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
144 (if buffer
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
145 (let ((old-buffer (current-buffer)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
146 (pop-to-buffer buffer t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
147 (bury-buffer buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
148 (goto-char (point-max))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
149 (recenter (if line
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
150 (prefix-numeric-value line)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
151 (/ (window-height) 2)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
152 (pop-to-buffer old-buffer))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
153 (message "No process for this document."))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
154
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
155 (defun TeX-kill-job ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
156 "Kill the currently running TeX job."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
157 (interactive)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
158 (let ((process (TeX-active-process)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
159 (if process
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
160 (kill-process process)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
161 ;; Should test for TeX background process here.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
162 (error "No TeX process to kill"))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
163
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
164 (defun TeX-home-buffer ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
165 "Go to the buffer where you last issued a TeX command.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
166 If there is no such buffer, or you already are in that buffer, find
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
167 the master file."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
168 (interactive)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
169 (if (or (null TeX-command-buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
170 (eq TeX-command-buffer (current-buffer)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
171 (find-file (TeX-master-file TeX-default-extension))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
172 (switch-to-buffer TeX-command-buffer)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
173
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
174 (defun TeX-next-error (reparse)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
175 "Find the next error in the TeX output buffer.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
176 Prefix by C-u to start from the beginning of the errors."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
177 (interactive "P")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
178 (if (null (TeX-active-buffer))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
179 (error "No TeX output buffer")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
180 (funcall (TeX-process-get-variable (TeX-active-master) 'TeX-parse-function)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
181 reparse)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
182
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
183 (defun TeX-toggle-debug-boxes ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
184 "Toggle if the debugger should display \"bad boxes\" too."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
185 (interactive)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
186 (cond (TeX-debug-bad-boxes
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
187 (setq TeX-debug-bad-boxes nil))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
188 (t
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
189 (setq TeX-debug-bad-boxes t)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
190 (message (concat "TeX-debug-bad-boxes: " (cond (TeX-debug-bad-boxes "on")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
191 (t "off")))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
192
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
193 ;;; Command Query
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
194
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
195 (defun TeX-command (name file)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
196 "Run command NAME on the file you get by calling FILE.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
197
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
198 FILE is a function return a file name. It has one optional argument,
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
199 the extension to use on the file.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
200
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
201 Use the information in TeX-command-list to determine how to run the
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
202 command."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
203 (setq TeX-current-process-region-p (eq file 'TeX-region-file))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
204 (let ((command (TeX-command-expand (nth 1 (assoc name TeX-command-list))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
205 file))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
206 (hook (nth 2 (assoc name TeX-command-list)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
207 (confirm (nth 3 (assoc name TeX-command-list))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
208
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
209 ;; Verify the expanded command
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
210 (if confirm
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
211 (setq command
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
212 (read-from-minibuffer (concat name " command: ") command)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
213
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
214 ;; Now start the process
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
215 (TeX-process-set-variable name 'TeX-command-next TeX-command-Show)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
216 (apply hook name command (apply file nil) nil)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
217
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
218 (defun TeX-command-expand (command file &optional list)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
219 "Expand COMMAND for FILE as described in LIST.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
220 LIST default to TeX-expand-list."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
221 (if (null list)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
222 (setq list TeX-expand-list))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
223 (while list
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
224 (let ((case-fold-search nil) ; Do not ignore case.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
225 (string (car (car list))) ;First element
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
226 (expansion (car (cdr (car list)))) ;Second element
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
227 (arguments (cdr (cdr (car list))))) ;Remaining elements
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
228 (while (string-match string command)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
229 (let ((prefix (substring command 0 (match-beginning 0)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
230 (postfix (substring command (match-end 0))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
231 (setq command (concat prefix
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
232 (cond ((TeX-function-p expansion)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
233 (apply expansion arguments))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
234 ((boundp expansion)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
235 (apply (eval expansion) arguments))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
236 (t
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
237 (error "Nonexpansion %s" expansion)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
238 postfix)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
239 (setq list (cdr list)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
240 command)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
241
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
242 (defun TeX-check-files (derived originals extensions)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
243 "Check that DERIVED is newer than any of the ORIGINALS.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
244 Try each original with each member of EXTENSIONS, in all directories
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
245 in TeX-check-path."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
246 (let ((found nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
247 (regexp (concat "\\`\\("
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
248 (mapconcat (function (lambda (dir)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
249 (regexp-quote (expand-file-name dir))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
250 TeX-check-path "\\|")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
251 "\\).*\\("
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
252 (mapconcat 'regexp-quote originals "\\|")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
253 "\\)\\.\\("
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
254 (mapconcat 'regexp-quote extensions "\\|")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
255 "\\)\\'"))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
256 (buffers (buffer-list)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
257 (while buffers
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
258 (let* ((buffer (car buffers))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
259 (name (buffer-file-name buffer)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
260 (setq buffers (cdr buffers))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
261 (if (and name (string-match regexp name))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
262 (progn
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
263 (and (buffer-modified-p buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
264 (or (not TeX-save-query)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
265 (y-or-n-p (concat "Save file "
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
266 (buffer-file-name buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
267 "? ")))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
268 (save-excursion (set-buffer buffer) (save-buffer)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
269 (if (file-newer-than-file-p name derived)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
270 (setq found t))))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
271 found))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
272
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
273 (defvar TeX-save-query t
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
274 "*If non-nil, ask user for permission to save files before starting TeX.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
275
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
276 (defun TeX-command-query (name)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
277 "Query the user for a what TeX command to use."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
278 (let* ((default (cond ((if (string-equal name TeX-region)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
279 (TeX-check-files (concat name ".dvi")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
280 (list name)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
281 TeX-file-extensions)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
282 (TeX-save-document (TeX-master-file)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
283 TeX-command-default)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
284 ((and (eq major-mode 'latex-mode)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
285 (TeX-check-files (concat name ".bbl")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
286 (mapcar 'car
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
287 (LaTeX-bibliography-list))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
288 BibTeX-file-extensions))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
289 ;; We should check for bst files here as well.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
290 TeX-command-BibTeX)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
291 ((TeX-process-get-variable name
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
292 'TeX-command-next
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
293 TeX-command-Show))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
294 (TeX-command-Show)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
295 (completion-ignore-case t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
296 (answer (or TeX-command-force
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
297 (completing-read
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
298 (concat "Command: (default " default ") ")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
299 TeX-command-list nil t))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
300 ;; If the answer "latex" it will not be expanded to "LaTeX"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
301 (setq answer (car-safe (TeX-assoc answer TeX-command-list)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
302 (if (and answer
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
303 (not (string-equal answer "")))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
304 answer
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
305 default)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
306
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
307 (defvar TeX-command-next nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
308 "The default command next time TeX-command is invoked.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
309
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
310 (make-variable-buffer-local 'TeX-command-next)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
311
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
312 (defun TeX-printer-query (&optional command element)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
313 "Query the user for a printer name.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
314 COMMAND is the default command to use if the entry for the printer in
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
315 TeX-printer-list does not itself have it specified in the ELEMENT'th
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
316 entry."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
317 (or command (setq command TeX-print-command))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
318 (or element (setq element 1))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
319 (let ((printer (if TeX-printer-list
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
320 (let ((completion-ignore-case t))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
321 (completing-read (concat "Printer: (default "
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
322 TeX-printer-default ") ")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
323 TeX-printer-list))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
324 "")))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
325
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
326 (setq printer (or (car-safe (TeX-assoc printer TeX-printer-list))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
327 printer))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
328 (if (or (null printer) (string-equal "" printer))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
329 (setq printer TeX-printer-default)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
330 (setq TeX-printer-default printer))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
331
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
332 (let ((expansion (let ((entry (assoc printer TeX-printer-list)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
333 (if (and entry (nth element entry))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
334 (nth element entry)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
335 command))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
336 (if (string-match "%p" printer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
337 (error "Don't use %s in printer names" "%p"))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
338 (while (string-match "%p" expansion)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
339 (setq expansion (concat (substring expansion 0 (match-beginning 0))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
340 printer
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
341 (substring expansion (match-end 0)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
342 expansion)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
343
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
344 (defun TeX-style-check (styles)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
345 "Check STYLES compared to the current style options."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
346
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
347 (let ((files (TeX-style-list)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
348 (while (and styles
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
349 (not (TeX-member (car (car styles)) files 'string-match)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
350 (setq styles (cdr styles))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
351 (if styles
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
352 (nth 1 (car styles))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
353 ""))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
354
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
355 ;;; Command Hooks
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
356
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
357 (defvar TeX-after-start-process-function nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
358 "Hooks to run after starting an asynchronous process.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
359 Used by Japanese TeX to set the coding system.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
360
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
361 (defvar TeX-show-compilation nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
362 "*If non-nil, show output of TeX compilation in other window.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
363
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
364 (defun TeX-run-command (name command file)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
365 "Create a process for NAME using COMMAND to process FILE.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
366 Return the new process."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
367 (let ((default TeX-command-default)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
368 (buffer (TeX-process-buffer-name file))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
369 (dir (TeX-master-directory)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
370 (TeX-process-check file) ; Check that no process is running
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
371 (setq TeX-command-buffer (current-buffer))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
372 (get-buffer-create buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
373 (set-buffer buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
374 (erase-buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
375 (if dir (cd dir))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
376 (insert "Running `" name "' on `" file "' with ``" command "''\n")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
377 (setq mode-name name)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
378 (if TeX-show-compilation
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
379 (display-buffer buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
380 (message "Type `C-c C-l' to display results of compilation."))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
381 (setq TeX-parse-function 'TeX-parse-command)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
382 (setq TeX-command-default default)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
383 (setq TeX-sentinel-function
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
384 (function (lambda (process name)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
385 (message (concat name ": done.")))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
386 (if TeX-process-asynchronous
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
387 (let ((process (start-process name buffer TeX-shell
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
388 TeX-shell-command-option command)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
389 (if TeX-after-start-process-function
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
390 (funcall TeX-after-start-process-function process))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
391 (TeX-command-mode-line process)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
392 (set-process-filter process 'TeX-command-filter)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
393 (set-process-sentinel process 'TeX-command-sentinel)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
394 (set-marker (process-mark process) (point-max))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
395 (setq compilation-in-progress (cons process compilation-in-progress))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
396 process)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
397 (setq mode-line-process ": run")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
398 (set-buffer-modified-p (buffer-modified-p))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
399 (sit-for 0) ; redisplay
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
400 (call-process TeX-shell nil buffer nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
401 TeX-shell-command-option command))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
402
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
403 (defun TeX-run-format (name command file)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
404 "Create a process for NAME using COMMAND to format FILE with TeX."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
405 (let ((buffer (TeX-process-buffer-name file))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
406 (process (TeX-run-command name command file)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
407 ;; Hook to TeX debuger.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
408 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
409 (set-buffer buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
410 (TeX-parse-reset)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
411 (setq TeX-parse-function 'TeX-parse-TeX)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
412 (setq TeX-sentinel-function 'TeX-TeX-sentinel)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
413 (if TeX-process-asynchronous
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
414 (progn
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
415 ;; Updating the mode line.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
416 (setq TeX-current-page "[0]")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
417 (TeX-format-mode-line process)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
418 (set-process-filter process 'TeX-format-filter)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
419 process)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
420
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
421 (defun TeX-run-TeX (name command file)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
422 "Create a process for NAME using COMMAND to format FILE with TeX."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
423 (let ((process (TeX-run-format name command file)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
424 (if TeX-process-asynchronous
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
425 process
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
426 (TeX-synchronous-sentinel name file process))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
427
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
428 (defun TeX-run-LaTeX (name command file)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
429 "Create a process for NAME using COMMAND to format FILE with TeX."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
430 (let ((process (TeX-run-format name command file)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
431 (setq TeX-sentinel-function 'TeX-LaTeX-sentinel)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
432 (if TeX-process-asynchronous
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
433 process
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
434 (TeX-synchronous-sentinel name file process))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
435
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
436 (defun TeX-run-BibTeX (name command file)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
437 "Create a process for NAME using COMMAND to format FILE with BibTeX."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
438 (let ((process (TeX-run-command name command file)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
439 (setq TeX-sentinel-function 'TeX-BibTeX-sentinel)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
440 (if TeX-process-asynchronous
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
441 process
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
442 (TeX-synchronous-sentinel name file process))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
443
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
444 (defun TeX-run-compile (name command file)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
445 "Ignore first and third argument, start compile with second argument."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
446 (compile command))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
447
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
448 (defun TeX-run-shell (name command file)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
449 "Ignore first and third argument, start shell-command with second argument."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
450 (shell-command command)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
451 (if (eq system-type 'ms-dos)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
452 (redraw-display)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
453
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
454 (defun TeX-run-discard (name command file)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
455 "Start process with second argument, discarding its output."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
456 (process-kill-without-query (start-process (concat name " discard")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
457 nil TeX-shell
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
458 TeX-shell-command-option
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
459 command)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
460
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
461 (defun TeX-run-dviout (name command file)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
462 "Call process wbith second argument, discarding its output. With support
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
463 for the dviout previewer, especially when used with PC-9801 series."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
464 (if (and (boundp 'dos-machine-type) (eq dos-machine-type 'pc98)) ;if PC-9801
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
465 (send-string-to-terminal "\e[2J")) ; clear screen
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
466 (call-process TeX-shell (if (eq system-type 'ms-dos) "con") nil nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
467 TeX-shell-command-option command)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
468 (if (eq system-type 'ms-dos)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
469 (redraw-display)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
470
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
471 (defun TeX-run-background (name command file)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
472 "Start process with second argument, show output when and if it arrives."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
473 (let ((dir (TeX-master-directory)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
474 (set-buffer (get-buffer-create "*TeX background*"))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
475 (if dir (cd dir))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
476 (erase-buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
477 (let ((process (start-process (concat name " background")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
478 nil TeX-shell
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
479 TeX-shell-command-option command)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
480 (if TeX-after-start-process-function
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
481 (funcall TeX-after-start-process-function process))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
482 (set-process-filter process 'TeX-background-filter)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
483 (process-kill-without-query process))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
484
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
485 (defun TeX-run-interactive (name command file)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
486 "Run TeX interactively.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
487 Run command in a buffer (in comint-shell-mode) so that it accepts user
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
488 interaction. If you return to the file buffer after the TeX run,
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
489 Error parsing on C-x ` should work with a bit of luck."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
490 (require 'comint)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
491 (let ((default TeX-command-default)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
492 (buffer (TeX-process-buffer-name file))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
493 (process nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
494 (dir (TeX-master-directory)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
495 (TeX-process-check file) ; Check that no process is running
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
496 (setq TeX-command-buffer (current-buffer))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
497 (with-output-to-temp-buffer buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
498 (set-buffer buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
499 (if dir (cd dir))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
500 (insert "Running `" name "' on `" file "' with ``" command "''\n")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
501 (comint-exec buffer name TeX-shell nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
502 (list TeX-shell-command-option command))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
503 (comint-mode)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
504 (setq mode-name name)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
505 (setq TeX-command-default default)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
506 (setq process (get-buffer-process buffer))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
507 (if TeX-after-start-process-function
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
508 (funcall TeX-after-start-process-function process))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
509 (TeX-command-mode-line process)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
510 (set-process-sentinel process 'TeX-command-sentinel)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
511 (set-marker (process-mark process) (point-max))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
512 (setq compilation-in-progress (cons process compilation-in-progress))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
513 (TeX-parse-reset)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
514 (setq TeX-parse-function 'TeX-parse-TeX)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
515 (setq TeX-sentinel-function 'TeX-LaTeX-sentinel)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
516
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
517 ;;; Command Sentinels
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
518
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
519 (defun TeX-synchronous-sentinel (name file result)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
520 "Process TeX command output buffer after the process dies."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
521 (let* ((buffer (TeX-process-buffer file)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
522 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
523 (set-buffer buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
524
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
525 ;; Append post-mortem information to the buffer
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
526 (goto-char (point-max))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
527 (insert "\n" mode-name (if (and result (zerop result))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
528 " finished" " exited") " at "
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
529 (substring (current-time-string) 0 -5))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
530 (setq mode-line-process ": exit")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
531
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
532 ;; Do command specific actions.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
533 (setq TeX-command-next TeX-command-Show)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
534 (goto-char (point-min))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
535 (apply TeX-sentinel-function nil name nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
536
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
537 ;; Force mode line redisplay soon
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
538 (set-buffer-modified-p (buffer-modified-p)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
539
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
540 (defun TeX-command-sentinel (process msg)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
541 "Process TeX command output buffer after the process dies."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
542 (let* ((buffer (process-buffer process))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
543 (name (process-name process)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
544 (cond ((null (buffer-name buffer)) ; buffer killed
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
545 (set-process-buffer process nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
546 (set-process-sentinel process nil))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
547 ((memq (process-status process) '(signal exit))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
548 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
549 (set-buffer buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
550
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
551 ;; Append post-mortem information to the buffer
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
552 (goto-char (point-max))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
553 (insert "\n" mode-name " " msg)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
554 (forward-char -1)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
555 (insert " at "
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
556 (substring (current-time-string) 0 -5))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
557 (forward-char 1)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
558
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
559 ;; Do command specific actions.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
560 (TeX-command-mode-line process)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
561 (setq TeX-command-next TeX-command-Show)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
562 (goto-char (point-min))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
563 (apply TeX-sentinel-function process name nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
564
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
565
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
566 ;; If buffer and mode line will show that the process
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
567 ;; is dead, we can delete it now. Otherwise it
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
568 ;; will stay around until M-x list-processes.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
569 (delete-process process)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
570
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
571 ;; Force mode line redisplay soon
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
572 (set-buffer-modified-p (buffer-modified-p))))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
573 (setq compilation-in-progress (delq process compilation-in-progress)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
574
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
575
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
576 (defvar TeX-sentinel-function (function (lambda (process name)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
577 "Hook to cleanup TeX command buffer after temination of PROCESS.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
578 NAME is the name of the process.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
579
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
580 (make-variable-buffer-local 'TeX-sentinel-function)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
581
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
582 (defun TeX-TeX-sentinel (process name)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
583 "Cleanup TeX output buffer after running TeX."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
584 (if (TeX-TeX-sentinel-check process name)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
585 ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
586 (message (concat name ": formatted " (TeX-current-pages)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
587 (setq TeX-command-next TeX-command-Show)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
588
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
589 (defun TeX-current-pages ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
590 ;; String indictating the number of pages formatted.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
591 (cond ((null TeX-current-page)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
592 "some pages.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
593 ((string-match "[^0-9]1[^0-9]" TeX-current-page)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
594 (concat TeX-current-page " page."))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
595 (t
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
596 (concat TeX-current-page " pages."))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
597
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
598 (defun TeX-TeX-sentinel-check (process name)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
599 "Cleanup TeX output buffer after running TeX.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
600 Return nil ifs no errors were found."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
601 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
602 (goto-char (point-max))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
603 (if (re-search-backward "^Output written on.* (\\([0-9]+\\) page" nil t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
604 (setq TeX-current-page (concat "{" (TeX-match-buffer 1) "}"))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
605 (if process (TeX-format-mode-line process))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
606 (if (re-search-forward "^! " nil t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
607 (progn
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
608 (message (concat name " errors in `" (buffer-name)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
609 "'. Use C-c ` to display."))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
610 (setq TeX-command-next TeX-command-default)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
611 t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
612 (setq TeX-command-next TeX-command-Show)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
613 nil))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
614
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
615 (defun TeX-LaTeX-sentinel (process name)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
616 "Cleanup TeX output buffer after running LaTeX."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
617 (cond ((TeX-TeX-sentinel-check process name))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
618 ((and (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
619 (re-search-forward "^LaTeX Warning: Citation" nil t))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
620 (let ((current (current-buffer)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
621 (set-buffer TeX-command-buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
622 (prog1 (and (LaTeX-bibliography-list)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
623 (TeX-check-files (TeX-master-file "bbl")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
624 (TeX-style-list)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
625 (append TeX-file-extensions
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
626 BibTeX-file-extensions)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
627 (set-buffer current))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
628 (message (concat "You should run BibTeX to get citations right, "
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
629 (TeX-current-pages)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
630 (setq TeX-command-next TeX-command-BibTeX))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
631 ((re-search-forward "^LaTeX Warning: Label(s)" nil t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
632 (message (concat "You should run LaTeX again "
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
633 "to get references right, "
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
634 (TeX-current-pages)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
635 (setq TeX-command-next TeX-command-default))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
636 ((re-search-forward "^LaTeX Warning: Reference" nil t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
637 (message (concat name ": there were unresolved references, "
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
638 (TeX-current-pages)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
639 (setq TeX-command-next TeX-command-Show))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
640 ((re-search-forward "^LaTeX Warning: Citation" nil t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
641 (message (concat name ": there were unresolved citations, "
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
642 (TeX-current-pages)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
643 (setq TeX-command-next TeX-command-Show))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
644 ((re-search-forward
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
645 "^\\(\\*\\* \\)?J?I?p?\\(La\\|Sli\\)TeX\\(2e\\)? \\(Version\\|ver\\.\\|<[0-9/]*>\\)" nil t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
646 (message (concat name ": successfully formatted "
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
647 (TeX-current-pages)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
648 (setq TeX-command-next TeX-command-Show))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
649 (t
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
650 (message (concat name ": problems after "
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
651 (TeX-current-pages)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
652 (setq TeX-command-next TeX-command-default))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
653
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
654 (defun TeX-BibTeX-sentinel (process name)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
655 "Cleanup TeX output buffer after running BibTeX."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
656 (message "You should perhaps run LaTeX again to get citations right.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
657 (setq TeX-command-next TeX-command-default))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
658
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
659 ;;; Process Control
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
660
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
661
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
662 ;; This variable is chared with `compile.el'.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
663 (defvar compilation-in-progress nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
664 "List of compilation processes now running.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
665
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
666 (or (assq 'compilation-in-progress minor-mode-alist)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
667 (setq minor-mode-alist (cons '(compilation-in-progress " Compiling")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
668 minor-mode-alist)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
669
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
670 (defun TeX-process-get-variable (name symbol &optional default)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
671 "Return the value in the process buffer for NAME of SYMBOL.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
672
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
673 Return DEFAULT if the process buffer does not exist or SYMBOL is not
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
674 defined."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
675 (let ((buffer (TeX-process-buffer name)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
676 (if buffer
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
677 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
678 (set-buffer buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
679 (if (boundp symbol)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
680 (eval symbol)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
681 default))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
682 default)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
683
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
684 (defun TeX-process-set-variable (name symbol value)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
685 "Set the variable SYMBOL in the process buffer to VALUE.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
686 Return nil iff no process buffer exist."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
687 (let ((buffer (TeX-process-buffer name)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
688 (if buffer
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
689 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
690 (set-buffer buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
691 (set symbol value)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
692 t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
693 nil)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
694
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
695 (defun TeX-process-check (name)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
696 "Check if a process for the TeX document NAME already exist.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
697 If so, give the user the choice of aborting the process or the current
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
698 command."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
699 (let ((process (TeX-process name)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
700 (cond ((null process))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
701 ((not (eq (process-status process) 'run)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
702 ((yes-or-no-p (concat "Process `"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
703 (process-name process)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
704 "' for document `"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
705 name
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
706 "' running, kill it? "))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
707 (delete-process process))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
708 (t
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
709 (error "Cannot have two processes for the same document")))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
710
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
711 (defun TeX-process-buffer-name (name)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
712 "Return name of AUC TeX buffer associated with the document NAME."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
713 (concat "*" (abbreviate-file-name (expand-file-name name)) " output*"))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
714
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
715 (defun TeX-process-buffer (name)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
716 "Return the AUC TeX buffer associated with the document NAME."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
717 (get-buffer (TeX-process-buffer-name name)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
718
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
719 (defun TeX-process (name)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
720 "Return AUC TeX process associated with the document NAME."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
721 (and TeX-process-asynchronous
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
722 (get-buffer-process (TeX-process-buffer name))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
723
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
724 ;;; Process Filters
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
725
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
726 (defun TeX-command-mode-line (process)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
727 "Format the mode line for a buffer containing output from PROCESS."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
728 (setq mode-line-process (concat ": "
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
729 (symbol-name (process-status process))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
730 (set-buffer-modified-p (buffer-modified-p)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
731
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
732 (defun TeX-command-filter (process string)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
733 "Filter to process normal output."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
734 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
735 (set-buffer (process-buffer process))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
736 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
737 (goto-char (process-mark process))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
738 (insert-before-markers string)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
739 (set-marker (process-mark process) (point)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
740
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
741 (defvar TeX-current-page nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
742 "The page number currently being formatted, enclosed in brackets.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
743
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
744 (make-variable-buffer-local 'TeX-current-page)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
745
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
746 (defun TeX-format-mode-line (process)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
747 "Format the mode line for a buffer containing TeX output from PROCESS."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
748 (setq mode-line-process (concat " " TeX-current-page ": "
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
749 (symbol-name (process-status process))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
750 (set-buffer-modified-p (buffer-modified-p)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
751
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
752 (defun TeX-format-filter (process string)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
753 "Filter to process TeX output."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
754 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
755 (set-buffer (process-buffer process))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
756 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
757 (goto-char (process-mark process))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
758 (insert-before-markers string)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
759 (set-marker (process-mark process) (point)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
760 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
761 (save-match-data
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
762 (if (re-search-backward "\\[[0-9]+\\(\\.[0-9\\.]+\\)?\\]" nil t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
763 (setq TeX-current-page (TeX-match-buffer 0)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
764 (TeX-format-mode-line process)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
765
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
766 (defvar TeX-parse-function nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
767 "Function to call to parse content of TeX output buffer.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
768 (make-variable-buffer-local 'TeX-parse-function)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
769
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
770 (defun TeX-background-filter (process string)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
771 "Filter to process background output."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
772 (let ((old-window (selected-window))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
773 (pop-up-windows t))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
774 (pop-to-buffer "*TeX background*")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
775 (goto-char (point-max))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
776 (insert string)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
777 (select-window old-window)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
778
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
779
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
780 ;;; Active Process
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
781
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
782 (defvar TeX-current-process-region-p nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
783 "This variable is set to t iff the last TeX command is on a region.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
784
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
785 (defun TeX-active-process ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
786 "Return the active process for the current buffer."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
787 (if TeX-current-process-region-p
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
788 (TeX-process (TeX-region-file))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
789 (TeX-process (TeX-master-file))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
790
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
791 (defun TeX-active-buffer ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
792 "Return the buffer of the active process for this buffer."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
793 (if TeX-current-process-region-p
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
794 (TeX-process-buffer (TeX-region-file))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
795 (TeX-process-buffer (TeX-master-file))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
796
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
797 (defun TeX-active-master (&optional extension)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
798 "The master file currently being compiled."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
799 (if TeX-current-process-region-p
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
800 (TeX-region-file extension)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
801 (TeX-master-file extension)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
802
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
803 (defvar TeX-command-buffer nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
804 "The buffer from where the last TeX command was issued.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
805
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
806 ;;; Region File
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
807
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
808 (defun TeX-region-create (file region original offset)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
809 "Create a new file named FILE with the string REGION
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
810 The region is taken from ORIGINAL starting at line OFFSET.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
811
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
812 The current buffer and master file is searched, in order to ensure
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
813 that the TeX header and trailer information is also included.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
814
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
815 The OFFSET is used to provide the debugger with information about the
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
816 original file."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
817 (let* (;; We shift buffer a lot, so we must keep track of the buffer
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
818 ;; local variables.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
819 (header-end TeX-header-end)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
820 (trailer-start TeX-trailer-start)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
821
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
822 ;; We seach for header and trailer in the master file.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
823 (master-name (TeX-master-file TeX-default-extension))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
824 (master-buffer (find-file-noselect master-name))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
825
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
826 ;; Attempt to disable font lock.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
827 (font-lock-defaults-alist nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
828 (font-lock-defaults nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
829 (font-lock-maximum-size 0)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
830 (font-lock-mode-hook nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
831 (font-lock-auto-fontify nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
832 (font-lock-mode-enable-list nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
833 ;; And insert them into the FILE buffer.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
834 (file-buffer (find-file-noselect file))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
835 ;; But remember original content.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
836 original-content
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
837
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
838 ;; We search for the header from the master file, if it is
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
839 ;; not present in the region.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
840 (header (if (string-match header-end region)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
841 ""
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
842 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
843 (save-restriction
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
844 (set-buffer master-buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
845 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
846 (save-restriction
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
847 (widen)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
848 (goto-char (point-min))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
849 ;; NOTE: We use the local value of
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
850 ;; TeX-header-end from the master file.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
851 (if (not (re-search-forward TeX-header-end nil t))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
852 ""
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
853 (re-search-forward "[\r\n]" nil t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
854 (buffer-substring (point-min) (point)))))))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
855
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
856 ;; We search for the trailer from the master file, if it is
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
857 ;; not present in the region.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
858 (trailer-offset 0)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
859 (trailer (if (string-match trailer-start region)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
860 ""
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
861 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
862 (save-restriction
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
863 (set-buffer master-buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
864 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
865 (save-restriction
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
866 (widen)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
867 (goto-char (point-max))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
868 ;; NOTE: We use the local value of
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
869 ;; TeX-trailer-start from the master file.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
870 (if (not (re-search-backward TeX-trailer-start nil t))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
871 ""
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
872 ;;(beginning-of-line 1)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
873 (re-search-backward "[\r\n]" nil t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
874 (setq trailer-offset
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
875 (count-lines (point-min) (point)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
876 (buffer-substring (point) (point-max))))))))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
877 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
878 (set-buffer file-buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
879 (setq original-content (buffer-string))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
880 (erase-buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
881 (insert "\\message{ !name(" master-name ")}"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
882 header
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
883 "\n\\message{ !name(" original ") !offset(")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
884 (insert (int-to-string (- offset
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
885 (count-lines (point-min) (point))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
886 ") }\n"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
887 region
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
888 "\n\\message{ !name(" master-name ") !offset(")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
889 (insert (int-to-string (- trailer-offset
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
890 (count-lines (point-min) (point))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
891 ") }\n"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
892 trailer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
893 (if (string-equal (buffer-string) original-content)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
894 (set-buffer-modified-p nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
895 (save-buffer 0)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
896
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
897 (defun TeX-region-file (&optional extension nondirectory)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
898 "Return TeX-region file name with EXTENSION.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
899 If optional second argument NONDIRECTORY is nil, do not include
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
900 the directory."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
901 (concat (if nondirectory "" (TeX-master-directory))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
902 (cond ((eq extension t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
903 (concat TeX-region "." TeX-default-extension))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
904 (extension
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
905 (concat TeX-region "." extension))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
906 (t
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
907 TeX-region))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
908
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
909 (defvar TeX-region "_region_"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
910 "*Base name for temporary file for use with TeX-region.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
911
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
912 ;;; Parsing
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
913
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
914 ;;; - Global Parser Variables
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
915
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
916 (defvar TeX-error-point nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
917 "How far we have parsed until now.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
918
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
919 (make-variable-buffer-local 'TeX-error-point)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
920
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
921 (defvar TeX-error-file nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
922 "Stack of files in which errors have occured")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
923
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
924 (make-variable-buffer-local 'TeX-error-file)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
925
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
926 (defvar TeX-error-offset nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
927 "Add this to any line numbers from TeX. Stack like TeX-error-file.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
928
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
929 (make-variable-buffer-local 'TeX-error-offset)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
930
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
931 (defun TeX-parse-reset ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
932 "Reset all variables used for parsing TeX output."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
933 (setq TeX-error-point (point-min))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
934 (setq TeX-error-offset nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
935 (setq TeX-error-file nil))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
936
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
937 ;;; - Parsers Hooks
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
938
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
939 (defun TeX-parse-command (reparse)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
940 "We can't parse anything but TeX."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
941 (error "I cannot parse %s output, sorry"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
942 (if (TeX-active-process)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
943 (process-name (TeX-active-process))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
944 "this")))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
945
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
946 (defun TeX-parse-TeX (reparse)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
947 "Find the next error produced by running TeX.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
948 Prefix by C-u to start from the beginning of the errors.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
949
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
950 If the file occurs in an included file, the file is loaded (if not
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
951 already in an Emacs buffer) and the cursor is placed at the error."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
952
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
953 (let ((old-buffer (current-buffer)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
954 (pop-to-buffer (TeX-active-buffer))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
955 (if reparse
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
956 (TeX-parse-reset))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
957 (goto-char TeX-error-point)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
958 (TeX-parse-error old-buffer)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
959
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
960 ;;; - Parsing (La)TeX
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
961
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
962 (defvar TeX-translate-location-hook nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
963 "List of functions to be called before showing an error or warning.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
964
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
965 You might want to examine and modify the free variables `file',
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
966 `offset', `line', `string', `error', and `context' from this hook.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
967
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
968 (defun TeX-parse-error (old)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
969 "Goto next error. Pop to OLD buffer if no more errors are found."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
970 (while
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
971 (progn
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
972 (re-search-forward (concat "\\("
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
973 "^! \\|"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
974 "(\\|"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
975 ")\\|"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
976 "\\'\\|"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
977 "!offset([---0-9]*)\\|"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
978 "!name([^)]*)\\|"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
979 "^.*erfull \\\\.*[0-9]*--[0-9]*\\|"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
980 "^LaTeX Warning: .*[0-9]+\\.$"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
981 "\\)"))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
982 (let ((string (TeX-match-buffer 1)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
983
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
984 (cond (;; TeX error
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
985 (string= string "! ")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
986 (TeX-error)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
987 nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
988
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
989 ;; LaTeX warning
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
990 ((string-match (concat "\\("
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
991 "^.*erfull \\\\.*[0-9]*--[0-9]*\\|"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
992 "^LaTeX Warning: .*[0-9]+\\.$"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
993 "\\)")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
994
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
995 string)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
996 (TeX-warning string))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
997
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
998 ;; New file -- Push on stack
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
999 ((string= string "(")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1000 (re-search-forward "\\([^()\n \t]*\\)")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1001 (setq TeX-error-file
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1002 (cons (TeX-match-buffer 1) TeX-error-file))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1003 (setq TeX-error-offset (cons 0 TeX-error-offset))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1004 t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1005
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1006 ;; End of file -- Pop from stack
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1007 ((string= string ")")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1008 (setq TeX-error-file (cdr TeX-error-file))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1009 (setq TeX-error-offset (cdr TeX-error-offset))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1010 t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1011
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1012 ;; Hook to change line numbers
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1013 ((string-match "!offset(\\([---0-9]*\\))" string)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1014 (rplaca TeX-error-offset
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1015 (string-to-int (substring string
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1016 (match-beginning 1)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1017 (match-end 1))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1018 t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1019
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1020 ;; Hook to change file name
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1021 ((string-match "!name(\\([^)]*\\))" string)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1022 (rplaca TeX-error-file (substring string
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1023 (match-beginning 1)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1024 (match-end 1)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1025 t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1026
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1027 ;; No more errors.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1028 (t
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1029 (message "No more errors.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1030 (beep)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1031 (pop-to-buffer old)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1032 nil))))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1033
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1034 (defun TeX-error ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1035 "Display an error."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1036
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1037 (let* (;; We need the error message to show the user.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1038 (error (progn
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1039 (re-search-forward "\\(.*\\)")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1040 (TeX-match-buffer 1)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1041
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1042 ;; And the context for the help window.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1043 (context-start (point))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1044
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1045 ;; And the line number to position the cursor.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1046 (line (if (re-search-forward "l\\.\\([0-9]+\\)" nil t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1047 (string-to-int (TeX-match-buffer 1))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1048 1))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1049 ;; And a string of the context to search for.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1050 (string (progn
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1051 (beginning-of-line)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1052 (re-search-forward " \\(\\([^ \t]*$\\)\\|\\($\\)\\)")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1053 (TeX-match-buffer 1)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1054
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1055 ;; And we have now found to the end of the context.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1056 (context (buffer-substring context-start (progn
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1057 (forward-line 1)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1058 (end-of-line)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1059 (point))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1060 ;; We may use these in another buffer.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1061 (offset (car TeX-error-offset) )
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1062 (file (car TeX-error-file)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1063
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1064 ;; Remember where we was.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1065 (setq TeX-error-point (point))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1066
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1067 ;; Find the error.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1068 (if (null file)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1069 (error "Error occured after last TeX file closed"))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1070 (run-hooks 'TeX-translate-location-hook)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1071 (find-file-other-window file)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1072 (goto-line (+ offset line))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1073 (if (not (string= string " "))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1074 (search-forward string nil t))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1075
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1076 ;; Explain the error.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1077 (if TeX-display-help
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1078 (TeX-help-error error context)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1079 (message (concat "! " error)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1080
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1081 (defun TeX-warning (string)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1082 "Display a warning for STRING.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1083 Return nil if we gave a report."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1084
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1085 (let* ((error (concat "** " string))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1086
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1087 ;; bad-box is nil if this is a "LaTeX Warning"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1088 (bad-box (string-match "^.*erfull \\\\.*[0-9]*--[0-9]*" string))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1089 ;; line-string: match 1 is beginning line, match 2 is end line
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1090 (line-string (if bad-box " \\([0-9]*\\)--\\([0-9]*\\)"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1091 "on input line \\([0-9]*\\)\\."))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1092 ;; word-string: match 1 is the word
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1093 (word-string (if bad-box "[][\\W() ---]\\(\\w+\\)[][\\W() ---]*$"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1094 "`\\(\\w+\\)'"))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1095
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1096 ;; Get error-line (warning)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1097 (line (progn
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1098 (re-search-backward line-string)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1099 (string-to-int (TeX-match-buffer 1))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1100 (line-end (if bad-box (string-to-int (TeX-match-buffer 2))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1101 line))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1102
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1103 ;; Find the context
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1104 (context-start (progn (if bad-box (end-of-line)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1105 (beginning-of-line))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1106 (point)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1107
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1108 (context (progn
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1109 (forward-line 1)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1110 (end-of-line)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1111 (while (equal (current-column) 79)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1112 (forward-line 1)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1113 (end-of-line))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1114 (buffer-substring context-start (point))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1115
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1116 ;; This is where we want to be.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1117 (error-point (point))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1118
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1119 ;; Now find the error word.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1120 (string (progn
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1121 (re-search-backward word-string
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1122 context-start t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1123 (TeX-match-buffer 1)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1124
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1125 ;; We might use these in another file.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1126 (offset (car TeX-error-offset))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1127 (file (car TeX-error-file)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1128
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1129 ;; This is where we start next time.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1130 (goto-char error-point)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1131 (setq TeX-error-point (point))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1132
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1133 ;; Go back to TeX-buffer
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1134 (if TeX-debug-bad-boxes
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1135 (progn
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1136 (run-hooks 'TeX-translate-location-hook)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1137 (find-file-other-window file)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1138 ;; Find line and string
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1139 (goto-line (+ offset line))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1140 (beginning-of-line 0)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1141 (let ((start (point)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1142 (goto-line (+ offset line-end))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1143 (end-of-line)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1144 (search-backward string start t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1145 (search-forward string nil t))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1146 ;; Display help
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1147 (if TeX-display-help
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1148 (TeX-help-error error (if bad-box context (concat "\n" context)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1149 (message (concat "! " error)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1150 nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1151 t)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1152
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1153 ;;; - Help
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1154
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1155 (defun TeX-help-error (error output)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1156 "Print ERROR in context OUTPUT in another window."
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1157
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1158 (let ((old-buffer (current-buffer))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1159 (log-file (TeX-active-master "log"))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1160 (TeX-error-pointer 1))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1161
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1162 ;; Find help text entry.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1163 (while (not (string-match (car (nth TeX-error-pointer
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1164 TeX-error-description-list))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1165 error))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1166 (setq TeX-error-pointer (+ TeX-error-pointer 1)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1167
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1168 (pop-to-buffer (get-buffer-create "*TeX Help*"))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1169 (erase-buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1170 (insert "ERROR: " error
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1171 "\n\n--- TeX said ---"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1172 output
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1173 "\n--- HELP ---\n"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1174 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1175 (if (and (string= (cdr (nth TeX-error-pointer
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1176 TeX-error-description-list))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1177 "No help available")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1178 (let* ((log-buffer (find-file-noselect log-file)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1179 (set-buffer log-buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1180 (auto-save-mode nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1181 (setq buffer-read-only t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1182 (goto-line (point-min))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1183 (search-forward error nil t 1)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1184 (progn
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1185 (re-search-forward "^l.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1186 (re-search-forward "^ [^\n]+$")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1187 (forward-char 1)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1188 (let ((start (point)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1189 (re-search-forward "^$")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1190 (concat "From the .log file...\n\n"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1191 (buffer-substring start (point)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1192 (cdr (nth TeX-error-pointer
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1193 TeX-error-description-list)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1194 (goto-char (point-min))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1195 (pop-to-buffer old-buffer)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1196
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1197 ;;; Error Messages
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1198
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1199 (defvar TeX-error-description-list
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1200 '(("Bad \\\\line or \\\\vector argument.*" .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1201 "The first argument of a \\line or \\vector command, which specifies the
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1202 slope, is illegal\.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1203
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1204 ("Bad math environment delimiter.*" .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1205 "TeX has found either a math-mode-starting command such as \\[ or \\(
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1206 when it is already in math mode, or else a math-mode-ending command
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1207 such as \\) or \\] while in LR or paragraph mode. The problem is caused
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1208 by either unmatched math mode delimiters or unbalanced braces\.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1209
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1210 ("Bad use of \\\\\\\\.*" .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1211 "A \\\\ command appears between paragraphs, where it makes no sense. This
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1212 error message occurs when the \\\\ is used in a centering or flushing
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1213 environment or else in the scope of a centering or flushing
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1214 declaration.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1215
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1216 ("\\\\begin{[^ ]*} ended by \\\\end{[^ ]*}." .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1217 "LaTeX has found an \\end command that doesn't match the corresponding
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1218 \\begin command. You probably misspelled the environment name in the
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1219 \\end command, have an extra \\begin, or else forgot an \\end.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1220
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1221 ("Can be used only in preamble." .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1222 "LaTeX has encountered, after the \\begin{document}, one of the
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1223 following commands that should appear only in the preamble:
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1224 \\documentstyle, \\nofiles, \\includeonly, \\makeindex, or
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1225 \\makeglossary. The error is also caused by an extra \\begin{document}
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1226 command.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1227
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1228 ("Command name [^ ]* already used.*" .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1229 "You are using \\newcommand, \\newenvironment, \\newlength, \\newsavebox,
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1230 or \\newtheorem to define a command or environment name that is
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1231 already defined, or \\newcounter to define a counter that already
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1232 exists. (Defining an environment named gnu automatically defines the
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1233 command \\gnu.) You'll have to choose a new name or, in the case of
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1234 \\newcommand or \\newenvironment, switch to the \\renew ... command.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1235
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1236 ("Counter too large." .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1237 "Some object that is numbered with letters, probably an item in a
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1238 enumerated list, has received a number greater than 26. Either you're
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1239 making a very long list or you've been resetting counter values.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1240
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1241 ("Environment [^ ]* undefined." .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1242 "LaTeX has encountered a \\begin command for a nonexistent environment.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1243 You probably misspelled the environment name. ")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1244
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1245 ("Float(s) lost." .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1246 "You put a figure or table environment or a \\marginpar command inside a
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1247 parbox---either one made with a minipage environment or \\parbox
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1248 command, or one constructed by LaTeX in making a footnote, figure,
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1249 etc. This is an outputting error, and the offending environment or
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1250 command may be quite a way back from the point where LaTeX discovered
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1251 the problem. One or more figures, tables, and/or marginal notes have
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1252 been lost, but not necessarily the one that caused the error.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1253
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1254 ("Illegal character in array arg." .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1255 "There is an illegal character in the argument of an array or tabular
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1256 environment, or in the second argument of a \\multicolumn command.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1257
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1258 ("Missing \\\\begin{document}." .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1259 "LaTeX produced printed output before encountering a \\begin{document}
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1260 command. Either you forgot the \\begin{document} command or there is
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1261 something wrong in the preamble. The problem may be a stray character
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1262 or an error in a declaration---for example, omitting the braces around
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1263 an argument or forgetting the \\ in a command name.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1264
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1265 ("Missing p-arg in array arg.*" .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1266 "There is a p that is not followed by an expression in braces in the
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1267 argument of an array or tabular environment, or in the second argument
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1268 of a \\multicolumn command.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1269
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1270 ("Missing @-exp in array arg." .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1271 "There is an @ character not followed by an @-expression in the
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1272 argument of an array or tabular environment, or in the second argument
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1273 of a \\multicolumn command.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1274
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1275 ("No such counter." .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1276 "You have specified a nonexistent counter in a \\setcounter or
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1277 \\addtocounter command. This is probably caused by a simple typing
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1278 error. However, if the error occurred while a file with the extension
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1279 aux is being read, then you probably used a \\newcounter command
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1280 outside the preamble.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1281
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1282 ("Not in outer par mode." .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1283 "You had a figure or table environment or a \\marginpar command in math
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1284 mode or inside a parbox.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1285
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1286 ("\\\\pushtabs and \\\\poptabs don't match." .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1287 "LaTeX found a \\poptabs with no matching \\pushtabs, or has come to the
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1288 \\end{tabbing} command with one or more unmatched \\pushtabs commands.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1289
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1290 ("Something's wrong--perhaps a missing \\\\item." .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1291 "The most probable cause is an omitted \\item command in a list-making
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1292 environment. It is also caused by forgetting the argument of a
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1293 thebibliography environment.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1294
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1295 ("Tab overflow." .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1296 "A \\= command has exceeded the maximum number of tab stops that LaTeX
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1297 permits.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1298
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1299 ("There's no line here to end." .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1300 "A \\newline or \\\\ command appears between paragraphs, where it makes no
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1301 sense. If you're trying to ``leave a blank line'', use a \\vspace
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1302 command.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1303
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1304 ("This may be a LaTeX bug." .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1305 "LaTeX has become thoroughly confused. This is probably due to a
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1306 previously detected error, but it is possible that you have found an
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1307 error in LaTeX itself. If this is the first error message produced by
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1308 the input file and you can't find anything wrong, save the file and
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1309 contact the person listed in your Local Guide.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1310
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1311 ("Too deeply nested." .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1312 "There are too many list-making environments nested within one another.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1313 How many levels of nesting are permitted may depend upon what computer
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1314 you are using, but at least four levels are provided, which should be
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1315 enough.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1316
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1317 ("Too many unprocessed floats." .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1318 "While this error can result from having too many \\marginpar commands
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1319 on a page, a more likely cause is forcing LaTeX to save more figures
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1320 and tables than it has room for. When typesetting its continuous
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1321 scroll, LaTeX saves figures and tables separately and inserts them as
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1322 it cuts off pages. This error occurs when LaTeX finds too many figure
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1323 and/or table environments before it is time to cut off a page, a
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1324 problem that is solved by moving some of the environments farther
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1325 towards the end of the input file. The error can also be caused by a
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1326 ``logjam''---a figure or table that cannot be printed causing others
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1327 to pile up behind it, since LaTeX will not print figures or tables out
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1328 of order. The jam can be started by a figure or table that either is
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1329 too large to fit on a page or won't fit where its optional placement
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1330 argument says it must go. This is likely to happen if the argument
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1331 does not contain a p option.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1332
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1333 ("Undefined tab position." .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1334 "A \\>, \\+, \\-, or \\< command is trying to go to a nonexistent tab
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1335 position---one not defined by a \\= command.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1336
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1337 ("\\\\< in mid line." .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1338 "A \\< command appears in the middle of a line in a tabbing environment.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1339 This command should come only at the beginning of a line.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1340
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1341 ("Counter too large." .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1342 "Footnotes are being ``numbered'' with letters or footnote symbols and
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1343 LaTeX has run out of letters or symbols. This is probably caused by
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1344 too many \\thanks commands.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1345
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1346 ("Double subscript." .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1347 "There are two subscripts in a row in a mathematical
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1348 formula---something like x_{2}_{3}, which makes no sense.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1349
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1350 ("Double superscript." .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1351 "There are two superscripts in a row in a mathematical
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1352 formula---something like x^{2}^{3}, which makes no sense.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1353
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1354 ("Extra alignment tab has been changed to \\\\cr." .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1355 "There are too many separate items (column entries) in a single row of
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1356 an array or tabular environment. In other words, there were too many &
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1357 's before the end of the row. You probably forgot the \\\\ at the end of
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1358 the preceding row.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1359
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1360 ("Extra \\}, or forgotten \\$." .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1361 "The braces or math mode delimiters don't match properly. You probably
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1362 forgot a {, \\[, \\(, or $.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1363
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1364 ("Font [^ ]* not loaded: Not enough room left." .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1365 "The document uses more fonts than TeX has room for. If different parts
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1366 of the document use different fonts, then you can get around the
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1367 problem by processing it in parts.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1368
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1369 ("I can't find file `.*'." .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1370 "TeX can't find a file that it needs. If the name of the missing file
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1371 has the extension tex, then it is looking for an input file that you
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1372 specified---either your main file or another file inserted with an
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1373 \\input or \\include command. If the missing file has the extension sty
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1374 , then you have specified a nonexistent document style or style
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1375 option.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1376
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1377 ("Illegal parameter number in definition of .*" .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1378 "This is probably caused by a \\newcommand, \\renewcommand,
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1379 \\newenvironment, or \\renewenvironment command in which a # is used
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1380 incorrectly. A # character, except as part of the command name \\#,
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1381 can be used only to indicate an argument parameter, as in #2, which
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1382 denotes the second argument. This error is also caused by nesting one
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1383 of the above four commands inside another, or by putting a parameter
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1384 like #2 in the last argument of a \\newenvironment or \\renewenvironment
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1385 command.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1386
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1387 ("Illegal unit of measure ([^ ]* inserted)." .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1388 "If you just got a
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1389
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1390 ! Missing number, treated as zero.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1391
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1392 error, then this is part of the same problem. If not, it means that
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1393 LaTeX was expecting a length as an argument and found a number
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1394 instead. The most common cause of this error is writing 0 instead of
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1395 something like 0in for a length of zero, in which case typing return
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1396 should result in correct output. However, the error can also be caused
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1397 by omitting a command argument.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1398
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1399 ("Misplaced alignment tab character \\&." .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1400 "The special character &, which should be used only to separate items
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1401 in an array or tabular environment, appeared in ordinary text. You
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1402 probably meant to type \\&.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1403
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1404 ("Missing control sequence inserted." .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1405 "This is probably caused by a \\newcommand, \\renewcommand, \\newlength,
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1406 or \\newsavebox command whose first argument is not a command name.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1407
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1408 ("Missing number, treated as zero." .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1409 "This is usually caused by a LaTeX command expecting but not finding
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1410 either a number or a length as an argument. You may have omitted an
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1411 argument, or a square bracket in the text may have been mistaken for
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1412 the beginning of an optional argument. This error is also caused by
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1413 putting \\protect in front of either a length command or a command such
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1414 as \\value that produces a number.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1415
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1416 ("Missing [{}] inserted." .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1417 "TeX has become confused. The position indicated by the error locator
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1418 is probably beyond the point where the incorrect input is.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1419
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1420 ("Missing \\$ inserted." .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1421 "TeX probably found a command that can be used only in math mode when
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1422 it wasn't in math mode. Remember that unless stated otherwise, all
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1423 the commands of Section can be used only in math mode. TeX is not in
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1424 math mode when it begins processing the argument of a box-making
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1425 command, even if that command is inside a math environment. This error
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1426 also occurs if TeX encounters a blank line when it is in math mode.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1427
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1428 ("Not a letter." .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1429 "Something appears in the argument of a \\hyphenation command that
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1430 doesn't belong there.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1431
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1432 ("Paragraph ended before [^ ]* was complete." .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1433 "A blank line occurred in a command argument that shouldn't contain
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1434 one. You probably forgot the right brace at the end of an argument.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1435
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1436 ("\\\\[^ ]*font [^ ]* is undefined .*" .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1437 "These errors occur when an uncommon font is used in math mode---for
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1438 example, if you use a \\sc command in a formula inside a footnote,
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1439 calling for a footnote-sized small caps font. This problem is solved
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1440 by using a \\load command.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1441
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1442 ("Font .* not found." .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1443 "You requested a family/series/shape/size combination that is totally
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1444 unknown. There are two cases in which this error can occur:
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1445 1) You used the \\size macro to select a size that is not available.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1446 2) If you did not do that, go to your local `wizard' and
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1447 complain fiercely that the font selection tables are corrupted!")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1448
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1449 ("TeX capacity exceeded, sorry .*" .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1450 "TeX has just run out of space and aborted its execution. Before you
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1451 panic, remember that the least likely cause of this error is TeX not
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1452 having the capacity to process your document. It was probably an
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1453 error in your input file that caused TeX to run out of room. The
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1454 following discussion explains how to decide whether you've really
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1455 exceeded TeX's capacity and, if so, what to do. If the problem is an
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1456 error in the input, you may have to use the divide and conquer method
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1457 described previously to locate it. LaTeX seldom runs out of space on a
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1458 short input file, so if running it on the last few pages before the
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1459 error indicator's position still produces the error, then there's
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1460 almost certainly something wrong in the input file.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1461
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1462 The end of the error indicator tells what kind of space TeX ran out
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1463 of. The more common ones are listed below, with an explanation of
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1464 their probable causes.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1465
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1466 buffer size
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1467 ===========
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1468 Can be caused by too long a piece of text as the argument
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1469 of a sectioning, \\caption, \\addcontentsline, or \\addtocontents
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1470 command. This error will probably occur when the \\end{document} is
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1471 being processed, but it could happen when a \\tableofcontents,
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1472 \\listoffigures, or \\listoftables command is executed. To solve this
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1473 problem, use a shorter optional argument. Even if you're producing a
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1474 table of contents or a list of figures or tables, such a long entry
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1475 won't help the reader.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1476
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1477 exception dictionary
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1478 ====================
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1479 You have used \\hyphenation commands to give TeX
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1480 more hyphenation information than it has room for. Remove some of the
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1481 less frequently used words from the \\hyphenation commands and insert
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1482 \\- commands instead.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1483
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1484 hash size
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1485 =========
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1486 Your input file defines too many command names and/or uses
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1487 too many cross-ref- erencing labels.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1488
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1489 input stack size
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1490 ================
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1491 This is probably caused by an error in a command
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1492 definition. For example, the following command makes a circular
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1493 definition, defining \\gnu in terms of itself:
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1494
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1495 \\newcommand{\\gnu}{a \\gnu} % This is wrong!
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1496
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1497 When TeX encounters this \\gnu command, it will keep chasing its tail
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1498 trying to figure out what \\gnu should produce, and eventually run out
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1499 of ``input stack''.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1500
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1501 main memory size
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1502 ================
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1503 This is one kind of space that TeX can run out of when processing a
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1504 short file. There are three ways you can run TeX out of main memory
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1505 space: (1) defining a lot of very long, complicated commands, (2)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1506 making an index or glossary and having too many \\index or \\glossary
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1507 commands on a single page, and (3) creating so complicated a page of
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1508 output that TeX can't hold all the information needed to generate it.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1509 The solution to the first two problems is obvious: define fewer
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1510 commands or use fewer \\index and \\glossary commands. The third problem
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1511 is nastier. It can be caused by large tabbing, tabular, array, and
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1512 picture environments. TeX's space may also be filled up with figures
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1513 and tables waiting for a place to go. To find out if you've really
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1514 exceeded TeX's capacity in this way, put a \\clearpage command in your
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1515 input file right before the place where TeX ran out of room and try
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1516 running it again. If it doesn't run out of room with the \\clearpage
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1517 command there, then you did exceed TeX's capacity. If it still runs
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1518 out of room, then there's probably an error in your file. If TeX is
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1519 really out of room, you must give it some help. Remember that TeX
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1520 processes a complete paragraph before deciding whether to cut the
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1521 page. Inserting a \\newpage command in the middle of the paragraph,
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1522 where TeX should break the page, may save the day by letting TeX write
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1523 the current page before processing the rest of the paragraph. (A
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1524 \\pagebreak command won't help.) If the problem is caused by
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1525 accumulated figures and tables, you can try to prevent them from
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1526 accumulating---either by moving them further towards the end of the
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1527 document or by trying to get them to come out sooner. If you are
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1528 still writing the document, simply add a \\clearpage command and forget
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1529 about the problem until you're ready to produce the final version.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1530 Changes to the input file are likely to make the problem go away.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1531
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1532 pool size
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1533 =========
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1534 You probably used too many cross-ref-erencing \\labels and/or defined
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1535 too many new command names. More precisely, the labels and command
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1536 names that you define have too many characters, so this problem can be
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1537 solved by using shorter names. However, the error can also be caused
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1538 by omitting the right brace that ends the argument of either a counter
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1539 command such as \\setcounter, or a \\newenvironment or \\newtheorem
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1540 command.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1541
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1542 save size
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1543 =========
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1544 This occurs when commands, environments, and the scopes of
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1545 declarations are nested too deeply---for example, by having the
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1546 argument of a \\multiput command contain a picture environment that in
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1547 turn has a \\footnotesize declaration whose scope contains a \\multiput
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1548 command containing a ....")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1549
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1550 ("Text line contains an invalid character." .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1551 "The input contains some strange character that it shouldn't. A mistake
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1552 when creating the file probably caused your text editor to insert this
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1553 character. Exactly what could have happened depends upon what text
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1554 editor you used. If examining the input file doesn't reveal the
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1555 offending character, consult the Local Guide for suggestions.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1556
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1557 ("Undefined control sequence." .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1558 "TeX encountered an unknown command name. You probably misspelled the
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1559 name. If this message occurs when a LaTeX command is being processed,
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1560 the command is probably in the wrong place---for example, the error
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1561 can be produced by an \\item command that's not inside a list-making
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1562 environment. The error can also be caused by a missing \\documentstyle
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1563 command.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1564
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1565 ("Use of [^ ]* doesn't match its definition." .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1566 "It's probably one of the picture-drawing commands, and you have used
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1567 the wrong syntax for specifying an argument. If it's \\@array that
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1568 doesn't match its definition, then there is something wrong in an
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1569 @-expression in the argument of an array or tabular
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1570 environment---perhaps a fragile command that is not \\protect'ed.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1571
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1572 ("You can't use `macro parameter character \\#' in [^ ]* mode." .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1573 "The special character # has appeared in ordinary text. You probably
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1574 meant to type \\#.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1575
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1576 ("Overfull \\\\hbox .*" .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1577 "Because it couldn't find a good place for a line break, TeX put more
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1578 on this line than it should.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1579
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1580 ("Overfull \\\\vbox .*" .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1581 "Because it couldn't find a good place for a page break, TeX put more
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1582 on the page than it should. ")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1583
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1584 ("Underfull \\\\hbox .*" .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1585 "Check your output for extra vertical space. If you find some, it was
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1586 probably caused by a problem with a \\\\ or \\newline command---for
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1587 example, two \\\\ commands in succession. This warning can also be
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1588 caused by using the sloppypar environment or \\sloppy declaration, or
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1589 by inserting a \\linebreak command.")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1590
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1591 ("Underfull \\\\vbox .*" .
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1592 "TeX could not find a good place to break the page, so it produced a
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1593 page without enough text on it. ")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1594
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1595 ;; New list items should be placed here
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1596 ;;
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1597 ;; ("err-regexp" . "context")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1598 ;;
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1599 ;; the err-regexp item should match anything
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1600
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1601 (".*" . "No help available")) ; end definition
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1602 "A list of the form (\"err-regexp\" . \"context\") used by function
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1603 \\{TeX-help-error} to display help-text on an error message or warning.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1604 err-regexp should be a regular expression matching the error message
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1605 given from TeX/LaTeX, and context should be some lines describing that
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1606 error")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1607
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1608 (provide 'tex-buf)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1609
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents:
diff changeset
1610 ;;; tex-buf.el ends here