0
|
1 ;;; compile.el --- run compiler as inferior of Emacs, parse error messages.
|
|
2
|
2
|
3 ;; Copyright (C) 1985, 86, 87, 93, 94, 1995, 1996 Free Software Foundation, Inc.
|
0
|
4 ;; Copyright (C) 1995 Tinker Systems and INS Engineering Corp.
|
|
5
|
|
6 ;; Author: Roland McGrath <roland@prep.ai.mit.edu>
|
|
7 ;; Maintainer: FSF
|
|
8 ;; Keywords: tools, processes
|
|
9
|
|
10 ;; This file is part of XEmacs.
|
|
11
|
|
12 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
13 ;; under the terms of the GNU General Public License as published by
|
|
14 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
15 ;; any later version.
|
|
16
|
|
17 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
20 ;; General Public License for more details.
|
|
21
|
|
22 ;; You should have received a copy of the GNU General Public License
|
|
23 ;; along with XEmacs; see the file COPYING. If not, write to the Free
|
2
|
24 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
25 ;; 02111-1307, USA.
|
0
|
26
|
2
|
27 ;;; Synched up with: FSF 19.34, with a lot of divergence.
|
0
|
28
|
|
29 ;;; Commentary:
|
|
30
|
|
31 ;; This package provides the compile and grep facilities documented in
|
|
32 ;; the Emacs user's manual.
|
|
33
|
|
34 ;;; Code:
|
|
35
|
120
|
36 (defgroup compilation nil
|
189
|
37 "Run compiler as inferior of Emacs, parse error messages."
|
|
38 :group 'programming
|
|
39 :group 'tools
|
|
40 :group 'processes)
|
120
|
41
|
0
|
42
|
|
43 ;;;###autoload
|
120
|
44 (defcustom compilation-mode-hook nil
|
|
45 "*List of hook functions run by `compilation-mode' (see `run-hooks')."
|
|
46 :type 'hook
|
|
47 :group 'compilation)
|
|
48
|
|
49 ;;;###autoload
|
|
50 (defcustom compilation-window-height nil
|
|
51 "*Number of lines in a compilation window. If nil, use Emacs default."
|
|
52 :type '(choice (const nil)
|
|
53 integer)
|
|
54 :group 'compilation)
|
0
|
55
|
2
|
56 ;; XEmacs change
|
0
|
57 (defvar compilation-error-list 'invalid ; only valid buffer-local
|
|
58 "List of error message descriptors for visiting erring functions.
|
|
59 Each error descriptor is a cons (or nil). Its car is a marker pointing to
|
|
60 an error message. If its cdr is a marker, it points to the text of the
|
|
61 line the message is about. If its cdr is a cons, it is a list
|
|
62 \(\(DIRECTORY . FILE\) LINE [COLUMN]\). Or its cdr may be nil if that
|
|
63 error is not interesting.
|
|
64
|
|
65 The value may be t instead of a list; this means that the buffer of
|
|
66 error messages should be reparsed the next time the list of errors is wanted.
|
|
67
|
|
68 Some other commands (like `diff') use this list to control the error
|
2
|
69 message tracking facilities; if you change its structure, you should make
|
0
|
70 sure you also change those packages. Perhaps it is better not to change
|
|
71 it at all.")
|
|
72
|
|
73 (defvar compilation-old-error-list nil
|
|
74 "Value of `compilation-error-list' after errors were parsed.")
|
|
75
|
|
76 (defvar compilation-parse-errors-function 'compilation-parse-errors
|
|
77 "Function to call to parse error messages from a compilation.
|
|
78 It takes args LIMIT-SEARCH and FIND-AT-LEAST.
|
|
79 If LIMIT-SEARCH is non-nil, don't bother parsing past that location.
|
|
80 If FIND-AT-LEAST is non-nil, don't bother parsing after finding that
|
|
81 many new errors.
|
|
82 It should read in the source files which have errors and set
|
|
83 `compilation-error-list' to a list with an element for each error message
|
|
84 found. See that variable for more info.")
|
|
85
|
|
86 ;;;###autoload
|
120
|
87 (defcustom compilation-buffer-name-function nil
|
0
|
88 "Function to compute the name of a compilation buffer.
|
|
89 The function receives one argument, the name of the major mode of the
|
|
90 compilation buffer. It should return a string.
|
120
|
91 nil means compute the name with `(concat \"*\" (downcase major-mode) \"*\")'."
|
|
92 :type 'function
|
|
93 :group 'compilation)
|
0
|
94
|
|
95 ;;;###autoload
|
120
|
96 (defcustom compilation-finish-function nil
|
0
|
97 "*Function to call when a compilation process finishes.
|
|
98 It is called with two arguments: the compilation buffer, and a string
|
120
|
99 describing how the process finished."
|
|
100 :type 'function
|
|
101 :group 'compilation)
|
0
|
102
|
|
103 (defvar compilation-last-buffer nil
|
|
104 "The most recent compilation buffer.
|
|
105 A buffer becomes most recent when its compilation is started
|
|
106 or when it is used with \\[next-error] or \\[compile-goto-error].")
|
|
107
|
|
108 (defvar compilation-in-progress nil
|
|
109 "List of compilation processes now running.")
|
|
110 (or (assq 'compilation-in-progress minor-mode-alist)
|
|
111 (setq minor-mode-alist (cons '(compilation-in-progress " Compiling")
|
|
112 minor-mode-alist)))
|
|
113
|
2
|
114 ;; XEmacs change
|
120
|
115 (defcustom compilation-always-signal-completion nil
|
|
116 "*Always give an audible signal upon compilation completion.
|
0
|
117 By default that signal is only given if the bottom of the compilation
|
120
|
118 buffer is not visible in its window."
|
|
119 :type 'boolean
|
|
120 :group 'compilation)
|
0
|
121
|
|
122 (defvar compilation-parsing-end nil
|
|
123 "Position of end of buffer when last error messages were parsed.")
|
|
124
|
|
125 (defvar compilation-error-message "No more errors"
|
|
126 "Message to print when no more matches are found.")
|
|
127
|
|
128 (defvar compilation-num-errors-found)
|
|
129
|
120
|
130 (defcustom compilation-error-regexp-systems-list 'all
|
|
131 "*This is either the symbol `all', or a list of systems for which
|
116
|
132 compilation error regexps should be included in
|
|
133 `compilation-error-regexp-alist'.
|
|
134
|
|
135 The list of known systems is:
|
|
136 gnu: but of course
|
|
137 lcc: Lucid compilers
|
|
138 ada: Ada compilers
|
|
139 of: Using tool that says line xx of foo.c
|
|
140 comma: Using tool that says \"foo.c\", line 12
|
|
141 4bsd: Using 4bsd
|
|
142 msft: Using microsoft
|
|
143 borland: Using Borland
|
|
144 mips: Using Mips
|
|
145 sgi: Using SGI
|
|
146 cray: Using Cray
|
|
147 ibm: IBM C compilers
|
|
148 aix: the operating system
|
|
149 ultrix: the operating system
|
|
150
|
120
|
151 See also the variable `compilation-error-regexp-alist-alist'."
|
189
|
152 :type '(choice (const all)
|
|
153 (set :menu-tag "Pick"
|
|
154 (const gnu) (const lcc) (const ada)
|
|
155 (const of) (const comma) (const 4bsd)
|
|
156 (const msft) (const borland) (const mips)
|
|
157 (const sgi) (const cray) (const ibm)
|
|
158 (const aix) (const ultrix)))
|
120
|
159 :group 'compilation)
|
116
|
160
|
|
161 (defun compilation-build-compilation-error-regexp-alist ()
|
|
162 (interactive)
|
|
163 (setq compilation-error-regexp-alist
|
|
164 (apply 'append
|
|
165 (mapcar
|
|
166 '(lambda (elt)
|
|
167 (if (or (not (consp compilation-error-regexp-systems-list))
|
|
168 (and (consp (car elt))
|
|
169 (intersection (car elt)
|
|
170 compilation-error-regexp-systems-list))
|
|
171 (memq (car elt) compilation-error-regexp-systems-list))
|
|
172 (cdr elt)
|
|
173 nil))
|
|
174 compilation-error-regexp-alist-alist))))
|
|
175
|
|
176 (defvar compilation-error-regexp-alist-alist
|
0
|
177 '(
|
|
178 ;; NOTE! See also grep-regexp-alist, below.
|
|
179
|
|
180 ;; 4.3BSD grep, cc, lint pass 1:
|
|
181 ;; /usr/src/foo/foo.c(8): warning: w may be used before set
|
|
182 ;; or GNU utilities:
|
|
183 ;; foo.c:8: error message
|
|
184 ;; or HP-UX 7.0 fc:
|
|
185 ;; foo.f :16 some horrible error message
|
|
186 ;; or GNU utilities with column (GNAT 1.82):
|
|
187 ;; foo.adb:2:1: Unit name does not match file name
|
|
188 ;;
|
|
189 ;; We'll insist that the number be followed by a colon or closing
|
|
190 ;; paren, because otherwise this matches just about anything
|
|
191 ;; containing a number with spaces around it.
|
116
|
192 ((4bsd gnu)
|
88
|
193 ("\
|
2
|
194 \\([a-zA-Z]?:?[^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\)\\([) \t]\\|\
|
0
|
195 :\\([^0-9\n]\\|\\([0-9]+:\\)\\)\\)" 1 2 5)
|
116
|
196 )
|
0
|
197
|
2
|
198 ;; Microsoft C/C++:
|
|
199 ;; keyboard.c(537) : warning C4005: 'min' : macro redefinition
|
|
200 ;; d:\tmp\test.c(23) : error C2143: syntax error : missing ';' before 'if'
|
116
|
201 (msft
|
88
|
202 ("\\(\\([a-zA-Z]:\\)?[^:( \t\n-]+\\)[:(][ \t]*\\([0-9]+\\)[:) \t]" 1 3)
|
116
|
203 )
|
2
|
204
|
0
|
205 ;; Borland C++:
|
|
206 ;; Error ping.c 15: Unable to open include file 'sys/types.h'
|
|
207 ;; Warning ping.c 68: Call to function 'func' with no prototype
|
116
|
208 (borland
|
88
|
209 ("\\(Error\\|Warning\\) \\([a-zA-Z]?:?[^:( \t\n]+\\)\
|
0
|
210 \\([0-9]+\\)\\([) \t]\\|:[^0-9\n]\\)" 2 3)
|
116
|
211 )
|
0
|
212
|
|
213 ;; 4.3BSD lint pass 2
|
|
214 ;; strcmp: variable # of args. llib-lc(359) :: /usr/src/foo/foo.c(8)
|
116
|
215 (4bsd
|
88
|
216 ("[^\n]*[ \t:]\\([a-zA-Z]?:?[^:( \t\n]+\\)[:(](+[ \t]*\\([0-9]+\\))[:) \t]*$"
|
2
|
217 1 2)
|
116
|
218 )
|
0
|
219
|
|
220 ;; 4.3BSD lint pass 3
|
|
221 ;; bloofle defined( /users/wolfgang/foo.c(4) ), but never used
|
|
222 ;; This used to be
|
2
|
223 ;; ("[ \t(]+\\([a-zA-Z]?:?[^:( \t\n]+\\)[:( \t]+\\([0-9]+\\)[:) \t]+" 1 2)
|
0
|
224 ;; which is regexp Impressionism - it matches almost anything!
|
116
|
225 (4bsd
|
88
|
226 ("[^\n]*([ \t]*\\([a-zA-Z]?:?[^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\))" 1 2)
|
116
|
227 )
|
2
|
228
|
|
229 ;; MIPS lint pass<n>; looks good for SunPro lint also
|
|
230 ;; TrimMask (255) in solomon.c may be indistinguishable from TrimMasks (93) in solomon.c due to truncation
|
116
|
231 (mips
|
88
|
232 ("[^ \n]+ (\\([0-9]+\\)) in \\([^ \n]+\\)" 2 1)
|
2
|
233 ;; name defined but never used: LinInt in cmap_calc.c(199)
|
88
|
234 ("[^\n]*in \\([^(\n]+\\)(\\([0-9]+\\))$" 1 2)
|
116
|
235 )
|
0
|
236
|
|
237 ;; Ultrix 3.0 f77:
|
|
238 ;; fort: Severe: addstf.f, line 82: Missing operator or delimiter symbol
|
|
239 ;; Some SGI cc version:
|
|
240 ;; cfe: Warning 835: foo.c, line 2: something
|
116
|
241 ((sgi ultrix)
|
88
|
242 ("\\(cfe\\|fort\\): [^:\n]*: \\([^ \n]*\\), line \\([0-9]+\\):" 2 3)
|
116
|
243 )
|
0
|
244 ;; Error on line 3 of t.f: Execution error unclassifiable statement
|
|
245 ;; Unknown who does this:
|
2
|
246 ;; Line 45 of "foo.c": bloofle undefined
|
0
|
247 ;; Absoft FORTRAN 77 Compiler 3.1.3
|
|
248 ;; error on line 19 of fplot.f: spelling error?
|
|
249 ;; warning on line 17 of fplot.f: data type is undefined for variable d
|
116
|
250 (of
|
88
|
251 ("\\(\\|[^\n]* on \\)[Ll]ine[ \t]+\\([0-9]+\\)[ \t]+\
|
2
|
252 of[ \t]+\"?\\([a-zA-Z]?:?[^\":\n]+\\)\"?:" 3 2)
|
116
|
253 )
|
0
|
254
|
|
255 ;; Apollo cc, 4.3BSD fc:
|
|
256 ;; "foo.f", line 3: Error: syntax error near end of statement
|
|
257 ;; IBM RS6000:
|
|
258 ;; "vvouch.c", line 19.5: 1506-046 (S) Syntax error.
|
|
259 ;; Unknown compiler:
|
|
260 ;; File "foobar.ml", lines 5-8, characters 20-155: blah blah
|
|
261 ;; Microtec mcc68k:
|
|
262 ;; "foo.c", line 32 pos 1; (E) syntax error; unexpected symbol: "lossage"
|
|
263 ;; GNAT (as of July 94):
|
|
264 ;; "foo.adb", line 2(11): warning: file name does not match ...
|
2
|
265 ;; IBM AIX xlc compiler:
|
|
266 ;; "src/swapping.c", line 30.34: 1506-342 (W) "/*" detected in comment.
|
116
|
267 (comma
|
88
|
268 ("[^\n]*\"\\([^,\" \n\t]+\\)\", lines? \
|
2
|
269 \\([0-9]+\\)\\([\(.]\\([0-9]+\\)\)?\\)?[:., (-]" 1 2 4)
|
116
|
270 )
|
0
|
271
|
|
272 ;; MIPS RISC CC - the one distributed with Ultrix:
|
|
273 ;; ccom: Error: foo.c, line 2: syntax error
|
|
274 ;; DEC AXP OSF/1 cc
|
|
275 ;; /usr/lib/cmplrs/cc/cfe: Error: foo.c: 1: blah blah
|
116
|
276 ((mips ultrix)
|
88
|
277 ("[^\n]*rror: \\([^,\" \n\t]+\\)[,:] \\(line \\)?\\([0-9]+\\):" 1 3)
|
116
|
278 )
|
0
|
279
|
|
280 ;; IBM AIX PS/2 C version 1.1:
|
|
281 ;; ****** Error number 140 in line 8 of file errors.c ******
|
116
|
282 (aix
|
88
|
283 ("[^\n]*in line \\([0-9]+\\) of file \\([^ \n]+[^. \n]\\)\\.? " 2 1)
|
116
|
284 )
|
0
|
285 ;; IBM AIX lint is too painful to do right this way. File name
|
|
286 ;; prefixes entire sections rather than being on each line.
|
|
287
|
|
288 ;; Lucid Compiler, lcc 3.x
|
|
289 ;; E, file.cc(35,52) Illegal operation on pointers
|
116
|
290 (lcc
|
88
|
291 ("[EW], \\([^(\n]*\\)(\\([0-9]+\\),[ \t]*\\([0-9]+\\)" 1 2 3)
|
116
|
292 )
|
0
|
293
|
|
294 ;; GNU messages with program name and optional column number.
|
116
|
295 (gnu
|
88
|
296 ("[a-zA-Z]?:?[^0-9 \n\t:]+:[ \t]*\\([^ \n\t:]+\\):\
|
0
|
297 \\([0-9]+\\):\\(\\([0-9]+\\)[: \t]\\)?" 1 2 4)
|
116
|
298 )
|
0
|
299
|
88
|
300 ;; GNU messages with program name and optional column number
|
|
301 ;; and a severity letter after that. nsgmls makes them.
|
116
|
302 (gnu
|
88
|
303 ("[^0-9 \n\t:]+:[ \t]*\\([^ \n\t:]+\\):\
|
|
304 \\([0-9]+\\):\\(\\([0-9]+\\):\\)?[A-Za-z]:" 1 2 4)
|
116
|
305 )
|
88
|
306
|
0
|
307 ;; jwz:
|
|
308 ;; IRIX 5.2
|
|
309 ;; cfe: Warning 712: foo.c, line 2: illegal combination of pointer and ...
|
116
|
310 (sgi
|
88
|
311 ("[^\n]* \\([^ \n,\"]+\\), line \\([0-9]+\\):" 1 2)
|
116
|
312 )
|
0
|
313 ;; IRIX 5.2
|
|
314 ;; cfe: Warning 600: xfe.c: 170: Not in a conditional directive while ...
|
116
|
315 (sgi
|
88
|
316 ("[^\n]*: \\([^ \n,\"]+\\): \\([0-9]+\\):" 1 2)
|
116
|
317 )
|
0
|
318
|
|
319 ;; Cray C compiler error messages
|
116
|
320 (cray
|
88
|
321 ("\\(cc\\| cft\\)-[0-9]+ c\\(c\\|f77\\): ERROR \\([^,\n]+, \\)* File = \\([^,\n]+\\), Line = \\([0-9]+\\)" 4 5)
|
116
|
322 )
|
0
|
323
|
|
324 ;; IBM C/C++ Tools 2.01:
|
|
325 ;; foo.c(2:0) : informational EDC0804: Function foo is not referenced.
|
|
326 ;; foo.c(3:8) : warning EDC0833: Implicit return statement encountered.
|
|
327 ;; foo.c(5:5) : error EDC0350: Syntax error.
|
116
|
328 (ibm
|
88
|
329 ("\\([^( \n\t]+\\)(\\([0-9]+\\):\\([0-9]+\\)) : " 1 2 3)
|
116
|
330 )
|
0
|
331
|
|
332 ;; Sun ada (VADS, Solaris):
|
|
333 ;; /home3/xdhar/rcds_rc/main.a, line 361, char 6:syntax error: "," inserted
|
116
|
334 (ada
|
88
|
335 ("\\([^, \n\t]+\\), line \\([0-9]+\\), char \\([0-9]+\\)[:., \(-]" 1 2 3)
|
0
|
336 )
|
116
|
337 )
|
|
338 "Alist of (system regexp-alist) for building
|
|
339 `compilation-error-regexp-alist'. SYSTEM is either a system identifier,
|
|
340 or a list of system identifiers. See the variable
|
|
341 `compilation-error-regexp-systems-list'")
|
|
342
|
|
343 (defvar compilation-error-regexp-alist nil
|
88
|
344 "Alist that specifies how to match errors in compiler output.
|
0
|
345 Each elt has the form (REGEXP FILE-IDX LINE-IDX [COLUMN-IDX FILE-FORMAT...])
|
88
|
346 If REGEXP matches constrained to the beginning of the line, the
|
|
347 FILE-IDX'th subexpression gives the file name, and the LINE-IDX'th
|
|
348 subexpression gives the line number. If COLUMN-IDX is given, the
|
|
349 COLUMN-IDX'th subexpression gives the column number on that line. If
|
|
350 any FILE-FORMAT is given, each is a format string to produce a file name
|
|
351 to try; %s in the string is replaced by the text matching the
|
|
352 FILE-IDX'th subexpression. Note previously REGEXP was not constrained
|
|
353 to the beginning of the line, so old patterns without leading `^' or `\\n'
|
116
|
354 may now require a leading `.*'.
|
|
355
|
|
356 Note that this now gets set by the function
|
|
357 `compilation-build-compilation-error-regexp-alist' using the
|
|
358 value of the variable `compilation-error-regexp-alist-alist'")
|
|
359
|
|
360 (compilation-build-compilation-error-regexp-alist)
|
0
|
361
|
120
|
362 (defcustom compilation-read-command t
|
|
363 "*If not nil, M-x compile reads the compilation command to use.
|
|
364 Otherwise, M-x compile just uses the value of `compile-command'."
|
|
365 :type 'boolean
|
|
366 :group 'compilation)
|
0
|
367
|
120
|
368 (defcustom compilation-ask-about-save t
|
|
369 "*If not nil, M-x compile asks which buffers to save before compiling.
|
|
370 Otherwise, it saves all modified buffers without asking."
|
|
371 :type 'boolean
|
|
372 :group 'compilation)
|
0
|
373
|
|
374 (defvar grep-regexp-alist
|
2
|
375 '(("^\\([a-zA-Z]?:?[^:( \t\n]+\\)[:( \t]+\\([0-9]+\\)[:) \t]" 1 2))
|
0
|
376 "Regexp used to match grep hits. See `compilation-error-regexp-alist'.")
|
|
377
|
120
|
378 (defcustom grep-command "grep -n "
|
|
379 "*Last grep command used in \\[grep]; default for next grep."
|
|
380 :type 'string
|
|
381 :group 'compilation)
|
0
|
382
|
|
383 ;;;###autoload
|
120
|
384 (defcustom compilation-search-path '(nil)
|
0
|
385 "*List of directories to search for source files named in error messages.
|
|
386 Elements should be directory names, not file names of directories.
|
120
|
387 nil as an element means to try the default directory."
|
|
388 :type '(repeat (choice (const :tag "Default" nil)
|
|
389 directory))
|
|
390 :group 'compilation)
|
0
|
391
|
120
|
392 (defcustom compile-command "make -k "
|
|
393 "*Last shell command used to do a compilation; default for next compilation.
|
0
|
394
|
|
395 Sometimes it is useful for files to supply local values for this variable.
|
|
396 You might also use mode hooks to specify it in certain modes, like this:
|
|
397
|
|
398 (setq c-mode-hook
|
|
399 '(lambda () (or (file-exists-p \"makefile\") (file-exists-p \"Makefile\")
|
|
400 (progn (make-local-variable 'compile-command)
|
|
401 (setq compile-command
|
|
402 (concat \"make -k \"
|
120
|
403 buffer-file-name))))))"
|
|
404 :type 'string
|
|
405 :group 'compilation)
|
0
|
406
|
|
407 (defvar compilation-enter-directory-regexp
|
88
|
408 "[^\n]*: Entering directory `\\([^\n]*\\)'$"
|
0
|
409 "Regular expression matching lines that indicate a new current directory.
|
|
410 This must contain one \\(, \\) pair around the directory name.
|
|
411
|
|
412 The default value matches lines printed by the `-w' option of GNU Make.")
|
|
413
|
|
414 (defvar compilation-leave-directory-regexp
|
88
|
415 "[^\n]*: Leaving directory `\\([^\n]*\\)'$"
|
0
|
416 "Regular expression matching lines that indicate restoring current directory.
|
|
417 This may contain one \\(, \\) pair around the name of the directory
|
|
418 being moved from. If it does not, the last directory entered \(by a
|
|
419 line matching `compilation-enter-directory-regexp'\) is assumed.
|
|
420
|
|
421 The default value matches lines printed by the `-w' option of GNU Make.")
|
|
422
|
|
423 (defvar compilation-directory-stack nil
|
|
424 "Stack of previous directories for `compilation-leave-directory-regexp'.
|
|
425 The head element is the directory the compilation was started in.")
|
|
426
|
|
427 (defvar compilation-exit-message-function nil "\
|
|
428 If non-nil, called when a compilation process dies to return a status message.
|
2
|
429 This should be a function of three arguments: process status, exit status,
|
|
430 and exit message; it returns a cons (MESSAGE . MODELINE) of the strings to
|
|
431 write into the compilation buffer, and to put in its mode line.")
|
0
|
432
|
|
433 ;; History of compile commands.
|
|
434 (defvar compile-history nil)
|
|
435 ;; History of grep commands.
|
|
436 (defvar grep-history nil)
|
|
437
|
2
|
438 ;; XEmacs
|
74
|
439 (defvar compilation-font-lock-keywords (purecopy
|
0
|
440 (list
|
|
441 '("^[-_.\"A-Za-z0-9/+]+\\(:\\|, line \\)[0-9]+: \\([wW]arning:\\).*$" .
|
|
442 font-lock-keyword-face)
|
|
443 '("^[-_.\"A-Za-z0-9/+]+\\(: *\\|, line \\)[0-9]+:.*$" . font-lock-function-name-face)
|
|
444 '("^[^:\n]+-[a-zA-Z][^:\n]+$" . font-lock-doc-string-face)
|
|
445 '("\\(^[-_.\"A-Za-z0-9/+]+\\)\\(: *\\|, line \\)[0-9]+" 1 font-lock-string-face t)
|
|
446 '("^[-_.\"A-Za-z0-9/+]+\\(: *[0-9]+\\|, line [0-9]+\\)" 1 bold t)
|
|
447 ))
|
|
448 "Additional expressions to highlight in Compilation mode.")
|
|
449
|
|
450 ;FSF's version. Ours looks better.
|
2
|
451 ;(defvar compilation-mode-font-lock-keywords
|
0
|
452 ; ;; This regexp needs a bit of rewriting. What is the third grouping for?
|
2
|
453 ; '(("^\\([a-zA-Z]?:?[^ \n:]*:\\([0-9]+:\\)+\\)\\(.*\\)$"
|
|
454 ; 1 font-lock-function-name-face))
|
|
455 ;;; ("^\\([^\n:]*:\\([0-9]+:\\)+\\)\\(.*\\)$" 0 font-lock-keyword-face keep)
|
|
456
|
|
457 ;; XEmacs change
|
0
|
458 (put 'compilation-mode 'font-lock-defaults
|
|
459 '(compilation-font-lock-keywords t))
|
|
460
|
120
|
461 (defcustom compilation-mouse-motion-initiate-parsing t
|
|
462 "*Should mouse motion over the compilation buffer initiate parsing?
|
|
463 When set to a non-nil value, mouse motion over the compilation/grep
|
|
464 buffer may initiate parsing of the error messages or grep hits.
|
|
465 When this is nil, errors and grep matches will no longer be
|
|
466 highlighted until they have been parsed, but may still be selected
|
|
467 with the center mouse button. This will then initiate parsing
|
|
468 and jump to the corresponding source line."
|
|
469 :type 'boolean
|
|
470 :group 'compilation)
|
0
|
471
|
|
472 ;;;###autoload
|
|
473 (defun compile (command)
|
|
474 "Compile the program including the current buffer. Default: run `make'.
|
|
475 Runs COMMAND, a shell command, in a separate process asynchronously
|
|
476 with output going to the buffer `*compilation*'.
|
|
477
|
|
478 You can then use the command \\[next-error] to find the next error message
|
|
479 and move to the source code that caused it.
|
|
480
|
|
481 Interactively, prompts for the command if `compilation-read-command' is
|
|
482 non-nil; otherwise uses `compile-command'. With prefix arg, always prompts.
|
|
483
|
|
484 To run more than one compilation at once, start one and rename the
|
|
485 \`*compilation*' buffer to some other name with \\[rename-buffer].
|
|
486 Then start the next one.
|
|
487
|
|
488 The name used for the buffer is actually whatever is returned by
|
|
489 the function in `compilation-buffer-name-function', so you can set that
|
|
490 to a function that generates a unique name."
|
|
491 (interactive
|
|
492 (if (or compilation-read-command current-prefix-arg)
|
2
|
493 ;; XEmacs change
|
0
|
494 (list (read-shell-command "Compile command: "
|
|
495 compile-command
|
|
496 ;; #### minibuffer code should do this
|
|
497 (if (equal (car compile-history)
|
|
498 compile-command)
|
|
499 '(compile-history . 1)
|
|
500 'compile-history)))
|
|
501 (list compile-command)))
|
|
502 (setq compile-command command)
|
|
503 (save-some-buffers (not compilation-ask-about-save) nil)
|
|
504 (compile-internal compile-command "No more errors"))
|
|
505
|
|
506 ;;; run compile with the default command line
|
|
507 (defun recompile ()
|
|
508 "Re-compile the program including the current buffer."
|
|
509 (interactive)
|
|
510 (save-some-buffers (not compilation-ask-about-save) nil)
|
|
511 (compile-internal compile-command "No more errors"))
|
|
512
|
|
513 ;; The system null device. (Should reference NULL_DEVICE from C.)
|
|
514 (defvar grep-null-device "/dev/null" "The system null device.")
|
|
515
|
|
516 ;;;###autoload
|
|
517 (defun grep (command-args)
|
|
518 "Run grep, with user-specified args, and collect output in a buffer.
|
|
519 While grep runs asynchronously, you can use the \\[next-error] command
|
|
520 to find the text that grep hits refer to.
|
|
521
|
|
522 This command uses a special history list for its arguments, so you can
|
|
523 easily repeat a grep command."
|
|
524 (interactive
|
2
|
525 ;; XEmacs change
|
0
|
526 (list (read-shell-command "Run grep (like this): "
|
|
527 grep-command 'grep-history)))
|
|
528 (let ((buf (compile-internal (concat command-args " " grep-null-device)
|
|
529 "No more grep hits" "grep"
|
|
530 ;; Give it a simpler regexp to match.
|
|
531 nil grep-regexp-alist)))
|
|
532 (save-excursion
|
|
533 (set-buffer buf)
|
|
534 (set (make-local-variable 'compilation-exit-message-function)
|
2
|
535 ;; XEmacs change
|
0
|
536 (lambda (proc msg)
|
|
537 (let ((code (process-exit-status proc)))
|
|
538 (if (eq (process-status proc) 'exit)
|
|
539 (cond ((zerop code)
|
|
540 '("finished (matches found)\n" . "matched"))
|
|
541 ((= code 1)
|
|
542 '("finished with no matches found\n" . "no match"))
|
|
543 (t
|
|
544 (cons msg code)))
|
|
545 (cons msg code))))))))
|
|
546
|
|
547 (defun compile-internal (command error-message
|
|
548 &optional name-of-mode parser regexp-alist
|
|
549 name-function)
|
|
550 "Run compilation command COMMAND (low level interface).
|
|
551 ERROR-MESSAGE is a string to print if the user asks to see another error
|
|
552 and there are no more errors. Third argument NAME-OF-MODE is the name
|
|
553 to display as the major mode in the compilation buffer.
|
|
554
|
|
555 Fourth arg PARSER is the error parser function (nil means the default). Fifth
|
|
556 arg REGEXP-ALIST is the error message regexp alist to use (nil means the
|
|
557 default). Sixth arg NAME-FUNCTION is a function called to name the buffer (nil
|
|
558 means the default). The defaults for these variables are the global values of
|
|
559 \`compilation-parse-errors-function', `compilation-error-regexp-alist', and
|
|
560 \`compilation-buffer-name-function', respectively.
|
|
561
|
|
562 Returns the compilation buffer created."
|
|
563 (let (outbuf)
|
|
564 (save-excursion
|
|
565 (or name-of-mode
|
|
566 (setq name-of-mode "Compilation"))
|
|
567 (setq outbuf
|
|
568 (get-buffer-create
|
|
569 (funcall (or name-function compilation-buffer-name-function
|
|
570 (function (lambda (mode)
|
|
571 (concat "*" (downcase mode) "*"))))
|
|
572 name-of-mode)))
|
|
573 (set-buffer outbuf)
|
|
574 (let ((comp-proc (get-buffer-process (current-buffer))))
|
|
575 (if comp-proc
|
|
576 (if (or (not (eq (process-status comp-proc) 'run))
|
|
577 (yes-or-no-p
|
|
578 (format "A %s process is running; kill it? "
|
|
579 name-of-mode)))
|
|
580 (condition-case ()
|
|
581 (progn
|
|
582 (interrupt-process comp-proc)
|
|
583 (sit-for 1)
|
|
584 (delete-process comp-proc))
|
|
585 (error nil))
|
|
586 (error "Cannot have two processes in `%s' at once"
|
|
587 (buffer-name))
|
|
588 )))
|
|
589 ;; In case the compilation buffer is current, make sure we get the global
|
|
590 ;; values of compilation-error-regexp-alist, etc.
|
|
591 (kill-all-local-variables))
|
|
592 (let ((regexp-alist (or regexp-alist compilation-error-regexp-alist))
|
|
593 (parser (or parser compilation-parse-errors-function))
|
|
594 (thisdir default-directory)
|
2
|
595 ;; XEmacs change
|
0
|
596 (buffer-save (current-buffer))
|
|
597 outwin)
|
2
|
598
|
|
599 ;; XEmacs change
|
0
|
600 ;; Pop up the compilation buffer.
|
|
601 (setq outwin (display-buffer outbuf))
|
|
602
|
|
603 (unwind-protect
|
|
604 (progn
|
|
605 ;; Clear out the compilation buffer and make it writable.
|
|
606 ;; Change its default-directory to the directory where the compilation
|
|
607 ;; will happen, and insert a `cd' command to indicate this.
|
|
608 (set-buffer outbuf)
|
2
|
609
|
0
|
610 (setq buffer-read-only nil)
|
|
611 (buffer-disable-undo (current-buffer))
|
|
612 (erase-buffer)
|
|
613 (buffer-enable-undo (current-buffer))
|
|
614 (setq default-directory thisdir)
|
|
615 (insert "cd " thisdir "\n" command "\n")
|
|
616 (set-buffer-modified-p nil)
|
|
617
|
2
|
618 ;; XEmacs change
|
0
|
619 ;; set it so the window will scroll to show compile output
|
|
620 (save-window-excursion
|
|
621 (select-window outwin)
|
|
622 (goto-char (point-max)))
|
|
623
|
2
|
624 ;; XEmacs change
|
0
|
625 (compilation-mode name-of-mode)
|
|
626 ;; (setq buffer-read-only t) ;;; Non-ergonomic.
|
2
|
627 ;; XEmacs change
|
0
|
628 (set (make-local-variable 'compile-command) command)
|
|
629 (set (make-local-variable 'compilation-parse-errors-function) parser)
|
|
630 (set (make-local-variable 'compilation-error-message) error-message)
|
|
631 (set (make-local-variable 'compilation-error-regexp-alist) regexp-alist)
|
|
632 (setq default-directory thisdir
|
|
633 compilation-directory-stack (list default-directory))
|
|
634 (set-window-start outwin (point-min))
|
|
635 (setq mode-name name-of-mode)
|
2
|
636 ;; XEmacs change
|
0
|
637 ; (or (eq outwin (selected-window))
|
|
638 ; (set-window-point outwin (point-min)))
|
|
639 (compilation-set-window-height outwin)
|
|
640 ;; Start the compilation.
|
|
641 (if (fboundp 'start-process)
|
|
642 (let* ((process-environment (cons "EMACS=t" process-environment))
|
|
643 (proc (start-process-shell-command (downcase mode-name)
|
|
644 outbuf
|
|
645 command)))
|
|
646 (set-process-sentinel proc 'compilation-sentinel)
|
|
647 (set-process-filter proc 'compilation-filter)
|
|
648 (set-marker (process-mark proc) (point) outbuf)
|
|
649 (setq compilation-in-progress
|
|
650 (cons proc compilation-in-progress)))
|
2
|
651 ;; No asynchronous processes available.
|
|
652 (message "Executing `%s'..." command)
|
|
653 ; FSF
|
|
654 ; (setq mode-line-process ":run")
|
|
655 ; (force-mode-line-update)
|
|
656 (sit-for 0) ;; Force redisplay
|
0
|
657 (let ((status (call-process shell-file-name nil outbuf nil "-c"
|
|
658 command))))
|
2
|
659 (message "Executing `%s'...done" command)))
|
0
|
660 (set-buffer buffer-save)))
|
|
661
|
|
662 ;; Make it so the next C-x ` will use this buffer.
|
|
663 (setq compilation-last-buffer outbuf)))
|
|
664
|
|
665 ;; Set the height of WINDOW according to compilation-window-height.
|
|
666 (defun compilation-set-window-height (window)
|
|
667 (and compilation-window-height
|
|
668 (= (window-width window) (frame-width (window-frame window)))
|
|
669 ;; If window is alone in its frame, aside from a minibuffer,
|
|
670 ;; don't change its height.
|
|
671 (not (eq window (frame-root-window (window-frame window))))
|
|
672 ;; This save-excursion prevents us from changing the current buffer,
|
|
673 ;; which might not be the same as the selected window's buffer.
|
|
674 (save-excursion
|
|
675 (let ((w (selected-window)))
|
|
676 (unwind-protect
|
|
677 (progn
|
|
678 (select-window window)
|
|
679 (enlarge-window (- compilation-window-height
|
|
680 (window-height))))
|
|
681 (select-window w))))))
|
|
682
|
|
683 (defvar compilation-minor-mode-map
|
|
684 (let ((map (make-sparse-keymap)))
|
|
685 (set-keymap-name map 'compilation-minor-mode-map)
|
|
686 (define-key map "\C-c\C-c" 'compile-goto-error)
|
|
687 (define-key map "\C-m" 'compile-goto-error)
|
|
688 (define-key map "\C-c\C-k" 'kill-compilation)
|
|
689 (define-key map "\M-n" 'compilation-next-error)
|
|
690 (define-key map "\M-p" 'compilation-previous-error)
|
|
691 (define-key map "\M-{" 'compilation-previous-file)
|
|
692 (define-key map "\M-}" 'compilation-next-file)
|
|
693 map)
|
|
694 "Keymap for `compilation-minor-mode'.")
|
|
695
|
|
696 (defvar compilation-mode-map
|
|
697 (let ((map (make-sparse-keymap)))
|
|
698 (set-keymap-parents map (list compilation-minor-mode-map))
|
|
699 (set-keymap-name map 'compilation-mode-map)
|
|
700 (define-key map " " 'scroll-up)
|
|
701 (define-key map "\^?" 'scroll-down)
|
|
702 (define-key map 'button2 'compile-mouse-goto-error)
|
|
703 map)
|
|
704 "Keymap for compilation log buffers.
|
|
705 `compilation-minor-mode-map' is a parent of this.")
|
|
706
|
|
707 ;;; XEmacs menus
|
|
708
|
|
709 (defun compilation-errors-exist-p (&optional buffer)
|
|
710 "Whether we are in a state where the `next-error' command will work,
|
|
711 that is, whether there exist (or may exist) error targets in the *compile*
|
|
712 or *grep* buffers."
|
|
713 (or buffer
|
|
714 (setq buffer (condition-case nil
|
|
715 (compilation-find-buffer)
|
|
716 (error nil))))
|
|
717 (and buffer
|
|
718 (compilation-buffer-p buffer)
|
|
719 (save-excursion
|
|
720 (set-buffer buffer)
|
|
721 ;; Has errors on the list, or needs to be parsed.
|
|
722 ;; But don't parse it now!
|
|
723 (or (not (null compilation-error-list))
|
|
724 (< compilation-parsing-end (point-max))))))
|
|
725
|
|
726 (defvar Compilation-mode-popup-menu
|
|
727 '("Compilation Mode Commands"
|
|
728 :filter compile-menu-filter
|
|
729 ["Compile..." compile t]
|
|
730 ["Recompile" recompile t]
|
|
731 ["Kill Compilation" kill-compilation (get-buffer-process (current-buffer))]
|
|
732 "---"
|
|
733 ["Goto Error" compile-goto-error (compilation-errors-exist-p)]
|
|
734 ["Next Error" next-error (compilation-errors-exist-p)]
|
|
735 ["Previous Error" previous-error (compilation-errors-exist-p)]
|
|
736 ["First Error" first-error (compilation-errors-exist-p)]
|
|
737 ))
|
|
738
|
|
739 (defvar Compilation-mode-menubar-menu
|
|
740 (cons "Compile" (cdr Compilation-mode-popup-menu)))
|
|
741
|
|
742 (defvar grep-mode-popup-menu
|
|
743 '("Grep Mode Commands"
|
|
744 :filter grep-menu-filter
|
|
745 ["Grep..." grep t]
|
|
746 ["Repeat Grep" recompile t]
|
|
747 ["Kill Grep" kill-compilation (get-buffer-process (current-buffer))]
|
|
748 "---"
|
|
749 ["Goto Match" compile-goto-error (default-value 'compilation-error-list)]
|
|
750 ["Next Match" next-error (default-value 'compilation-error-list)]
|
|
751 ["Previous Match" previous-error (default-value 'compilation-error-list)]
|
|
752 ["First Match" first-error (default-value 'compilation-error-list)]
|
|
753 ))
|
|
754
|
|
755 (defvar grep-mode-menubar-menu
|
|
756 (cons "Grep" (cdr grep-mode-popup-menu)))
|
|
757
|
|
758 (defun compile-menu-filter-1 (menu history-list item-name command-name)
|
|
759 (let ((submenu (mapcar #'(lambda (string)
|
|
760 (vector string
|
|
761 (list command-name string)
|
|
762 t))
|
|
763 history-list))
|
|
764 (existing (assoc item-name menu)))
|
|
765 (if existing
|
|
766 (progn
|
|
767 (setcdr existing submenu)
|
|
768 menu)
|
|
769 (nconc menu (list (cons item-name submenu))))))
|
|
770
|
|
771 (defun compile-menu-filter (menu)
|
|
772 (compile-menu-filter-1 menu compile-history "Compile History" 'compile))
|
|
773
|
|
774 (defun grep-menu-filter (menu)
|
|
775 (compile-menu-filter-1 menu grep-history "Grep History" 'grep))
|
|
776
|
|
777 (defun compilation-mode (&optional name-of-mode)
|
|
778 "Major mode for compilation log buffers.
|
|
779 \\<compilation-mode-map>To visit the source for a line-numbered error,
|
|
780 move point to the error message line and type \\[compile-goto-error],
|
|
781 or click on the line with \\[compile-mouse-goto-error].
|
|
782 There is a menu of commands on \\[compile-popup-menu].
|
|
783 To kill the compilation, type \\[kill-compilation].
|
|
784
|
|
785 Runs `compilation-mode-hook' with `run-hooks' (which see)."
|
|
786 (interactive)
|
|
787 (kill-all-local-variables)
|
|
788 (use-local-map compilation-mode-map)
|
|
789 (setq major-mode 'compilation-mode
|
|
790 mode-name "Compilation")
|
|
791 (compilation-setup)
|
|
792 (font-lock-set-defaults)
|
|
793 (if (not name-of-mode) nil
|
|
794 (let ((sym (intern (concat name-of-mode "-mode-popup-menu"))))
|
|
795 (if (boundp sym)
|
|
796 (setq mode-popup-menu (symbol-value sym))))
|
|
797 (if (featurep 'menubar)
|
|
798 (progn
|
|
799 ;; make a local copy of the menubar, so our modes don't
|
|
800 ;; change the global menubar
|
|
801 (set-buffer-menubar current-menubar)
|
|
802 (let ((sym (intern (concat name-of-mode "-mode-menubar-menu"))))
|
|
803 (if (boundp sym)
|
|
804 (add-submenu nil (symbol-value sym)))))))
|
|
805 (run-hooks 'compilation-mode-hook))
|
|
806
|
|
807 ;; XEmacs addition, hacked by Mly
|
|
808 (defun compilation-mode-motion-hook (event)
|
|
809 (mode-motion-highlight-internal
|
|
810 event
|
|
811 #'beginning-of-line
|
|
812 #'(lambda ()
|
|
813 (let* ((p (point))
|
|
814 (e (progn (end-of-line) (point)))
|
|
815 (l (progn
|
116
|
816 (if (and compilation-mouse-motion-initiate-parsing
|
|
817 (or (eq compilation-error-list 't)
|
|
818 (>= p compilation-parsing-end)))
|
0
|
819 ;; #### Does it suck too badly to have mouse-movement
|
|
820 ;; #### over a buffer parse errors in that buffer??
|
|
821 (save-window-excursion
|
|
822 (compile-reinitialize-errors nil p)))
|
|
823 (if (and compilation-error-list
|
|
824 (<= (car (car compilation-error-list)) p))
|
|
825 ;; Perhaps save time by only searching tail
|
|
826 compilation-error-list
|
|
827 compilation-old-error-list))))
|
|
828 (if (catch 'found
|
|
829 (while l
|
|
830 (let ((x (marker-position (car (car l)))))
|
|
831 (cond ((< x p)
|
|
832 (setq l (cdr l)))
|
|
833 ((<= x e)
|
|
834 (throw 'found t))
|
|
835 (t
|
|
836 (throw 'found nil)))))
|
|
837 nil)
|
|
838 (goto-char e)
|
|
839 (goto-char p))))))
|
|
840
|
|
841 ;; Prepare the buffer for the compilation parsing commands to work.
|
|
842 (defun compilation-setup ()
|
|
843 ;; Make the buffer's mode line show process state.
|
|
844 (setq mode-line-process '(":%s"))
|
|
845 (set (make-local-variable 'compilation-error-list) nil)
|
|
846 (set (make-local-variable 'compilation-old-error-list) nil)
|
|
847 (set (make-local-variable 'compilation-parsing-end) 1)
|
|
848 (set (make-local-variable 'compilation-directory-stack) nil)
|
|
849 (setq compilation-last-buffer (current-buffer))
|
|
850 ;; XEmacs change: highlight lines, install menubar.
|
|
851 (require 'mode-motion)
|
|
852 (setq mode-motion-hook 'compilation-mode-motion-hook)
|
|
853 (make-local-variable 'mouse-track-click-hook)
|
|
854 (add-hook 'mouse-track-click-hook 'compile-mouse-maybe-goto-error)
|
|
855 )
|
|
856
|
|
857 (defvar compilation-minor-mode nil
|
|
858 "Non-nil when in compilation-minor-mode.
|
|
859 In this minor mode, all the error-parsing commands of the
|
|
860 Compilation major mode are available.")
|
|
861 (make-variable-buffer-local 'compilation-minor-mode)
|
|
862
|
|
863 (or (assq 'compilation-minor-mode minor-mode-alist)
|
|
864 (setq minor-mode-alist (cons '(compilation-minor-mode " Compilation")
|
|
865 minor-mode-alist)))
|
|
866 (or (assq 'compilation-minor-mode minor-mode-map-alist)
|
|
867 (setq minor-mode-map-alist (cons (cons 'compilation-minor-mode
|
|
868 compilation-minor-mode-map)
|
|
869 minor-mode-map-alist)))
|
|
870
|
|
871 ;;;###autoload
|
|
872 (defun compilation-minor-mode (&optional arg)
|
|
873 "Toggle compilation minor mode.
|
|
874 With arg, turn compilation mode on if and only if arg is positive.
|
|
875 See `compilation-mode'.
|
|
876 ! \\{compilation-mode-map}"
|
|
877 (interactive "P")
|
|
878 (if (setq compilation-minor-mode (if (null arg)
|
|
879 (null compilation-minor-mode)
|
|
880 (> (prefix-numeric-value arg) 0)))
|
2
|
881 (progn
|
|
882 (compilation-setup)
|
|
883 (run-hooks 'compilation-minor-mode-hook))))
|
|
884
|
|
885 ;; Write msg in the current buffer and hack its mode-line-process.
|
|
886 (defun compilation-handle-exit (process-status exit-status msg)
|
|
887 (let ((buffer-read-only nil)
|
|
888 (status (if compilation-exit-message-function
|
|
889 (funcall compilation-exit-message-function
|
|
890 process-status exit-status msg)
|
|
891 (cons msg exit-status)))
|
|
892 (omax (point-max))
|
|
893 (opoint (point)))
|
|
894 ;; Record where we put the message, so we can ignore it
|
|
895 ;; later on.
|
|
896 (goto-char omax)
|
|
897 (insert ?\n mode-name " " (car status))
|
|
898 (forward-char -1)
|
|
899 (insert " at " (substring (current-time-string) 0 19))
|
|
900 (forward-char 1)
|
|
901 (setq mode-line-process (format ":%s [%s]" process-status (cdr status)))
|
|
902 ;; Force mode line redisplay soon.
|
|
903 (force-mode-line-update)
|
|
904 (if (and opoint (< opoint omax))
|
|
905 (goto-char opoint))
|
|
906 (if compilation-finish-function
|
|
907 (funcall compilation-finish-function (current-buffer) msg))))
|
0
|
908
|
|
909 ;; Called when compilation process changes state.
|
|
910 (defun compilation-sentinel (proc msg)
|
|
911 "Sentinel for compilation buffers."
|
2
|
912 ;; XEmacs change
|
0
|
913 (let* ((buffer (process-buffer proc))
|
|
914 (window (get-buffer-window buffer)))
|
|
915 (if (memq (process-status proc) '(signal exit))
|
|
916 (progn
|
|
917 (if (null (buffer-name buffer))
|
|
918 ;; buffer killed
|
|
919 (set-process-buffer proc nil)
|
|
920 (let ((obuf (current-buffer))
|
|
921 omax opoint estatus)
|
|
922 ;; save-excursion isn't the right thing if
|
|
923 ;; process-buffer is current-buffer
|
|
924 (unwind-protect
|
|
925 (progn
|
|
926 ;; Write something in the compilation buffer
|
|
927 ;; and hack its mode line.
|
|
928 (set-buffer buffer)
|
|
929 (let ((buffer-read-only nil)
|
|
930 (status (if compilation-exit-message-function
|
|
931 (funcall compilation-exit-message-function
|
|
932 proc msg)
|
|
933 (cons msg (process-exit-status proc)))))
|
|
934 (setq omax (point-max)
|
|
935 opoint (point))
|
|
936 (goto-char omax)
|
|
937 ;; Record where we put the message, so we can ignore it
|
|
938 ;; later on.
|
|
939 (insert ?\n mode-name " " (car status))
|
|
940 (forward-char -1)
|
|
941 (insert " at " (substring (current-time-string) 0 19))
|
|
942 (forward-char 1)
|
|
943 (setq mode-line-process
|
|
944 (concat ":"
|
|
945 (symbol-name (process-status proc))
|
|
946 (if (zerop (process-exit-status proc))
|
|
947 " OK"
|
|
948 (setq estatus
|
|
949 (format " [exit-status %d]"
|
|
950 (process-exit-status proc))))
|
|
951 ))
|
|
952 ;; XEmacs - tedium should let you know when it's ended...
|
|
953 (if (and (not compilation-always-signal-completion)
|
|
954 window
|
|
955 (pos-visible-in-window-p (point-max) window))
|
|
956 nil ; assume that the user will see it...
|
|
957 (ding t 'ready)
|
|
958 (message "Compilation process completed%s."
|
|
959 (or estatus " successfully")
|
|
960 ))
|
|
961 ;; Since the buffer and mode line will show that the
|
|
962 ;; process is dead, we can delete it now. Otherwise it
|
|
963 ;; will stay around until M-x list-processes.
|
|
964 (delete-process proc)
|
|
965 ;; Force mode line redisplay soon.
|
|
966 (redraw-modeline))
|
|
967 (if (and opoint (< opoint omax))
|
|
968 (goto-char opoint))
|
|
969 (if compilation-finish-function
|
|
970 (funcall compilation-finish-function buffer msg)))
|
|
971 (set-buffer obuf))))
|
|
972 (setq compilation-in-progress (delq proc compilation-in-progress))
|
|
973 ))))
|
|
974
|
|
975 (defun compilation-filter (proc string)
|
|
976 "Process filter for compilation buffers.
|
|
977 Just inserts the text, but uses `insert-before-markers'."
|
|
978 (if (buffer-name (process-buffer proc))
|
|
979 (save-excursion
|
|
980 (set-buffer (process-buffer proc))
|
|
981 (let ((buffer-read-only nil))
|
|
982 (save-excursion
|
|
983 (goto-char (process-mark proc))
|
|
984 (insert-before-markers string)
|
2
|
985 (run-hooks 'compilation-filter-hook)
|
0
|
986 (set-marker (process-mark proc) (point)))))))
|
|
987
|
|
988 ;; Return the cdr of compilation-old-error-list for the error containing point.
|
|
989 (defun compile-error-at-point ()
|
|
990 (compile-reinitialize-errors nil (point))
|
|
991 (let ((errors compilation-old-error-list))
|
|
992 (while (and errors
|
|
993 (> (point) (car (car errors))))
|
|
994 (setq errors (cdr errors)))
|
|
995 errors))
|
|
996
|
2
|
997 (defsubst compilation-buffer-p (buffer)
|
0
|
998 (save-excursion
|
|
999 (set-buffer buffer)
|
|
1000 (or compilation-minor-mode (eq major-mode 'compilation-mode))))
|
|
1001
|
|
1002 (defun compilation-next-error (n)
|
|
1003 "Move point to the next error in the compilation buffer.
|
|
1004 Does NOT find the source line like \\[next-error]."
|
|
1005 (interactive "p")
|
|
1006 (or (compilation-buffer-p (current-buffer))
|
|
1007 (error "Not in a compilation buffer."))
|
|
1008 (setq compilation-last-buffer (current-buffer))
|
|
1009
|
|
1010 (let ((errors (compile-error-at-point)))
|
|
1011
|
|
1012 ;; Move to the error after the one containing point.
|
|
1013 (goto-char (car (if (< n 0)
|
|
1014 (let ((i 0)
|
|
1015 (e compilation-old-error-list))
|
|
1016 ;; See how many cdrs away ERRORS is from the start.
|
|
1017 (while (not (eq e errors))
|
|
1018 (setq i (1+ i)
|
|
1019 e (cdr e)))
|
|
1020 (if (> (- n) i)
|
|
1021 (error "Moved back past first error")
|
|
1022 (nth (+ i n) compilation-old-error-list)))
|
|
1023 (let ((compilation-error-list (cdr errors)))
|
|
1024 (compile-reinitialize-errors nil nil n)
|
|
1025 (if compilation-error-list
|
|
1026 (nth (1- n) compilation-error-list)
|
|
1027 (error "Moved past last error"))))))))
|
|
1028
|
|
1029 (defun compilation-previous-error (n)
|
|
1030 "Move point to the previous error in the compilation buffer.
|
|
1031 Does NOT find the source line like \\[next-error]."
|
|
1032 (interactive "p")
|
|
1033 (compilation-next-error (- n)))
|
|
1034
|
|
1035
|
|
1036 ;; Given an elt of `compilation-error-list', return an object representing
|
|
1037 ;; the referenced file which is equal to (but not necessarily eq to) what
|
|
1038 ;; this function would return for another error in the same file.
|
|
1039 (defsubst compilation-error-filedata (data)
|
|
1040 (setq data (cdr data))
|
|
1041 (if (markerp data)
|
|
1042 (marker-buffer data)
|
|
1043 (car data)))
|
|
1044
|
|
1045 ;; Return a string describing a value from compilation-error-filedata.
|
|
1046 ;; This value is not necessarily useful as a file name, but should be
|
|
1047 ;; indicative to the user of what file's errors are being referred to.
|
|
1048 (defsubst compilation-error-filedata-file-name (filedata)
|
|
1049 (if (bufferp filedata)
|
|
1050 (buffer-file-name filedata)
|
|
1051 (car filedata)))
|
|
1052
|
|
1053 (defun compilation-next-file (n)
|
|
1054 "Move point to the next error for a different file than the current one."
|
|
1055 (interactive "p")
|
|
1056 (or (compilation-buffer-p (current-buffer))
|
|
1057 (error "Not in a compilation buffer."))
|
|
1058 (setq compilation-last-buffer (current-buffer))
|
|
1059
|
|
1060 (let ((reversed (< n 0))
|
|
1061 errors filedata)
|
|
1062
|
|
1063 (if (not reversed)
|
|
1064 (setq errors (or (compile-error-at-point)
|
|
1065 (error "Moved past last error")))
|
|
1066
|
|
1067 ;; Get a reversed list of the errors up through the one containing point.
|
|
1068 (compile-reinitialize-errors nil (point))
|
|
1069 (setq errors (reverse compilation-old-error-list)
|
|
1070 n (- n))
|
|
1071
|
|
1072 ;; Ignore errors after point. (car ERRORS) will be the error
|
|
1073 ;; containing point, (cadr ERRORS) the one before it.
|
|
1074 (while (and errors
|
|
1075 (< (point) (car (car errors))))
|
|
1076 (setq errors (cdr errors))))
|
|
1077
|
|
1078 (while (> n 0)
|
|
1079 (setq filedata (compilation-error-filedata (car errors)))
|
|
1080
|
|
1081 ;; Skip past the following errors for this file.
|
|
1082 (while (equal filedata
|
|
1083 (compilation-error-filedata
|
|
1084 (car (or errors
|
|
1085 (if reversed
|
|
1086 (error "%s the first erring file"
|
|
1087 (compilation-error-filedata-file-name
|
|
1088 filedata))
|
|
1089 (let ((compilation-error-list nil))
|
|
1090 ;; Parse some more.
|
|
1091 (compile-reinitialize-errors nil nil 2)
|
|
1092 (setq errors compilation-error-list)))
|
|
1093 (error "%s is the last erring file"
|
|
1094 (compilation-error-filedata-file-name
|
|
1095 filedata))))))
|
|
1096 (setq errors (cdr errors)))
|
|
1097
|
|
1098 (setq n (1- n)))
|
|
1099
|
|
1100 ;; Move to the following error.
|
|
1101 (goto-char (car (car (or errors
|
|
1102 (if reversed
|
|
1103 (error "This is the first erring file")
|
|
1104 (let ((compilation-error-list nil))
|
|
1105 ;; Parse the last one.
|
|
1106 (compile-reinitialize-errors nil nil 1)
|
|
1107 compilation-error-list))))))))
|
|
1108
|
|
1109 (defun compilation-previous-file (n)
|
|
1110 "Move point to the previous error for a different file than the current one."
|
|
1111 (interactive "p")
|
|
1112 (compilation-next-file (- n)))
|
|
1113
|
|
1114
|
|
1115 (defun kill-compilation ()
|
|
1116 "Kill the process made by the \\[compile] command."
|
|
1117 (interactive)
|
|
1118 (let ((buffer (compilation-find-buffer)))
|
|
1119 (if (get-buffer-process buffer)
|
|
1120 (interrupt-process (get-buffer-process buffer))
|
|
1121 (error "The compilation process is not running."))))
|
|
1122
|
|
1123
|
|
1124 ;; Parse any new errors in the compilation buffer,
|
|
1125 ;; or reparse from the beginning if the user has asked for that.
|
|
1126 (defun compile-reinitialize-errors (reparse
|
|
1127 &optional limit-search find-at-least)
|
|
1128 (save-excursion
|
|
1129 ;; XEmacs change: Below we made a change to possibly change the
|
|
1130 ;; selected window. If we don't save and restore the old window
|
|
1131 ;; then if we get an error such as 'no more errors' we'll end up
|
|
1132 ;; in the compilation buffer.
|
|
1133 (save-window-excursion
|
|
1134 (set-buffer compilation-last-buffer)
|
|
1135 ;; If we are out of errors, or if user says "reparse",
|
|
1136 ;; discard the info we have, to force reparsing.
|
|
1137 (if (or (eq compilation-error-list t)
|
|
1138 reparse)
|
|
1139 (compilation-forget-errors))
|
|
1140 (if (and compilation-error-list
|
|
1141 (or (not limit-search)
|
|
1142 (> compilation-parsing-end limit-search))
|
|
1143 (or (not find-at-least)
|
|
1144 (>= (length compilation-error-list) find-at-least)))
|
|
1145 ;; Since compilation-error-list is non-nil, it points to a specific
|
|
1146 ;; error the user wanted. So don't move it around.
|
|
1147 nil
|
|
1148
|
|
1149 ;; XEmacs change: if the compilation buffer is already visible
|
|
1150 ;; in a window, use that instead of thrashing the display.
|
|
1151 (let ((w (get-buffer-window compilation-last-buffer)))
|
|
1152 (if w
|
|
1153 (select-window w)
|
|
1154 (switch-to-buffer compilation-last-buffer)))
|
|
1155
|
2
|
1156 ;; This was here for a long time (before my rewrite); why? --roland
|
|
1157 ;;(switch-to-buffer compilation-last-buffer)
|
0
|
1158 (set-buffer-modified-p nil)
|
|
1159 (if (< compilation-parsing-end (point-max))
|
|
1160 ;; compilation-error-list might be non-nil if we have a non-nil
|
|
1161 ;; LIMIT-SEARCH or FIND-AT-LEAST arg. In that case its value
|
|
1162 ;; records the current position in the error list, and we must
|
|
1163 ;; preserve that after reparsing.
|
|
1164 (let ((error-list-pos compilation-error-list))
|
|
1165 (funcall compilation-parse-errors-function
|
|
1166 limit-search
|
|
1167 (and find-at-least
|
|
1168 ;; We only need enough new parsed errors to reach
|
|
1169 ;; FIND-AT-LEAST errors past the current
|
|
1170 ;; position.
|
|
1171 (- find-at-least (length compilation-error-list))))
|
|
1172 ;; Remember the entire list for compilation-forget-errors. If
|
|
1173 ;; this is an incremental parse, append to previous list. If
|
|
1174 ;; we are parsing anew, compilation-forget-errors cleared
|
|
1175 ;; compilation-old-error-list above.
|
|
1176 (setq compilation-old-error-list
|
|
1177 (nconc compilation-old-error-list compilation-error-list))
|
|
1178 (if error-list-pos
|
|
1179 ;; We started in the middle of an existing list of parsed
|
|
1180 ;; errors before parsing more; restore that position.
|
|
1181 (setq compilation-error-list error-list-pos))
|
|
1182 ))))))
|
|
1183
|
2
|
1184 ;; XEmacs addition
|
|
1185 ;; FSF has added this by 19.34, but it is highly complex, why? -sb
|
|
1186 (defun compile-mouse-goto-error (event)
|
|
1187 "Visit the source for the error under the mouse.
|
|
1188 Use this command in a compilation log buffer."
|
|
1189 (interactive "e")
|
|
1190 (mouse-set-point event)
|
|
1191 (beginning-of-line)
|
|
1192 (compile-goto-error))
|
|
1193
|
0
|
1194 (defun compile-goto-error (&optional argp)
|
|
1195 "Visit the source for the error message point is on.
|
|
1196 Use this command in a compilation log buffer. Sets the mark at point there.
|
|
1197 \\[universal-argument] as a prefix arg means to reparse the buffer's error messages first;
|
|
1198 other kinds of prefix arguments are ignored."
|
|
1199 (interactive "P")
|
|
1200 (or (compilation-buffer-p (current-buffer))
|
|
1201 (error "Not in a compilation buffer."))
|
|
1202 (setq compilation-last-buffer (current-buffer))
|
|
1203 (compile-reinitialize-errors (consp argp) (point))
|
|
1204
|
|
1205 ;; Move to bol; the marker for the error on this line will point there.
|
|
1206 (beginning-of-line)
|
|
1207
|
|
1208 ;; Move compilation-error-list to the elt of compilation-old-error-list
|
|
1209 ;; we want.
|
|
1210 (setq compilation-error-list compilation-old-error-list)
|
|
1211 (while (and compilation-error-list
|
|
1212 (> (point) (car (car compilation-error-list))))
|
|
1213 (setq compilation-error-list (cdr compilation-error-list)))
|
|
1214
|
|
1215 ;; Move to another window, so that next-error's window changes
|
|
1216 ;; result in the desired setup.
|
|
1217 (or (one-window-p)
|
|
1218 (progn
|
|
1219 (other-window -1)
|
|
1220 ;; other-window changed the selected buffer,
|
|
1221 ;; but we didn't want to do that.
|
|
1222 (set-buffer compilation-last-buffer)))
|
|
1223
|
|
1224 (push-mark)
|
|
1225 (next-error 1))
|
|
1226
|
|
1227 ;; XEmacs addition
|
|
1228 (defun compile-mouse-maybe-goto-error (event &optional click-count)
|
|
1229 (interactive "e")
|
|
1230 (if (equal (event-button event) 2)
|
|
1231 (let ((buffer (current-buffer))
|
|
1232 (point (point))
|
|
1233 (config (current-window-configuration)))
|
|
1234 (condition-case nil
|
|
1235 (progn
|
|
1236 (compile-mouse-goto-error event)
|
|
1237 t)
|
|
1238 (error
|
|
1239 (set-window-configuration config)
|
|
1240 (set-buffer buffer)
|
|
1241 (goto-char point)
|
|
1242 nil)))))
|
|
1243
|
|
1244 ;; Return a compilation buffer.
|
|
1245 ;; If the current buffer is a compilation buffer, return it.
|
|
1246 ;; If compilation-last-buffer is set to a live buffer, use that.
|
|
1247 ;; Otherwise, look for a compilation buffer and signal an error
|
|
1248 ;; if there are none.
|
|
1249 (defun compilation-find-buffer (&optional other-buffer)
|
|
1250 (if (and (not other-buffer)
|
|
1251 (compilation-buffer-p (current-buffer)))
|
|
1252 ;; The current buffer is a compilation buffer.
|
|
1253 (current-buffer)
|
|
1254 (if (and compilation-last-buffer (buffer-name compilation-last-buffer)
|
2
|
1255 (compilation-buffer-p compilation-last-buffer)
|
0
|
1256 (or (not other-buffer) (not (eq compilation-last-buffer
|
|
1257 (current-buffer)))))
|
|
1258 compilation-last-buffer
|
|
1259 (let ((buffers (buffer-list)))
|
|
1260 (while (and buffers (or (not (compilation-buffer-p (car buffers)))
|
|
1261 (and other-buffer
|
|
1262 (eq (car buffers) (current-buffer)))))
|
|
1263 (setq buffers (cdr buffers)))
|
|
1264 (if buffers
|
|
1265 (car buffers)
|
|
1266 (or (and other-buffer
|
|
1267 (compilation-buffer-p (current-buffer))
|
|
1268 ;; The current buffer is a compilation buffer.
|
|
1269 (progn
|
|
1270 (if other-buffer
|
|
1271 (message "This is the only compilation buffer."))
|
|
1272 (current-buffer)))
|
|
1273 (error "No compilation started!")))))))
|
|
1274
|
|
1275 ;;;###autoload
|
|
1276 (defun next-error (&optional argp)
|
|
1277 "Visit next compilation error message and corresponding source code.
|
|
1278 This operates on the output from the \\[compile] command.
|
|
1279 If all preparsed error messages have been processed,
|
|
1280 the error message buffer is checked for new ones.
|
|
1281
|
|
1282 A prefix arg specifies how many error messages to move;
|
|
1283 negative means move back to previous error messages.
|
|
1284 Just C-u as a prefix means reparse the error message buffer
|
|
1285 and start at the first error.
|
|
1286
|
|
1287 \\[next-error] normally applies to the most recent compilation started,
|
|
1288 but as long as you are in the middle of parsing errors from one compilation
|
|
1289 output buffer, you stay with that compilation output buffer.
|
|
1290
|
|
1291 Use \\[next-error] in a compilation output buffer to switch to
|
|
1292 processing errors from that compilation.
|
|
1293
|
|
1294 See variables `compilation-parse-errors-function' and
|
|
1295 \`compilation-error-regexp-alist' for customization ideas."
|
|
1296 (interactive "P")
|
|
1297 (setq compilation-last-buffer (compilation-find-buffer))
|
|
1298 (compilation-goto-locus (compilation-next-error-locus
|
|
1299 ;; We want to pass a number here only if
|
|
1300 ;; we got a numeric prefix arg, not just C-u.
|
|
1301 (and (not (consp argp))
|
|
1302 (prefix-numeric-value argp))
|
|
1303 (consp argp))))
|
2
|
1304 ;;;###autoload (define-key ctl-x-map "`" 'next-error)
|
0
|
1305
|
|
1306 ;; XEmacs change
|
|
1307 ;;;###autoload
|
|
1308 (defun previous-error (&optional argp)
|
|
1309 "Visit previous compilation error message and corresponding source code.
|
|
1310 This operates on the output from the \\[compile] command."
|
|
1311 (interactive "P")
|
|
1312 (next-error (cond ((null argp) -1)
|
|
1313 ((numberp argp) (- argp))
|
|
1314 (t argp))))
|
|
1315
|
|
1316 ;;;###autoload
|
|
1317 (defun first-error ()
|
|
1318 "Reparse the error message buffer and start at the first error
|
|
1319 Visit corresponding source code.
|
|
1320 This operates on the output from the \\[compile] command."
|
|
1321 (interactive)
|
|
1322 (next-error '(4)))
|
|
1323
|
|
1324 (defun compilation-next-error-locus (&optional move reparse silent)
|
|
1325 "Visit next compilation error and return locus in corresponding source code.
|
|
1326 This operates on the output from the \\[compile] command.
|
|
1327 If all preparsed error messages have been processed,
|
|
1328 the error message buffer is checked for new ones.
|
|
1329
|
|
1330 Returns a cons (ERROR . SOURCE) of two markers: ERROR is a marker at the
|
|
1331 location of the error message in the compilation buffer, and SOURCE is a
|
|
1332 marker at the location in the source code indicated by the error message.
|
|
1333
|
|
1334 Optional first arg MOVE says how many error messages to move forwards (or
|
|
1335 backwards, if negative); default is 1. Optional second arg REPARSE, if
|
|
1336 non-nil, says to reparse the error message buffer and reset to the first
|
|
1337 error (plus MOVE - 1). If optional third argument SILENT is non-nil, return
|
|
1338 nil instead of raising an error if there are no more errors.
|
|
1339
|
|
1340 The current buffer should be the desired compilation output buffer."
|
|
1341 (or move (setq move 1))
|
|
1342 (compile-reinitialize-errors reparse nil (and (not reparse)
|
|
1343 (if (< move 1) 0 (1- move))))
|
|
1344 (let (next-errors next-error)
|
|
1345 (catch 'no-next-error
|
|
1346 (save-excursion
|
|
1347 (set-buffer compilation-last-buffer)
|
|
1348 ;; compilation-error-list points to the "current" error.
|
|
1349 (setq next-errors
|
|
1350 (if (> move 0)
|
|
1351 (nthcdr (1- move)
|
|
1352 compilation-error-list)
|
|
1353 ;; Zero or negative arg; we need to move back in the list.
|
|
1354 (let ((n (1- move))
|
|
1355 (i 0)
|
|
1356 (e compilation-old-error-list))
|
|
1357 ;; See how many cdrs away the current error is from the start.
|
|
1358 (while (not (eq e compilation-error-list))
|
|
1359 (setq i (1+ i)
|
|
1360 e (cdr e)))
|
|
1361 (if (> (- n) i)
|
|
1362 (error "Moved back past first error")
|
|
1363 (nthcdr (+ i n) compilation-old-error-list))))
|
|
1364 next-error (car next-errors))
|
|
1365 (while
|
|
1366 (if (null next-error)
|
|
1367 (progn
|
|
1368 (and move (/= move 1)
|
|
1369 (error (if (> move 0)
|
|
1370 "Moved past last error"
|
|
1371 "Moved back past first error")))
|
|
1372 ;; Forget existing error messages if compilation has finished.
|
|
1373 ;;; XEmacs change by Barry Warsaw.
|
|
1374 ;;; Without this, if you get a "no more errors" error, then you can't do
|
|
1375 ;;; previous-error or goto-error until you kill the buffer.
|
|
1376 ; (if (not (and (get-buffer-process (current-buffer))
|
|
1377 ; (eq (process-status
|
|
1378 ; (get-buffer-process
|
|
1379 ; (current-buffer)))
|
|
1380 ; 'run)))
|
|
1381 ; (compilation-forget-errors))
|
|
1382 (if silent
|
|
1383 (throw 'no-next-error nil)
|
|
1384 (error (concat compilation-error-message
|
|
1385 (and (get-buffer-process (current-buffer))
|
2
|
1386 (eq (process-status
|
|
1387 (get-buffer-process
|
0
|
1388 (current-buffer)))
|
|
1389 'run)
|
|
1390 " yet")))))
|
|
1391 (setq compilation-error-list (cdr next-errors))
|
|
1392 (if (null (cdr next-error))
|
|
1393 ;; This error is boring. Go to the next.
|
|
1394 t
|
|
1395 (or (markerp (cdr next-error))
|
|
1396 ;; This error has a filename/lineno pair.
|
|
1397 ;; Find the file and turn it into a marker.
|
|
1398 (let* ((fileinfo (car (cdr next-error)))
|
|
1399 (cbuf (current-buffer)) ;XEmacs addition
|
|
1400 (buffer (apply 'compilation-find-file
|
|
1401 (car next-error) fileinfo)))
|
|
1402 (if (null buffer)
|
|
1403 ;; We can't find this error's file.
|
|
1404 ;; Remove all errors in the same file.
|
|
1405 (progn
|
|
1406 (setq next-errors compilation-old-error-list)
|
|
1407 (while next-errors
|
|
1408 (and (consp (cdr (car next-errors)))
|
|
1409 (equal (car (cdr (car next-errors)))
|
|
1410 fileinfo)
|
|
1411 (progn
|
|
1412 (set-marker (car (car next-errors)) nil)
|
|
1413 (setcdr (car next-errors) nil)))
|
|
1414 (setq next-errors (cdr next-errors)))
|
|
1415 ;; Look for the next error.
|
|
1416 t)
|
|
1417 ;; We found the file. Get a marker for this error.
|
|
1418 ;; compilation-old-error-list is a buffer-local
|
|
1419 ;; variable, so we must be careful to extract its value
|
|
1420 ;; before switching to the source file buffer.
|
|
1421 (let ((errors compilation-old-error-list)
|
|
1422 (last-line (nth 1 (cdr next-error)))
|
|
1423 (column (nth 2 (cdr next-error))))
|
|
1424 (set-buffer buffer)
|
|
1425 (save-excursion
|
|
1426 (save-restriction
|
|
1427 (widen)
|
|
1428 (goto-line last-line)
|
|
1429 (if (and column (> column 0))
|
|
1430 ;; Columns in error msgs are 1-origin.
|
|
1431 (move-to-column (1- column))
|
|
1432 (beginning-of-line))
|
|
1433 (setcdr next-error (point-marker))
|
|
1434 ;; Make all the other error messages referring
|
|
1435 ;; to the same file have markers into the buffer.
|
|
1436 (while errors
|
|
1437 (and (consp (cdr (car errors)))
|
|
1438 (equal (car (cdr (car errors))) fileinfo)
|
|
1439 (let* ((this (nth 1 (cdr (car errors))))
|
|
1440 (column (nth 2 (cdr (car errors))))
|
|
1441 (lines (- this last-line)))
|
|
1442 (if (eq selective-display t)
|
|
1443 ;; When selective-display is t,
|
|
1444 ;; each C-m is a line boundary,
|
|
1445 ;; as well as each newline.
|
|
1446 (if (< lines 0)
|
|
1447 (re-search-backward "[\n\C-m]"
|
|
1448 nil 'end
|
|
1449 (- lines))
|
|
1450 (re-search-forward "[\n\C-m]"
|
|
1451 nil 'end
|
|
1452 lines))
|
|
1453 (forward-line lines))
|
|
1454 (if (and column (> column 1))
|
|
1455 (move-to-column (1- column))
|
|
1456 (beginning-of-line))
|
|
1457 (setq last-line this)
|
|
1458 (setcdr (car errors) (point-marker))))
|
|
1459 (setq errors (cdr errors)))))
|
|
1460 ;; XEmacs addition
|
|
1461 (set-buffer cbuf)))))
|
|
1462 ;; If we didn't get a marker for this error, or this
|
|
1463 ;; marker's buffer was killed, go on to the next one.
|
|
1464 (or (not (markerp (cdr next-error)))
|
|
1465 (not (marker-buffer (cdr next-error))))))
|
|
1466 (setq next-errors compilation-error-list
|
|
1467 next-error (car next-errors)))
|
|
1468
|
|
1469 ;; XEmacs -- move this inside save-excursion
|
|
1470 ;; Skip over multiple error messages for the same source location,
|
|
1471 ;; so the next C-x ` won't go to an error in the same place.
|
|
1472 (while (and compilation-error-list
|
|
1473 (equal (cdr (car compilation-error-list))
|
|
1474 (cdr next-error)))
|
|
1475 (setq compilation-error-list (cdr compilation-error-list)))
|
|
1476 ))
|
|
1477
|
|
1478 ;; XEmacs change: If a new window has to be displayed, select the other
|
|
1479 ;; window to avoid swapping the position of the compilation error buffer.
|
|
1480 (and next-error (get-buffer-window (marker-buffer (car next-error)))
|
|
1481 (progn
|
|
1482 (select-window (get-buffer-window (marker-buffer (car next-error))))
|
|
1483 (other-window -1)))
|
|
1484
|
|
1485 ;; We now have a marker for the position of the error source code.
|
|
1486 ;; NEXT-ERROR is a cons (ERROR . SOURCE) of two markers.
|
|
1487 next-error))
|
|
1488
|
|
1489 (defun compilation-goto-locus (next-error)
|
|
1490 "Jump to an error locus returned by `compilation-next-error-locus'.
|
|
1491 Takes one argument, a cons (ERROR . SOURCE) of two markers.
|
|
1492 Selects a window with point at SOURCE, with another window displaying ERROR."
|
|
1493 ;; XEmacs: this code is horrendous, and makes windows do all sorts of
|
|
1494 ;; weird things when you're using separate frames for the compilation
|
|
1495 ;; and source buffer.
|
|
1496 ; (if (and (window-dedicated-p (selected-window))
|
|
1497 ; (eq (selected-window) (frame-root-window)))
|
|
1498 ; (switch-to-buffer-other-frame (marker-buffer (cdr next-error)))
|
|
1499 ; (switch-to-buffer (marker-buffer (cdr next-error))))
|
|
1500 ; (goto-char (cdr next-error))
|
|
1501 ; ;; If narrowing got in the way of
|
|
1502 ; ;; going to the right place, widen.
|
|
1503 ; (or (= (point) (marker-position (cdr next-error)))
|
|
1504 ; (progn
|
|
1505 ; (widen)
|
|
1506 ; (goto-char (cdr next-error))))
|
|
1507 ;
|
|
1508 ; ;; Show compilation buffer in other window, scrolled to this error.
|
|
1509 ; (let* ((pop-up-windows t)
|
|
1510 ; (w (or (get-buffer-window (marker-buffer (car next-error)) 'visible)
|
|
1511 ; (display-buffer (marker-buffer (car next-error))))))
|
|
1512 ; (set-window-point w (car next-error))
|
|
1513 ; (set-window-start w (car next-error))
|
|
1514 ; (compilation-set-window-height w)))
|
|
1515
|
|
1516 (let* ((pop-up-windows t)
|
|
1517 (compilation-buffer (marker-buffer (car next-error)))
|
|
1518 (source-buffer (marker-buffer (cdr next-error)))
|
|
1519 ;; make sure compilation buffer is visible ...
|
|
1520 (compilation-window
|
|
1521 ;; Use an existing window if it is in a visible frame.
|
|
1522 (or (get-buffer-window compilation-buffer 'visible)
|
|
1523 ;; Pop up a window.
|
|
1524 (display-buffer compilation-buffer))))
|
|
1525
|
|
1526 ;; now, make the compilation buffer **STAY WHERE IT IS** and
|
|
1527 ;; make sure the source buffer is visible
|
|
1528
|
|
1529 (select-window compilation-window)
|
|
1530 (pop-to-buffer source-buffer)
|
|
1531
|
|
1532 ;; now put things aright in the compilation window.
|
|
1533 (set-window-point compilation-window (car next-error))
|
|
1534 (set-window-start compilation-window (car next-error))
|
|
1535 (compilation-set-window-height compilation-window)
|
|
1536
|
|
1537 ;; now put things aright in the source window.
|
|
1538
|
|
1539 (set-buffer source-buffer)
|
|
1540 (goto-char (cdr next-error))
|
|
1541 ;; If narrowing got in the way of
|
|
1542 ;; going to the right place, widen.
|
|
1543 (or (= (point) (marker-position (cdr next-error)))
|
|
1544 (progn
|
|
1545 (widen)
|
|
1546 (goto-char (cdr next-error))))))
|
2
|
1547
|
0
|
1548
|
|
1549 ;; Find a buffer for file FILENAME.
|
|
1550 ;; Search the directories in compilation-search-path.
|
|
1551 ;; A nil in compilation-search-path means to try the
|
|
1552 ;; current directory, which is passed in DIR.
|
|
1553 ;; If FILENAME is not found at all, ask the user where to find it.
|
|
1554 ;; Pop up the buffer containing MARKER and scroll to MARKER if we ask the user.
|
|
1555 (defun compilation-find-file (marker filename dir &rest formats)
|
|
1556 (or formats (setq formats '("%s")))
|
|
1557 (let ((dirs compilation-search-path)
|
|
1558 buffer thisdir fmts name)
|
|
1559 (if (file-name-absolute-p filename)
|
|
1560 ;; The file name is absolute. Use its explicit directory as
|
|
1561 ;; the first in the search path, and strip it from FILENAME.
|
|
1562 (setq filename (abbreviate-file-name (expand-file-name filename))
|
|
1563 dirs (cons (file-name-directory filename) dirs)
|
|
1564 filename (file-name-nondirectory filename)))
|
|
1565 ;; Now search the path.
|
|
1566 (while (and dirs (null buffer))
|
|
1567 (setq thisdir (or (car dirs) dir)
|
|
1568 fmts formats)
|
|
1569 ;; For each directory, try each format string.
|
|
1570 (while (and fmts (null buffer))
|
|
1571 (setq name (expand-file-name (format (car fmts) filename) thisdir)
|
|
1572 buffer (and (file-exists-p name)
|
|
1573 (find-file-noselect name))
|
|
1574 fmts (cdr fmts)))
|
|
1575 (setq dirs (cdr dirs)))
|
|
1576 (or buffer
|
|
1577 ;; The file doesn't exist.
|
|
1578 ;; Ask the user where to find it.
|
|
1579 ;; If he hits C-g, then the next time he does
|
|
1580 ;; next-error, he'll skip past it.
|
|
1581 (let* ((pop-up-windows t)
|
|
1582 (w (display-buffer (marker-buffer marker))))
|
|
1583 (set-window-point w marker)
|
|
1584 (set-window-start w marker)
|
|
1585 (let ((name (expand-file-name
|
|
1586 (read-file-name
|
|
1587 (format "Find this error in: (default %s) "
|
|
1588 filename)
|
|
1589 dir filename t))))
|
|
1590 (if (file-directory-p name)
|
|
1591 (setq name (expand-file-name filename name)))
|
|
1592 (and (file-exists-p name)
|
|
1593 (find-file-noselect name)))))))
|
|
1594
|
|
1595 ;; Set compilation-error-list to nil, and unchain the markers that point to the
|
|
1596 ;; error messages and their text, so that they no longer slow down gap motion.
|
|
1597 ;; This would happen anyway at the next garbage collection, but it is better to
|
|
1598 ;; do it right away.
|
|
1599 (defun compilation-forget-errors ()
|
|
1600 (while compilation-old-error-list
|
|
1601 (let ((next-error (car compilation-old-error-list)))
|
|
1602 (set-marker (car next-error) nil)
|
|
1603 (if (markerp (cdr next-error))
|
|
1604 (set-marker (cdr next-error) nil)))
|
|
1605 (setq compilation-old-error-list (cdr compilation-old-error-list)))
|
|
1606 (setq compilation-error-list nil
|
|
1607 compilation-directory-stack nil
|
|
1608 compilation-parsing-end 1))
|
|
1609
|
|
1610
|
|
1611 (defun count-regexp-groupings (regexp)
|
|
1612 "Return the number of \\( ... \\) groupings in REGEXP (a string)."
|
|
1613 (let ((groupings 0)
|
|
1614 (len (length regexp))
|
|
1615 (i 0)
|
|
1616 c)
|
|
1617 (while (< i len)
|
|
1618 (setq c (aref regexp i)
|
|
1619 i (1+ i))
|
|
1620 (cond ((= c ?\[)
|
|
1621 ;; Find the end of this [...].
|
|
1622 (while (and (< i len)
|
|
1623 (not (= (aref regexp i) ?\])))
|
|
1624 (setq i (1+ i))))
|
|
1625 ((= c ?\\)
|
|
1626 (if (< i len)
|
|
1627 (progn
|
|
1628 (setq c (aref regexp i)
|
|
1629 i (1+ i))
|
|
1630 (if (= c ?\))
|
|
1631 ;; We found the end of a grouping,
|
|
1632 ;; so bump our counter.
|
|
1633 (setq groupings (1+ groupings))))))))
|
|
1634 groupings))
|
|
1635
|
|
1636 (defun compilation-parse-errors (limit-search find-at-least)
|
|
1637 "Parse the current buffer as grep, cc or lint error messages.
|
|
1638 See variable `compilation-parse-errors-function' for the interface it uses."
|
|
1639 (setq compilation-error-list nil)
|
|
1640 (message "Parsing error messages...")
|
|
1641 (let (;;text-buffer -- unused
|
|
1642 orig orig-expanded parent-expanded
|
|
1643 regexp enter-group leave-group error-group
|
|
1644 alist subexpr error-regexp-groups
|
|
1645 (found-desired nil)
|
116
|
1646 (compilation-num-errors-found 0)
|
|
1647 (message-freq (max 1 (/ (count-lines (point-min) (point-max)) 50))))
|
0
|
1648
|
|
1649 ;; Don't reparse messages already seen at last parse.
|
|
1650 (goto-char compilation-parsing-end)
|
|
1651 ;; Don't parse the first two lines as error messages.
|
|
1652 ;; This matters for grep.
|
|
1653 (if (bobp)
|
|
1654 (progn
|
|
1655 (forward-line 2)
|
|
1656 ;; Move back so point is before the newline.
|
|
1657 ;; This matters because some error regexps use \n instead of ^
|
|
1658 ;; to be faster.
|
|
1659 (forward-char -1)))
|
|
1660
|
|
1661 ;; Compile all the regexps we want to search for into one.
|
|
1662 (setq regexp (concat "\\(" compilation-enter-directory-regexp "\\)\\|"
|
|
1663 "\\(" compilation-leave-directory-regexp "\\)\\|"
|
|
1664 "\\(" (mapconcat (function
|
|
1665 (lambda (elt)
|
|
1666 (concat "\\(" (car elt) "\\)")))
|
|
1667 compilation-error-regexp-alist
|
|
1668 "\\|") "\\)"))
|
|
1669
|
|
1670 ;; Find out how many \(...\) groupings are in each of the regexps, and set
|
|
1671 ;; *-GROUP to the grouping containing each constituent regexp (whose
|
|
1672 ;; subgroups will come immediately thereafter) of the big regexp we have
|
|
1673 ;; just constructed.
|
|
1674 (setq enter-group 1
|
|
1675 leave-group (+ enter-group
|
|
1676 (count-regexp-groupings
|
|
1677 compilation-enter-directory-regexp)
|
|
1678 1)
|
|
1679 error-group (+ leave-group
|
|
1680 (count-regexp-groupings
|
|
1681 compilation-leave-directory-regexp)
|
|
1682 1))
|
|
1683
|
|
1684 ;; Compile an alist (IDX FILE LINE [COL]), where IDX is the number of
|
|
1685 ;; the subexpression for an entire error-regexp, and FILE and LINE (and
|
|
1686 ;; possibly COL) are the numbers for the subexpressions giving the file
|
|
1687 ;; name and line number (and possibly column number).
|
|
1688 (setq alist (or compilation-error-regexp-alist
|
|
1689 (error "compilation-error-regexp-alist is empty!"))
|
|
1690 subexpr (1+ error-group))
|
|
1691 (while alist
|
2
|
1692 (setq error-regexp-groups
|
|
1693 (cons (list subexpr
|
|
1694 (+ subexpr (nth 1 (car alist)))
|
|
1695 (+ subexpr (nth 2 (car alist)))
|
|
1696 ;;#### This is buggy in FSFmacs
|
|
1697 (let ((col (nth 3 (car alist))))
|
|
1698 (and col
|
|
1699 (+ subexpr col))))
|
|
1700 error-regexp-groups))
|
0
|
1701 (setq subexpr (+ subexpr 1 (count-regexp-groupings (car (car alist)))))
|
|
1702 (setq alist (cdr alist)))
|
|
1703
|
|
1704 ;; Set up now the expanded, abbreviated directory variables
|
|
1705 ;; that compile-abbreviate-directory will need, so we can
|
|
1706 ;; compute them just once here.
|
|
1707 (setq orig (abbreviate-file-name default-directory)
|
|
1708 orig-expanded (abbreviate-file-name
|
|
1709 (file-truename default-directory))
|
|
1710 parent-expanded (abbreviate-file-name
|
|
1711 (expand-file-name "../" orig-expanded)))
|
|
1712
|
|
1713 (while (and (not found-desired)
|
|
1714 ;; We don't just pass LIMIT-SEARCH to re-search-forward
|
|
1715 ;; because we want to find matches containing LIMIT-SEARCH
|
|
1716 ;; but which extend past it.
|
88
|
1717 ;; Instead of using re-search-forward,
|
|
1718 ;; we use this loop which tries only at each line.
|
|
1719 (progn
|
|
1720 (while (and (not (eobp))
|
|
1721 (not (looking-at regexp)))
|
|
1722 (forward-line 1))
|
|
1723 (not (eobp))))
|
|
1724
|
|
1725 ;; Move to the end of the match we just found.
|
|
1726 (goto-char (match-end 0))
|
0
|
1727
|
|
1728 ;; Figure out which constituent regexp matched.
|
|
1729 (cond ((match-beginning enter-group)
|
|
1730 ;; The match was the enter-directory regexp.
|
|
1731 (let ((dir
|
|
1732 (file-name-as-directory
|
|
1733 (expand-file-name
|
|
1734 (buffer-substring (match-beginning (+ enter-group 1))
|
|
1735 (match-end (+ enter-group 1)))))))
|
|
1736 ;; The directory name in the "entering" message
|
|
1737 ;; is a truename. Try to convert it to a form
|
|
1738 ;; like what the user typed in.
|
|
1739 (setq dir
|
|
1740 (compile-abbreviate-directory dir orig orig-expanded
|
|
1741 parent-expanded))
|
|
1742 (setq compilation-directory-stack
|
|
1743 (cons dir compilation-directory-stack))
|
|
1744 (and (file-directory-p dir)
|
|
1745 (setq default-directory dir)))
|
|
1746
|
|
1747 (and limit-search (>= (point) limit-search)
|
|
1748 ;; The user wanted a specific error, and we're past it.
|
|
1749 ;; We do this check here (and in the leave-group case)
|
|
1750 ;; rather than at the end of the loop because if the last
|
|
1751 ;; thing seen is an error message, we must carefully
|
|
1752 ;; discard the last error when it is the first in a new
|
|
1753 ;; file (see below in the error-group case).
|
|
1754 (setq found-desired t)))
|
|
1755
|
|
1756 ((match-beginning leave-group)
|
|
1757 ;; The match was the leave-directory regexp.
|
|
1758 (let ((beg (match-beginning (+ leave-group 1)))
|
|
1759 (stack compilation-directory-stack))
|
|
1760 (if beg
|
|
1761 (let ((dir
|
|
1762 (file-name-as-directory
|
|
1763 (expand-file-name
|
|
1764 (buffer-substring beg
|
|
1765 (match-end (+ leave-group
|
|
1766 1)))))))
|
|
1767 ;; The directory name in the "leaving" message
|
|
1768 ;; is a truename. Try to convert it to a form
|
|
1769 ;; like what the user typed in.
|
|
1770 (setq dir
|
|
1771 (compile-abbreviate-directory dir orig orig-expanded
|
|
1772 parent-expanded))
|
|
1773 (while (and stack
|
|
1774 (not (string-equal (car stack) dir)))
|
|
1775 (setq stack (cdr stack)))))
|
|
1776 (setq compilation-directory-stack (cdr stack))
|
|
1777 (setq stack (car compilation-directory-stack))
|
|
1778 (if stack
|
|
1779 (setq default-directory stack))
|
|
1780 )
|
|
1781
|
|
1782 (and limit-search (>= (point) limit-search)
|
|
1783 ;; The user wanted a specific error, and we're past it.
|
|
1784 ;; We do this check here (and in the enter-group case)
|
|
1785 ;; rather than at the end of the loop because if the last
|
|
1786 ;; thing seen is an error message, we must carefully
|
|
1787 ;; discard the last error when it is the first in a new
|
|
1788 ;; file (see below in the error-group case).
|
|
1789 (setq found-desired t)))
|
|
1790
|
|
1791 ((match-beginning error-group)
|
|
1792 ;; The match was the composite error regexp.
|
|
1793 ;; Find out which individual regexp matched.
|
|
1794 (setq alist error-regexp-groups)
|
|
1795 (while (and alist
|
|
1796 (null (match-beginning (car (car alist)))))
|
|
1797 (setq alist (cdr alist)))
|
|
1798 (if alist
|
|
1799 (setq alist (car alist))
|
|
1800 (error "compilation-parse-errors: impossible regexp match!"))
|
|
1801
|
|
1802 ;; Extract the file name and line number from the error message.
|
|
1803 (let ((beginning-of-match (match-beginning 0)) ;looking-at nukes
|
|
1804 (filename (buffer-substring (match-beginning (nth 1 alist))
|
|
1805 (match-end (nth 1 alist))))
|
|
1806 (linenum (string-to-int
|
|
1807 (buffer-substring
|
|
1808 (match-beginning (nth 2 alist))
|
|
1809 (match-end (nth 2 alist)))))
|
|
1810 (column (and (nth 3 alist)
|
|
1811 (match-beginning (nth 3 alist))
|
|
1812 (string-to-int
|
|
1813 (buffer-substring
|
|
1814 (match-beginning (nth 3 alist))
|
|
1815 (match-end (nth 3 alist)))))))
|
|
1816
|
|
1817 ;; Check for a comint-file-name-prefix and prepend it if
|
|
1818 ;; appropriate. (This is very useful for
|
|
1819 ;; compilation-minor-mode in an rlogin-mode buffer.)
|
|
1820 (and (boundp 'comint-file-name-prefix)
|
|
1821 ;; If the file name is relative, default-directory will
|
|
1822 ;; already contain the comint-file-name-prefix (done by
|
|
1823 ;; compile-abbreviate-directory).
|
|
1824 (file-name-absolute-p filename)
|
|
1825 (setq filename (concat comint-file-name-prefix filename)))
|
2
|
1826
|
|
1827 ;; Some compilers (e.g. Sun's java compiler, reportedly)
|
|
1828 ;; produce bogus file names like "./bar//foo.c" for the file
|
|
1829 ;; "bar/foo.c"; expand-file-name will collapse these into
|
|
1830 ;; "/foo.c" and fail to find the appropriate file. So we look
|
|
1831 ;; for doubled slashes in the file name and fix them up in the
|
|
1832 ;; buffer.
|
|
1833 (when (fboundp 'command-line-normalize-file-name)
|
|
1834 (setq filename (command-line-normalize-file-name filename)))
|
0
|
1835 (setq filename (cons filename (cons default-directory
|
|
1836 (nthcdr 4 alist))))
|
|
1837
|
|
1838
|
|
1839 ;; Locate the erring file and line.
|
|
1840 ;; Cons a new elt onto compilation-error-list,
|
|
1841 ;; giving a marker for the current compilation buffer
|
|
1842 ;; location, and the file and line number of the error.
|
|
1843 (save-excursion
|
|
1844 ;; Save as the start of the error the beginning of the
|
|
1845 ;; line containing the match unless the match starts at a
|
|
1846 ;; newline, in which case the beginning of the next line.
|
|
1847 (goto-char beginning-of-match)
|
|
1848 (forward-line (if (eolp) 1 0))
|
|
1849 (let ((this (cons (point-marker)
|
|
1850 (list filename linenum column))))
|
|
1851 ;; Don't add the same source line more than once.
|
|
1852 (if (equal (cdr this) (cdr (car compilation-error-list)))
|
|
1853 nil
|
|
1854 (setq compilation-error-list
|
|
1855 (cons this
|
|
1856 compilation-error-list))
|
|
1857 (setq compilation-num-errors-found
|
|
1858 (1+ compilation-num-errors-found)))))
|
|
1859 (and (or (and find-at-least (> compilation-num-errors-found
|
|
1860 find-at-least))
|
|
1861 (and limit-search (>= (point) limit-search)))
|
|
1862 ;; We have found as many new errors as the user wants,
|
|
1863 ;; or past the buffer position he indicated. We
|
|
1864 ;; continue to parse until we have seen all the
|
|
1865 ;; consecutive errors in the same file, so the error
|
|
1866 ;; positions will be recorded as markers in this buffer
|
|
1867 ;; that might change.
|
|
1868 (cdr compilation-error-list) ; Must check at least two.
|
|
1869 (not (equal (car (cdr (nth 0 compilation-error-list)))
|
|
1870 (car (cdr (nth 1 compilation-error-list)))))
|
|
1871 (progn
|
|
1872 ;; Discard the error just parsed, so that the next
|
|
1873 ;; parsing run can get it and the following errors in
|
|
1874 ;; the same file all at once. If we didn't do this, we
|
|
1875 ;; would have the same problem we are trying to avoid
|
|
1876 ;; with the test above, just delayed until the next run!
|
|
1877 (setq compilation-error-list
|
|
1878 (cdr compilation-error-list))
|
|
1879 (goto-char beginning-of-match)
|
|
1880 (setq found-desired t)))
|
|
1881 )
|
|
1882 )
|
|
1883 (t
|
|
1884 (error "compilation-parse-errors: known groups didn't match!")))
|
|
1885
|
116
|
1886 (when (= (% compilation-num-errors-found message-freq) 0)
|
|
1887 (message "Parsing error messages...%d (%.0f%% of buffer)"
|
|
1888 compilation-num-errors-found
|
|
1889 ;; Use floating-point because (* 100 (point)) frequently
|
|
1890 ;; exceeds the range of Emacs Lisp integers.
|
|
1891 (/ (* 100.0 (point)) (point-max))))
|
0
|
1892
|
116
|
1893 ;;; This is broken - it foils the logic above which is supposed to ensure
|
|
1894 ;;; that all errors for the current file are found before we quit.
|
|
1895 ; (and limit-search (>= (point) limit-search)
|
|
1896 ; ;; The user wanted a specific error, and we're past it.
|
|
1897 ; (setq found-desired t))
|
|
1898 )
|
0
|
1899 (setq compilation-parsing-end (if found-desired
|
|
1900 (point)
|
|
1901 ;; We have searched the whole buffer.
|
|
1902 (point-max))))
|
|
1903 (setq compilation-error-list (nreverse compilation-error-list))
|
|
1904 (message "Parsing error messages...done"))
|
|
1905
|
|
1906 ;; If directory DIR is a subdir of ORIG or of ORIG's parent,
|
|
1907 ;; return a relative name for it starting from ORIG or its parent.
|
|
1908 ;; ORIG-EXPANDED is an expanded version of ORIG.
|
|
1909 ;; PARENT-EXPANDED is an expanded version of ORIG's parent.
|
|
1910 ;; Those two args could be computed here, but we run faster by
|
|
1911 ;; having the caller compute them just once.
|
|
1912 (defun compile-abbreviate-directory (dir orig orig-expanded parent-expanded)
|
|
1913 ;; Apply canonical abbreviations to DIR first thing.
|
|
1914 ;; Those abbreviations are already done in the other arguments passed.
|
|
1915 (setq dir (abbreviate-file-name dir))
|
|
1916
|
|
1917 ;; Check for a comint-file-name-prefix and prepend it if appropriate.
|
|
1918 ;; (This is very useful for compilation-minor-mode in an rlogin-mode
|
|
1919 ;; buffer.)
|
|
1920 (if (boundp 'comint-file-name-prefix)
|
|
1921 (setq dir (concat comint-file-name-prefix dir)))
|
|
1922
|
|
1923 (if (and (> (length dir) (length orig-expanded))
|
|
1924 (string= orig-expanded
|
|
1925 (substring dir 0 (length orig-expanded))))
|
|
1926 (setq dir
|
|
1927 (concat orig
|
|
1928 (substring dir (length orig-expanded)))))
|
|
1929 (if (and (> (length dir) (length parent-expanded))
|
|
1930 (string= parent-expanded
|
|
1931 (substring dir 0 (length parent-expanded))))
|
|
1932 (setq dir
|
|
1933 (concat (file-name-directory
|
|
1934 (directory-file-name orig))
|
|
1935 (substring dir (length parent-expanded)))))
|
|
1936 dir)
|
|
1937
|
|
1938 (provide 'compile)
|
|
1939
|
|
1940 ;;; compile.el ends here
|