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