Mercurial > hg > xemacs-beta
comparison lisp/packages/compile.el @ 2:ac2d302a0011 r19-15b2
Import from CVS: tag r19-15b2
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:46:35 +0200 |
parents | 376386a54a3c |
children | b82b59fe008d |
comparison
equal
deleted
inserted
replaced
1:c0c6a60d29db | 2:ac2d302a0011 |
---|---|
1 ;;; compile.el --- run compiler as inferior of Emacs, parse error messages. | 1 ;;; compile.el --- run compiler as inferior of Emacs, parse error messages. |
2 | 2 |
3 ;; Copyright (C) 1985, 86, 87, 93, 94, 1995 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1985, 86, 87, 93, 94, 1995, 1996 Free Software Foundation, Inc. |
4 ;; Copyright (C) 1995 Tinker Systems and INS Engineering Corp. | 4 ;; Copyright (C) 1995 Tinker Systems and INS Engineering Corp. |
5 | 5 |
6 ;; Author: Roland McGrath <roland@prep.ai.mit.edu> | 6 ;; Author: Roland McGrath <roland@prep.ai.mit.edu> |
7 ;; Maintainer: FSF | 7 ;; Maintainer: FSF |
8 ;; Keywords: tools, processes | 8 ;; Keywords: tools, processes |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
20 ;; General Public License for more details. | 20 ;; General Public License for more details. |
21 | 21 |
22 ;; You should have received a copy of the GNU General Public License | 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 | 23 ;; along with XEmacs; see the file COPYING. If not, write to the Free |
24 ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | 24 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
25 | 25 ;; 02111-1307, USA. |
26 ;;; Synched up with: FSF 19.30. | 26 |
27 ;;; Synched up with: FSF 19.34, with a lot of divergence. | |
27 | 28 |
28 ;;; Commentary: | 29 ;;; Commentary: |
29 | 30 |
30 ;; This package provides the compile and grep facilities documented in | 31 ;; This package provides the compile and grep facilities documented in |
31 ;; the Emacs user's manual. | 32 ;; the Emacs user's manual. |
38 | 39 |
39 ;;;###autoload | 40 ;;;###autoload |
40 (defvar compilation-window-height nil | 41 (defvar compilation-window-height nil |
41 "*Number of lines in a compilation window. If nil, use Emacs default.") | 42 "*Number of lines in a compilation window. If nil, use Emacs default.") |
42 | 43 |
44 ;; XEmacs change | |
43 (defvar compilation-error-list 'invalid ; only valid buffer-local | 45 (defvar compilation-error-list 'invalid ; only valid buffer-local |
44 "List of error message descriptors for visiting erring functions. | 46 "List of error message descriptors for visiting erring functions. |
45 Each error descriptor is a cons (or nil). Its car is a marker pointing to | 47 Each error descriptor is a cons (or nil). Its car is a marker pointing to |
46 an error message. If its cdr is a marker, it points to the text of the | 48 an error message. If its cdr is a marker, it points to the text of the |
47 line the message is about. If its cdr is a cons, it is a list | 49 line the message is about. If its cdr is a cons, it is a list |
50 | 52 |
51 The value may be t instead of a list; this means that the buffer of | 53 The value may be t instead of a list; this means that the buffer of |
52 error messages should be reparsed the next time the list of errors is wanted. | 54 error messages should be reparsed the next time the list of errors is wanted. |
53 | 55 |
54 Some other commands (like `diff') use this list to control the error | 56 Some other commands (like `diff') use this list to control the error |
55 message tracking facilites; if you change its structure, you should make | 57 message tracking facilities; if you change its structure, you should make |
56 sure you also change those packages. Perhaps it is better not to change | 58 sure you also change those packages. Perhaps it is better not to change |
57 it at all.") | 59 it at all.") |
58 | 60 |
59 (defvar compilation-old-error-list nil | 61 (defvar compilation-old-error-list nil |
60 "Value of `compilation-error-list' after errors were parsed.") | 62 "Value of `compilation-error-list' after errors were parsed.") |
91 "List of compilation processes now running.") | 93 "List of compilation processes now running.") |
92 (or (assq 'compilation-in-progress minor-mode-alist) | 94 (or (assq 'compilation-in-progress minor-mode-alist) |
93 (setq minor-mode-alist (cons '(compilation-in-progress " Compiling") | 95 (setq minor-mode-alist (cons '(compilation-in-progress " Compiling") |
94 minor-mode-alist))) | 96 minor-mode-alist))) |
95 | 97 |
98 ;; XEmacs change | |
96 (defvar compilation-always-signal-completion nil | 99 (defvar compilation-always-signal-completion nil |
97 "Always give an audible signal upon compilation completion. | 100 "Always give an audible signal upon compilation completion. |
98 By default that signal is only given if the bottom of the compilation | 101 By default that signal is only given if the bottom of the compilation |
99 buffer is not visible in its window.") | 102 buffer is not visible in its window.") |
100 | 103 |
121 ;; | 124 ;; |
122 ;; We'll insist that the number be followed by a colon or closing | 125 ;; We'll insist that the number be followed by a colon or closing |
123 ;; paren, because otherwise this matches just about anything | 126 ;; paren, because otherwise this matches just about anything |
124 ;; containing a number with spaces around it. | 127 ;; containing a number with spaces around it. |
125 ("\n\ | 128 ("\n\ |
126 \\([^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\)\\([) \t]\\|\ | 129 \\([a-zA-Z]?:?[^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\)\\([) \t]\\|\ |
127 :\\([^0-9\n]\\|\\([0-9]+:\\)\\)\\)" 1 2 5) | 130 :\\([^0-9\n]\\|\\([0-9]+:\\)\\)\\)" 1 2 5) |
131 | |
132 ;; Microsoft C/C++: | |
133 ;; keyboard.c(537) : warning C4005: 'min' : macro redefinition | |
134 ;; d:\tmp\test.c(23) : error C2143: syntax error : missing ';' before 'if' | |
135 ("\n\\(\\([a-zA-Z]:\\)?[^:( \t\n-]+\\)[:(][ \t]*\\([0-9]+\\)[:) \t]" 1 3) | |
128 | 136 |
129 ;; Borland C++: | 137 ;; Borland C++: |
130 ;; Error ping.c 15: Unable to open include file 'sys/types.h' | 138 ;; Error ping.c 15: Unable to open include file 'sys/types.h' |
131 ;; Warning ping.c 68: Call to function 'func' with no prototype | 139 ;; Warning ping.c 68: Call to function 'func' with no prototype |
132 ("\n\\(Error\\|Warning\\) \\([^:( \t\n]+\\)\ | 140 ("\n\\(Error\\|Warning\\) \\([a-zA-Z]?:?[^:( \t\n]+\\)\ |
133 \\([0-9]+\\)\\([) \t]\\|:[^0-9\n]\\)" 2 3) | 141 \\([0-9]+\\)\\([) \t]\\|:[^0-9\n]\\)" 2 3) |
134 | 142 |
135 ;; 4.3BSD lint pass 2 | 143 ;; 4.3BSD lint pass 2 |
136 ;; strcmp: variable # of args. llib-lc(359) :: /usr/src/foo/foo.c(8) | 144 ;; strcmp: variable # of args. llib-lc(359) :: /usr/src/foo/foo.c(8) |
137 ("[ \t:]\\([^:( \t\n]+\\)[:(](+[ \t]*\\([0-9]+\\))[:) \t]*$" 1 2) | 145 ("[ \t:]\\([a-zA-Z]?:?[^:( \t\n]+\\)[:(](+[ \t]*\\([0-9]+\\))[:) \t]*$" |
146 1 2) | |
138 | 147 |
139 ;; 4.3BSD lint pass 3 | 148 ;; 4.3BSD lint pass 3 |
140 ;; bloofle defined( /users/wolfgang/foo.c(4) ), but never used | 149 ;; bloofle defined( /users/wolfgang/foo.c(4) ), but never used |
141 ;; This used to be | 150 ;; This used to be |
142 ;; ("[ \t(]+\\([^:( \t\n]+\\)[:( \t]+\\([0-9]+\\)[:) \t]+" 1 2) | 151 ;; ("[ \t(]+\\([a-zA-Z]?:?[^:( \t\n]+\\)[:( \t]+\\([0-9]+\\)[:) \t]+" 1 2) |
143 ;; which is regexp Impressionism - it matches almost anything! | 152 ;; which is regexp Impressionism - it matches almost anything! |
144 ("([ \t]*\\([^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\))" 1 2) | 153 ("([ \t]*\\([a-zA-Z]?:?[^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\))" 1 2) |
154 | |
155 ;; MIPS lint pass<n>; looks good for SunPro lint also | |
156 ;; TrimMask (255) in solomon.c may be indistinguishable from TrimMasks (93) in solomon.c due to truncation | |
157 ("[^ ]+ (\\([0-9]+\\)) in \\([^ ]+\\)" 2 1) | |
158 ;; name defined but never used: LinInt in cmap_calc.c(199) | |
159 ("in \\([^(]+\\)(\\([0-9]+\\))$" 1 2) | |
145 | 160 |
146 ;; Ultrix 3.0 f77: | 161 ;; Ultrix 3.0 f77: |
147 ;; fort: Severe: addstf.f, line 82: Missing operator or delimiter symbol | 162 ;; fort: Severe: addstf.f, line 82: Missing operator or delimiter symbol |
148 ;; Some SGI cc version: | 163 ;; Some SGI cc version: |
149 ;; cfe: Warning 835: foo.c, line 2: something | 164 ;; cfe: Warning 835: foo.c, line 2: something |
150 ("\n\\(cfe\\|fort\\): [^:\n]*: \\([^ \n]*\\), line \\([0-9]+\\):" 2 3) | 165 ("\n\\(cfe\\|fort\\): [^:\n]*: \\([^ \n]*\\), line \\([0-9]+\\):" 2 3) |
151 ;; Error on line 3 of t.f: Execution error unclassifiable statement | 166 ;; Error on line 3 of t.f: Execution error unclassifiable statement |
152 ;; Unknown who does this: | 167 ;; Unknown who does this: |
153 ;; Line 45 of "foo.c": bloofel undefined | 168 ;; Line 45 of "foo.c": bloofle undefined |
154 ;; Absoft FORTRAN 77 Compiler 3.1.3 | 169 ;; Absoft FORTRAN 77 Compiler 3.1.3 |
155 ;; error on line 19 of fplot.f: spelling error? | 170 ;; error on line 19 of fplot.f: spelling error? |
156 ;; warning on line 17 of fplot.f: data type is undefined for variable d | 171 ;; warning on line 17 of fplot.f: data type is undefined for variable d |
157 ("\\(\n\\|on \\)[Ll]ine[ \t]+\\([0-9]+\\)[ \t]+\ | 172 ("\\(\n\\|on \\)[Ll]ine[ \t]+\\([0-9]+\\)[ \t]+\ |
158 of[ \t]+\"?\\([^\":\n]+\\)\"?:" 3 2) | 173 of[ \t]+\"?\\([a-zA-Z]?:?[^\":\n]+\\)\"?:" 3 2) |
159 | 174 |
160 ;; Apollo cc, 4.3BSD fc: | 175 ;; Apollo cc, 4.3BSD fc: |
161 ;; "foo.f", line 3: Error: syntax error near end of statement | 176 ;; "foo.f", line 3: Error: syntax error near end of statement |
162 ;; IBM RS6000: | 177 ;; IBM RS6000: |
163 ;; "vvouch.c", line 19.5: 1506-046 (S) Syntax error. | 178 ;; "vvouch.c", line 19.5: 1506-046 (S) Syntax error. |
165 ;; File "foobar.ml", lines 5-8, characters 20-155: blah blah | 180 ;; File "foobar.ml", lines 5-8, characters 20-155: blah blah |
166 ;; Microtec mcc68k: | 181 ;; Microtec mcc68k: |
167 ;; "foo.c", line 32 pos 1; (E) syntax error; unexpected symbol: "lossage" | 182 ;; "foo.c", line 32 pos 1; (E) syntax error; unexpected symbol: "lossage" |
168 ;; GNAT (as of July 94): | 183 ;; GNAT (as of July 94): |
169 ;; "foo.adb", line 2(11): warning: file name does not match ... | 184 ;; "foo.adb", line 2(11): warning: file name does not match ... |
170 ("\"\\([^,\" \n\t]+\\)\", lines? \\([0-9]+\\)[:., (-]" 1 2) | 185 ;; IBM AIX xlc compiler: |
186 ;; "src/swapping.c", line 30.34: 1506-342 (W) "/*" detected in comment. | |
187 ("\"\\([^,\" \n\t]+\\)\", lines? \ | |
188 \\([0-9]+\\)\\([\(.]\\([0-9]+\\)\)?\\)?[:., (-]" 1 2 4) | |
171 | 189 |
172 ;; MIPS RISC CC - the one distributed with Ultrix: | 190 ;; MIPS RISC CC - the one distributed with Ultrix: |
173 ;; ccom: Error: foo.c, line 2: syntax error | 191 ;; ccom: Error: foo.c, line 2: syntax error |
174 ;; DEC AXP OSF/1 cc | 192 ;; DEC AXP OSF/1 cc |
175 ;; /usr/lib/cmplrs/cc/cfe: Error: foo.c: 1: blah blah | 193 ;; /usr/lib/cmplrs/cc/cfe: Error: foo.c: 1: blah blah |
184 ;; Lucid Compiler, lcc 3.x | 202 ;; Lucid Compiler, lcc 3.x |
185 ;; E, file.cc(35,52) Illegal operation on pointers | 203 ;; E, file.cc(35,52) Illegal operation on pointers |
186 ("\n[EW], \\([^(\n]*\\)(\\([0-9]+\\),[ \t]*\\([0-9]+\\)" 1 2 3) | 204 ("\n[EW], \\([^(\n]*\\)(\\([0-9]+\\),[ \t]*\\([0-9]+\\)" 1 2 3) |
187 | 205 |
188 ;; GNU messages with program name and optional column number. | 206 ;; GNU messages with program name and optional column number. |
189 ("\n[^0-9 \n\t:]+:[ \t]*\\([^ \n\t:]+\\):\ | 207 ("\n[a-zA-Z]?:?[^0-9 \n\t:]+:[ \t]*\\([^ \n\t:]+\\):\ |
190 \\([0-9]+\\):\\(\\([0-9]+\\)[: \t]\\)?" 1 2 4) | 208 \\([0-9]+\\):\\(\\([0-9]+\\)[: \t]\\)?" 1 2 4) |
191 | 209 |
192 ;; jwz: | 210 ;; jwz: |
193 ;; IRIX 5.2 | 211 ;; IRIX 5.2 |
194 ;; cfe: Warning 712: foo.c, line 2: illegal combination of pointer and ... | 212 ;; cfe: Warning 712: foo.c, line 2: illegal combination of pointer and ... |
226 (defvar compilation-ask-about-save t | 244 (defvar compilation-ask-about-save t |
227 "If not nil, M-x compile asks which buffers to save before compiling. | 245 "If not nil, M-x compile asks which buffers to save before compiling. |
228 Otherwise, it saves all modified buffers without asking.") | 246 Otherwise, it saves all modified buffers without asking.") |
229 | 247 |
230 (defvar grep-regexp-alist | 248 (defvar grep-regexp-alist |
231 '(("^\\([^:( \t\n]+\\)[:( \t]+\\([0-9]+\\)[:) \t]" 1 2)) | 249 '(("^\\([a-zA-Z]?:?[^:( \t\n]+\\)[:( \t]+\\([0-9]+\\)[:) \t]" 1 2)) |
232 "Regexp used to match grep hits. See `compilation-error-regexp-alist'.") | 250 "Regexp used to match grep hits. See `compilation-error-regexp-alist'.") |
233 | 251 |
234 (defvar grep-command "grep -n " | 252 (defvar grep-command "grep -n " |
235 "Last grep command used in \\[grep]; default for next grep.") | 253 "Last grep command used in \\[grep]; default for next grep.") |
236 | 254 |
273 "Stack of previous directories for `compilation-leave-directory-regexp'. | 291 "Stack of previous directories for `compilation-leave-directory-regexp'. |
274 The head element is the directory the compilation was started in.") | 292 The head element is the directory the compilation was started in.") |
275 | 293 |
276 (defvar compilation-exit-message-function nil "\ | 294 (defvar compilation-exit-message-function nil "\ |
277 If non-nil, called when a compilation process dies to return a status message. | 295 If non-nil, called when a compilation process dies to return a status message. |
278 This should be a function a two arguments as passed to a process sentinel | 296 This should be a function of three arguments: process status, exit status, |
279 \(see `set-process-sentinel\); it returns a cons (MESSAGE . MODELINE) of the | 297 and exit message; it returns a cons (MESSAGE . MODELINE) of the strings to |
280 strings to write into the compilation buffer, and to put in its mode line.") | 298 write into the compilation buffer, and to put in its mode line.") |
281 | 299 |
282 ;; History of compile commands. | 300 ;; History of compile commands. |
283 (defvar compile-history nil) | 301 (defvar compile-history nil) |
284 ;; History of grep commands. | 302 ;; History of grep commands. |
285 (defvar grep-history nil) | 303 (defvar grep-history nil) |
286 | 304 |
305 ;; XEmacs | |
287 (defconst compilation-font-lock-keywords (purecopy | 306 (defconst compilation-font-lock-keywords (purecopy |
288 (list | 307 (list |
289 '("^[-_.\"A-Za-z0-9/+]+\\(:\\|, line \\)[0-9]+: \\([wW]arning:\\).*$" . | 308 '("^[-_.\"A-Za-z0-9/+]+\\(:\\|, line \\)[0-9]+: \\([wW]arning:\\).*$" . |
290 font-lock-keyword-face) | 309 font-lock-keyword-face) |
291 '("^[-_.\"A-Za-z0-9/+]+\\(: *\\|, line \\)[0-9]+:.*$" . font-lock-function-name-face) | 310 '("^[-_.\"A-Za-z0-9/+]+\\(: *\\|, line \\)[0-9]+:.*$" . font-lock-function-name-face) |
294 '("^[-_.\"A-Za-z0-9/+]+\\(: *[0-9]+\\|, line [0-9]+\\)" 1 bold t) | 313 '("^[-_.\"A-Za-z0-9/+]+\\(: *[0-9]+\\|, line [0-9]+\\)" 1 bold t) |
295 )) | 314 )) |
296 "Additional expressions to highlight in Compilation mode.") | 315 "Additional expressions to highlight in Compilation mode.") |
297 | 316 |
298 ;FSF's version. Ours looks better. | 317 ;FSF's version. Ours looks better. |
299 ;(defvar compilation-font-lock-keywords | 318 ;(defvar compilation-mode-font-lock-keywords |
300 ; ;; This regexp needs a bit of rewriting. What is the third grouping for? | 319 ; ;; This regexp needs a bit of rewriting. What is the third grouping for? |
301 ; '(("^\\([^ \n:]*:\\([0-9]+:\\)+\\)\\(.*\\)$" 1 font-lock-function-name-face)) | 320 ; '(("^\\([a-zA-Z]?:?[^ \n:]*:\\([0-9]+:\\)+\\)\\(.*\\)$" |
302 ;;;; ("^\\([^\n:]*:\\([0-9]+:\\)+\\)\\(.*\\)$" 0 font-lock-keyword-face keep) | 321 ; 1 font-lock-function-name-face)) |
303 ; "Additional expressions to highlight in Compilation mode.") | 322 ;;; ("^\\([^\n:]*:\\([0-9]+:\\)+\\)\\(.*\\)$" 0 font-lock-keyword-face keep) |
323 | |
324 ;; XEmacs change | |
304 (put 'compilation-mode 'font-lock-defaults | 325 (put 'compilation-mode 'font-lock-defaults |
305 '(compilation-font-lock-keywords t)) | 326 '(compilation-font-lock-keywords t)) |
306 | 327 |
307 | 328 |
308 ;;;###autoload | 329 ;;;###autoload |
324 The name used for the buffer is actually whatever is returned by | 345 The name used for the buffer is actually whatever is returned by |
325 the function in `compilation-buffer-name-function', so you can set that | 346 the function in `compilation-buffer-name-function', so you can set that |
326 to a function that generates a unique name." | 347 to a function that generates a unique name." |
327 (interactive | 348 (interactive |
328 (if (or compilation-read-command current-prefix-arg) | 349 (if (or compilation-read-command current-prefix-arg) |
350 ;; XEmacs change | |
329 (list (read-shell-command "Compile command: " | 351 (list (read-shell-command "Compile command: " |
330 compile-command | 352 compile-command |
331 ;; #### minibuffer code should do this | 353 ;; #### minibuffer code should do this |
332 (if (equal (car compile-history) | 354 (if (equal (car compile-history) |
333 compile-command) | 355 compile-command) |
355 to find the text that grep hits refer to. | 377 to find the text that grep hits refer to. |
356 | 378 |
357 This command uses a special history list for its arguments, so you can | 379 This command uses a special history list for its arguments, so you can |
358 easily repeat a grep command." | 380 easily repeat a grep command." |
359 (interactive | 381 (interactive |
382 ;; XEmacs change | |
360 (list (read-shell-command "Run grep (like this): " | 383 (list (read-shell-command "Run grep (like this): " |
361 grep-command 'grep-history))) | 384 grep-command 'grep-history))) |
362 (let ((buf (compile-internal (concat command-args " " grep-null-device) | 385 (let ((buf (compile-internal (concat command-args " " grep-null-device) |
363 "No more grep hits" "grep" | 386 "No more grep hits" "grep" |
364 ;; Give it a simpler regexp to match. | 387 ;; Give it a simpler regexp to match. |
365 nil grep-regexp-alist))) | 388 nil grep-regexp-alist))) |
366 (save-excursion | 389 (save-excursion |
367 (set-buffer buf) | 390 (set-buffer buf) |
368 (set (make-local-variable 'compilation-exit-message-function) | 391 (set (make-local-variable 'compilation-exit-message-function) |
392 ;; XEmacs change | |
369 (lambda (proc msg) | 393 (lambda (proc msg) |
370 (let ((code (process-exit-status proc))) | 394 (let ((code (process-exit-status proc))) |
371 (if (eq (process-status proc) 'exit) | 395 (if (eq (process-status proc) 'exit) |
372 (cond ((zerop code) | 396 (cond ((zerop code) |
373 '("finished (matches found)\n" . "matched")) | 397 '("finished (matches found)\n" . "matched")) |
423 ;; values of compilation-error-regexp-alist, etc. | 447 ;; values of compilation-error-regexp-alist, etc. |
424 (kill-all-local-variables)) | 448 (kill-all-local-variables)) |
425 (let ((regexp-alist (or regexp-alist compilation-error-regexp-alist)) | 449 (let ((regexp-alist (or regexp-alist compilation-error-regexp-alist)) |
426 (parser (or parser compilation-parse-errors-function)) | 450 (parser (or parser compilation-parse-errors-function)) |
427 (thisdir default-directory) | 451 (thisdir default-directory) |
452 ;; XEmacs change | |
428 (buffer-save (current-buffer)) | 453 (buffer-save (current-buffer)) |
429 outwin) | 454 outwin) |
430 | 455 |
456 ;; XEmacs change | |
431 ;; Pop up the compilation buffer. | 457 ;; Pop up the compilation buffer. |
432 (setq outwin (display-buffer outbuf)) | 458 (setq outwin (display-buffer outbuf)) |
433 | 459 |
434 (unwind-protect | 460 (unwind-protect |
435 (progn | 461 (progn |
436 ;; Clear out the compilation buffer and make it writable. | 462 ;; Clear out the compilation buffer and make it writable. |
437 ;; Change its default-directory to the directory where the compilation | 463 ;; Change its default-directory to the directory where the compilation |
438 ;; will happen, and insert a `cd' command to indicate this. | 464 ;; will happen, and insert a `cd' command to indicate this. |
439 (set-buffer outbuf) | 465 (set-buffer outbuf) |
440 | 466 |
441 (setq buffer-read-only nil) | 467 (setq buffer-read-only nil) |
442 (buffer-disable-undo (current-buffer)) | 468 (buffer-disable-undo (current-buffer)) |
443 (erase-buffer) | 469 (erase-buffer) |
444 (buffer-enable-undo (current-buffer)) | 470 (buffer-enable-undo (current-buffer)) |
445 (setq default-directory thisdir) | 471 (setq default-directory thisdir) |
446 (insert "cd " thisdir "\n" command "\n") | 472 (insert "cd " thisdir "\n" command "\n") |
447 (set-buffer-modified-p nil) | 473 (set-buffer-modified-p nil) |
448 | 474 |
475 ;; XEmacs change | |
449 ;; set it so the window will scroll to show compile output | 476 ;; set it so the window will scroll to show compile output |
450 (save-window-excursion | 477 (save-window-excursion |
451 (select-window outwin) | 478 (select-window outwin) |
452 (goto-char (point-max))) | 479 (goto-char (point-max))) |
453 | 480 |
481 ;; XEmacs change | |
454 (compilation-mode name-of-mode) | 482 (compilation-mode name-of-mode) |
455 ;; (setq buffer-read-only t) ;;; Non-ergonomic. | 483 ;; (setq buffer-read-only t) ;;; Non-ergonomic. |
484 ;; XEmacs change | |
456 (set (make-local-variable 'compile-command) command) | 485 (set (make-local-variable 'compile-command) command) |
457 (set (make-local-variable 'compilation-parse-errors-function) parser) | 486 (set (make-local-variable 'compilation-parse-errors-function) parser) |
458 (set (make-local-variable 'compilation-error-message) error-message) | 487 (set (make-local-variable 'compilation-error-message) error-message) |
459 (set (make-local-variable 'compilation-error-regexp-alist) regexp-alist) | 488 (set (make-local-variable 'compilation-error-regexp-alist) regexp-alist) |
460 (setq default-directory thisdir | 489 (setq default-directory thisdir |
461 compilation-directory-stack (list default-directory)) | 490 compilation-directory-stack (list default-directory)) |
462 (set-window-start outwin (point-min)) | 491 (set-window-start outwin (point-min)) |
463 (setq mode-name name-of-mode) | 492 (setq mode-name name-of-mode) |
493 ;; XEmacs change | |
464 ; (or (eq outwin (selected-window)) | 494 ; (or (eq outwin (selected-window)) |
465 ; (set-window-point outwin (point-min))) | 495 ; (set-window-point outwin (point-min))) |
466 (compilation-set-window-height outwin) | 496 (compilation-set-window-height outwin) |
467 | |
468 ;; Set up the menus | |
469 | |
470 ;; Start the compilation. | 497 ;; Start the compilation. |
471 (if (fboundp 'start-process) | 498 (if (fboundp 'start-process) |
472 (let* ((process-environment (cons "EMACS=t" process-environment)) | 499 (let* ((process-environment (cons "EMACS=t" process-environment)) |
473 (proc (start-process-shell-command (downcase mode-name) | 500 (proc (start-process-shell-command (downcase mode-name) |
474 outbuf | 501 outbuf |
476 (set-process-sentinel proc 'compilation-sentinel) | 503 (set-process-sentinel proc 'compilation-sentinel) |
477 (set-process-filter proc 'compilation-filter) | 504 (set-process-filter proc 'compilation-filter) |
478 (set-marker (process-mark proc) (point) outbuf) | 505 (set-marker (process-mark proc) (point) outbuf) |
479 (setq compilation-in-progress | 506 (setq compilation-in-progress |
480 (cons proc compilation-in-progress))) | 507 (cons proc compilation-in-progress))) |
481 ;; No asynchronous processes available | 508 ;; No asynchronous processes available. |
482 (message (format "Executing `%s'..." command)) | 509 (message "Executing `%s'..." command) |
483 (sit-for 0) ;; Force redisplay | 510 ; FSF |
511 ; (setq mode-line-process ":run") | |
512 ; (force-mode-line-update) | |
513 (sit-for 0) ;; Force redisplay | |
484 (let ((status (call-process shell-file-name nil outbuf nil "-c" | 514 (let ((status (call-process shell-file-name nil outbuf nil "-c" |
485 command)))) | 515 command)))) |
486 (message (format "Executing `%s'...done" command)))) | 516 (message "Executing `%s'...done" command))) |
487 (set-buffer buffer-save))) | 517 (set-buffer buffer-save))) |
488 | 518 |
489 ;; Make it so the next C-x ` will use this buffer. | 519 ;; Make it so the next C-x ` will use this buffer. |
490 (setq compilation-last-buffer outbuf))) | 520 (setq compilation-last-buffer outbuf))) |
491 | 521 |
702 ! \\{compilation-mode-map}" | 732 ! \\{compilation-mode-map}" |
703 (interactive "P") | 733 (interactive "P") |
704 (if (setq compilation-minor-mode (if (null arg) | 734 (if (setq compilation-minor-mode (if (null arg) |
705 (null compilation-minor-mode) | 735 (null compilation-minor-mode) |
706 (> (prefix-numeric-value arg) 0))) | 736 (> (prefix-numeric-value arg) 0))) |
707 (compilation-setup))) | 737 (progn |
738 (compilation-setup) | |
739 (run-hooks 'compilation-minor-mode-hook)))) | |
740 | |
741 ;; Write msg in the current buffer and hack its mode-line-process. | |
742 (defun compilation-handle-exit (process-status exit-status msg) | |
743 (let ((buffer-read-only nil) | |
744 (status (if compilation-exit-message-function | |
745 (funcall compilation-exit-message-function | |
746 process-status exit-status msg) | |
747 (cons msg exit-status))) | |
748 (omax (point-max)) | |
749 (opoint (point))) | |
750 ;; Record where we put the message, so we can ignore it | |
751 ;; later on. | |
752 (goto-char omax) | |
753 (insert ?\n mode-name " " (car status)) | |
754 (forward-char -1) | |
755 (insert " at " (substring (current-time-string) 0 19)) | |
756 (forward-char 1) | |
757 (setq mode-line-process (format ":%s [%s]" process-status (cdr status))) | |
758 ;; Force mode line redisplay soon. | |
759 (force-mode-line-update) | |
760 (if (and opoint (< opoint omax)) | |
761 (goto-char opoint)) | |
762 (if compilation-finish-function | |
763 (funcall compilation-finish-function (current-buffer) msg)))) | |
708 | 764 |
709 ;; Called when compilation process changes state. | 765 ;; Called when compilation process changes state. |
710 (defun compilation-sentinel (proc msg) | 766 (defun compilation-sentinel (proc msg) |
711 "Sentinel for compilation buffers." | 767 "Sentinel for compilation buffers." |
768 ;; XEmacs change | |
712 (let* ((buffer (process-buffer proc)) | 769 (let* ((buffer (process-buffer proc)) |
713 (window (get-buffer-window buffer))) | 770 (window (get-buffer-window buffer))) |
714 (if (memq (process-status proc) '(signal exit)) | 771 (if (memq (process-status proc) '(signal exit)) |
715 (progn | 772 (progn |
716 (if (null (buffer-name buffer)) | 773 (if (null (buffer-name buffer)) |
779 (set-buffer (process-buffer proc)) | 836 (set-buffer (process-buffer proc)) |
780 (let ((buffer-read-only nil)) | 837 (let ((buffer-read-only nil)) |
781 (save-excursion | 838 (save-excursion |
782 (goto-char (process-mark proc)) | 839 (goto-char (process-mark proc)) |
783 (insert-before-markers string) | 840 (insert-before-markers string) |
841 (run-hooks 'compilation-filter-hook) | |
784 (set-marker (process-mark proc) (point))))))) | 842 (set-marker (process-mark proc) (point))))))) |
785 | 843 |
786 ;; Return the cdr of compilation-old-error-list for the error containing point. | 844 ;; Return the cdr of compilation-old-error-list for the error containing point. |
787 (defun compile-error-at-point () | 845 (defun compile-error-at-point () |
788 (compile-reinitialize-errors nil (point)) | 846 (compile-reinitialize-errors nil (point)) |
790 (while (and errors | 848 (while (and errors |
791 (> (point) (car (car errors)))) | 849 (> (point) (car (car errors)))) |
792 (setq errors (cdr errors))) | 850 (setq errors (cdr errors))) |
793 errors)) | 851 errors)) |
794 | 852 |
795 (defun compilation-buffer-p (buffer) | 853 (defsubst compilation-buffer-p (buffer) |
796 (save-excursion | 854 (save-excursion |
797 (set-buffer buffer) | 855 (set-buffer buffer) |
798 (or compilation-minor-mode (eq major-mode 'compilation-mode)))) | 856 (or compilation-minor-mode (eq major-mode 'compilation-mode)))) |
799 | 857 |
800 (defun compilation-next-error (n) | 858 (defun compilation-next-error (n) |
949 (let ((w (get-buffer-window compilation-last-buffer))) | 1007 (let ((w (get-buffer-window compilation-last-buffer))) |
950 (if w | 1008 (if w |
951 (select-window w) | 1009 (select-window w) |
952 (switch-to-buffer compilation-last-buffer))) | 1010 (switch-to-buffer compilation-last-buffer))) |
953 | 1011 |
1012 ;; This was here for a long time (before my rewrite); why? --roland | |
1013 ;;(switch-to-buffer compilation-last-buffer) | |
954 (set-buffer-modified-p nil) | 1014 (set-buffer-modified-p nil) |
955 (if (< compilation-parsing-end (point-max)) | 1015 (if (< compilation-parsing-end (point-max)) |
956 ;; compilation-error-list might be non-nil if we have a non-nil | 1016 ;; compilation-error-list might be non-nil if we have a non-nil |
957 ;; LIMIT-SEARCH or FIND-AT-LEAST arg. In that case its value | 1017 ;; LIMIT-SEARCH or FIND-AT-LEAST arg. In that case its value |
958 ;; records the current position in the error list, and we must | 1018 ;; records the current position in the error list, and we must |
975 ;; We started in the middle of an existing list of parsed | 1035 ;; We started in the middle of an existing list of parsed |
976 ;; errors before parsing more; restore that position. | 1036 ;; errors before parsing more; restore that position. |
977 (setq compilation-error-list error-list-pos)) | 1037 (setq compilation-error-list error-list-pos)) |
978 )))))) | 1038 )))))) |
979 | 1039 |
1040 ;; XEmacs addition | |
1041 ;; FSF has added this by 19.34, but it is highly complex, why? -sb | |
1042 (defun compile-mouse-goto-error (event) | |
1043 "Visit the source for the error under the mouse. | |
1044 Use this command in a compilation log buffer." | |
1045 (interactive "e") | |
1046 (mouse-set-point event) | |
1047 (beginning-of-line) | |
1048 (compile-goto-error)) | |
1049 | |
980 (defun compile-goto-error (&optional argp) | 1050 (defun compile-goto-error (&optional argp) |
981 "Visit the source for the error message point is on. | 1051 "Visit the source for the error message point is on. |
982 Use this command in a compilation log buffer. Sets the mark at point there. | 1052 Use this command in a compilation log buffer. Sets the mark at point there. |
983 \\[universal-argument] as a prefix arg means to reparse the buffer's error messages first; | 1053 \\[universal-argument] as a prefix arg means to reparse the buffer's error messages first; |
984 other kinds of prefix arguments are ignored." | 1054 other kinds of prefix arguments are ignored." |
1007 ;; but we didn't want to do that. | 1077 ;; but we didn't want to do that. |
1008 (set-buffer compilation-last-buffer))) | 1078 (set-buffer compilation-last-buffer))) |
1009 | 1079 |
1010 (push-mark) | 1080 (push-mark) |
1011 (next-error 1)) | 1081 (next-error 1)) |
1012 | |
1013 ;; XEmacs addition | |
1014 (defun compile-mouse-goto-error (event) | |
1015 "Visit the source for the error under the mouse. | |
1016 Use this command in a compilation log buffer." | |
1017 (interactive "e") | |
1018 (mouse-set-point event) | |
1019 (beginning-of-line) | |
1020 (compile-goto-error)) | |
1021 | 1082 |
1022 ;; XEmacs addition | 1083 ;; XEmacs addition |
1023 (defun compile-mouse-maybe-goto-error (event &optional click-count) | 1084 (defun compile-mouse-maybe-goto-error (event &optional click-count) |
1024 (interactive "e") | 1085 (interactive "e") |
1025 (if (equal (event-button event) 2) | 1086 (if (equal (event-button event) 2) |
1045 (if (and (not other-buffer) | 1106 (if (and (not other-buffer) |
1046 (compilation-buffer-p (current-buffer))) | 1107 (compilation-buffer-p (current-buffer))) |
1047 ;; The current buffer is a compilation buffer. | 1108 ;; The current buffer is a compilation buffer. |
1048 (current-buffer) | 1109 (current-buffer) |
1049 (if (and compilation-last-buffer (buffer-name compilation-last-buffer) | 1110 (if (and compilation-last-buffer (buffer-name compilation-last-buffer) |
1111 (compilation-buffer-p compilation-last-buffer) | |
1050 (or (not other-buffer) (not (eq compilation-last-buffer | 1112 (or (not other-buffer) (not (eq compilation-last-buffer |
1051 (current-buffer))))) | 1113 (current-buffer))))) |
1052 compilation-last-buffer | 1114 compilation-last-buffer |
1053 (let ((buffers (buffer-list))) | 1115 (let ((buffers (buffer-list))) |
1054 (while (and buffers (or (not (compilation-buffer-p (car buffers))) | 1116 (while (and buffers (or (not (compilation-buffer-p (car buffers))) |
1093 ;; We want to pass a number here only if | 1155 ;; We want to pass a number here only if |
1094 ;; we got a numeric prefix arg, not just C-u. | 1156 ;; we got a numeric prefix arg, not just C-u. |
1095 (and (not (consp argp)) | 1157 (and (not (consp argp)) |
1096 (prefix-numeric-value argp)) | 1158 (prefix-numeric-value argp)) |
1097 (consp argp)))) | 1159 (consp argp)))) |
1160 ;;;###autoload (define-key ctl-x-map "`" 'next-error) | |
1098 | 1161 |
1099 ;; XEmacs change | 1162 ;; XEmacs change |
1100 ;;;###autoload | 1163 ;;;###autoload |
1101 (defun previous-error (&optional argp) | 1164 (defun previous-error (&optional argp) |
1102 "Visit previous compilation error message and corresponding source code. | 1165 "Visit previous compilation error message and corresponding source code. |
1174 ; (compilation-forget-errors)) | 1237 ; (compilation-forget-errors)) |
1175 (if silent | 1238 (if silent |
1176 (throw 'no-next-error nil) | 1239 (throw 'no-next-error nil) |
1177 (error (concat compilation-error-message | 1240 (error (concat compilation-error-message |
1178 (and (get-buffer-process (current-buffer)) | 1241 (and (get-buffer-process (current-buffer)) |
1179 (eq (process-status (get-buffer-process | 1242 (eq (process-status |
1243 (get-buffer-process | |
1180 (current-buffer))) | 1244 (current-buffer))) |
1181 'run) | 1245 'run) |
1182 " yet"))))) | 1246 " yet"))))) |
1183 (setq compilation-error-list (cdr next-errors)) | 1247 (setq compilation-error-list (cdr next-errors)) |
1184 (if (null (cdr next-error)) | 1248 (if (null (cdr next-error)) |
1334 ;; going to the right place, widen. | 1398 ;; going to the right place, widen. |
1335 (or (= (point) (marker-position (cdr next-error))) | 1399 (or (= (point) (marker-position (cdr next-error))) |
1336 (progn | 1400 (progn |
1337 (widen) | 1401 (widen) |
1338 (goto-char (cdr next-error)))))) | 1402 (goto-char (cdr next-error)))))) |
1339 | 1403 |
1340 ;;;###autoload (define-key ctl-x-map "`" 'next-error) | |
1341 | 1404 |
1342 ;; Find a buffer for file FILENAME. | 1405 ;; Find a buffer for file FILENAME. |
1343 ;; Search the directories in compilation-search-path. | 1406 ;; Search the directories in compilation-search-path. |
1344 ;; A nil in compilation-search-path means to try the | 1407 ;; A nil in compilation-search-path means to try the |
1345 ;; current directory, which is passed in DIR. | 1408 ;; current directory, which is passed in DIR. |
1479 ;; name and line number (and possibly column number). | 1542 ;; name and line number (and possibly column number). |
1480 (setq alist (or compilation-error-regexp-alist | 1543 (setq alist (or compilation-error-regexp-alist |
1481 (error "compilation-error-regexp-alist is empty!")) | 1544 (error "compilation-error-regexp-alist is empty!")) |
1482 subexpr (1+ error-group)) | 1545 subexpr (1+ error-group)) |
1483 (while alist | 1546 (while alist |
1484 (setq error-regexp-groups (cons (list subexpr | 1547 (setq error-regexp-groups |
1485 (+ subexpr (nth 1 (car alist))) | 1548 (cons (list subexpr |
1486 (+ subexpr (nth 2 (car alist))) | 1549 (+ subexpr (nth 1 (car alist))) |
1487 ;;#### This is buggy in FSFmacs | 1550 (+ subexpr (nth 2 (car alist))) |
1488 (let ((col (nth 3 (car alist)))) | 1551 ;;#### This is buggy in FSFmacs |
1489 (and col | 1552 (let ((col (nth 3 (car alist)))) |
1490 (+ subexpr col)))) | 1553 (and col |
1491 error-regexp-groups)) | 1554 (+ subexpr col)))) |
1555 error-regexp-groups)) | |
1492 (setq subexpr (+ subexpr 1 (count-regexp-groupings (car (car alist))))) | 1556 (setq subexpr (+ subexpr 1 (count-regexp-groupings (car (car alist))))) |
1493 (setq alist (cdr alist))) | 1557 (setq alist (cdr alist))) |
1494 | 1558 |
1495 ;; Set up now the expanded, abbreviated directory variables | 1559 ;; Set up now the expanded, abbreviated directory variables |
1496 ;; that compile-abbreviate-directory will need, so we can | 1560 ;; that compile-abbreviate-directory will need, so we can |
1603 ;; If the file name is relative, default-directory will | 1667 ;; If the file name is relative, default-directory will |
1604 ;; already contain the comint-file-name-prefix (done by | 1668 ;; already contain the comint-file-name-prefix (done by |
1605 ;; compile-abbreviate-directory). | 1669 ;; compile-abbreviate-directory). |
1606 (file-name-absolute-p filename) | 1670 (file-name-absolute-p filename) |
1607 (setq filename (concat comint-file-name-prefix filename))) | 1671 (setq filename (concat comint-file-name-prefix filename))) |
1672 | |
1673 ;; Some compilers (e.g. Sun's java compiler, reportedly) | |
1674 ;; produce bogus file names like "./bar//foo.c" for the file | |
1675 ;; "bar/foo.c"; expand-file-name will collapse these into | |
1676 ;; "/foo.c" and fail to find the appropriate file. So we look | |
1677 ;; for doubled slashes in the file name and fix them up in the | |
1678 ;; buffer. | |
1679 (when (fboundp 'command-line-normalize-file-name) | |
1680 (setq filename (command-line-normalize-file-name filename))) | |
1608 (setq filename (cons filename (cons default-directory | 1681 (setq filename (cons filename (cons default-directory |
1609 (nthcdr 4 alist)))) | 1682 (nthcdr 4 alist)))) |
1610 | 1683 |
1611 | 1684 |
1612 ;; Locate the erring file and line. | 1685 ;; Locate the erring file and line. |
1654 ) | 1727 ) |
1655 ) | 1728 ) |
1656 (t | 1729 (t |
1657 (error "compilation-parse-errors: known groups didn't match!"))) | 1730 (error "compilation-parse-errors: known groups didn't match!"))) |
1658 | 1731 |
1659 (message "Parsing error messages...%d (%d%% of buffer)" | 1732 (message "Parsing error messages...%d (%.0f%% of buffer)" |
1660 compilation-num-errors-found | 1733 compilation-num-errors-found |
1661 (/ (* 100 (point)) (point-max))) | 1734 ;; Use floating-point because (* 100 (point)) frequently |
1735 ;; exceeds the range of Emacs Lisp integers. | |
1736 (/ (* 100.0 (point)) (point-max))) | |
1662 | 1737 |
1663 (and limit-search (>= (point) limit-search) | 1738 (and limit-search (>= (point) limit-search) |
1664 ;; The user wanted a specific error, and we're past it. | 1739 ;; The user wanted a specific error, and we're past it. |
1665 (setq found-desired t))) | 1740 (setq found-desired t))) |
1666 (setq compilation-parsing-end (if found-desired | 1741 (setq compilation-parsing-end (if found-desired |
1700 (concat (file-name-directory | 1775 (concat (file-name-directory |
1701 (directory-file-name orig)) | 1776 (directory-file-name orig)) |
1702 (substring dir (length parent-expanded))))) | 1777 (substring dir (length parent-expanded))))) |
1703 dir) | 1778 dir) |
1704 | 1779 |
1705 | |
1706 (provide 'compile) | 1780 (provide 'compile) |
1707 | 1781 |
1708 ;;; compile.el ends here | 1782 ;;; compile.el ends here |