annotate lisp/auctex/tex-buf.el @ 153:25f70ba0133c r20-3b3

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