annotate lisp/progmodes/compile.el @ 54457:ba16dd8bb815

*** empty log message ***
author Richard M. Stallman <rms@gnu.org>
date Sun, 21 Mar 2004 14:31:42 +0000
parents 6ea174960a93
children 3ae52d0dfe0b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38412
253f761ad37b Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents: 38077
diff changeset
1 ;;; compile.el --- run compiler as inferior of Emacs, parse error messages
712
16823e891d56 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 621
diff changeset
2
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
3 ;; Copyright (C) 1985, 86, 87, 93, 94, 95, 96, 97, 98, 1999, 2001, 03, 2004
40294
c3b8e6d5266f (compilation-parse-errors-filename-function):
Gerd Moellmann <gerd@gnu.org>
parents: 40222
diff changeset
4 ;; Free Software Foundation, Inc.
846
20674ae6bf52 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 811
diff changeset
5
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
6 ;; Authors: Roland McGrath <roland@gnu.org>,
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
7 ;; Daniel Pfeiffer <occitan@esperanto.org>
795
c693d56ef36d *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 778
diff changeset
8 ;; Maintainer: FSF
2247
2c7997f249eb Add or correct keywords
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1846
diff changeset
9 ;; Keywords: tools, processes
795
c693d56ef36d *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 778
diff changeset
10
71
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; This file is part of GNU Emacs.
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12
804
33aaf4b71a1d *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 795
diff changeset
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
33aaf4b71a1d *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 795
diff changeset
14 ;; it under the terms of the GNU General Public License as published by
33aaf4b71a1d *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 795
diff changeset
15 ;; the Free Software Foundation; either version 2, or (at your option)
33aaf4b71a1d *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 795
diff changeset
16 ;; any later version.
71
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17
804
33aaf4b71a1d *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 795
diff changeset
18 ;; GNU Emacs is distributed in the hope that it will be useful,
33aaf4b71a1d *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 795
diff changeset
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
33aaf4b71a1d *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 795
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33aaf4b71a1d *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 795
diff changeset
21 ;; GNU General Public License for more details.
33aaf4b71a1d *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 795
diff changeset
22
33aaf4b71a1d *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 795
diff changeset
23 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14049
diff changeset
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14049
diff changeset
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14049
diff changeset
26 ;; Boston, MA 02111-1307, USA.
71
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27
2337
2ee64176069c Fix library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
28 ;;; Commentary:
2ee64176069c Fix library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
29
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
30 ;; This package provides the compile facilities documented in the Emacs user's
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
31 ;; manual.
2337
2ee64176069c Fix library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
32
795
c693d56ef36d *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 778
diff changeset
33 ;;; Code:
c693d56ef36d *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 778
diff changeset
34
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
35 ;; This is the parsing engine for compile:
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
36 (require 'font-lock) ; needed to get font-lock-value-in-major-mode
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
37
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
38 ;;; This mode uses some complex data-structures:
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
39
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
40 ;;; LOC (or location) is a list of (COLUMN LINE FILE-STRUCTURE)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
41
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
42 ;; COLUMN and LINE are numbers parsed from an error message. COLUMN and maybe
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
43 ;; LINE will be nil for a message that doesn't contain them. Then the
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
44 ;; location refers to a indented beginning of line or beginning of file.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
45 ;; Once any location in some file has been jumped to, the list is extended to
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
46 ;; (COLUMN LINE FILE-STRUCTURE MARKER . VISITED) for all LOCs pertaining to
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
47 ;; that file.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
48 ;; MARKER initially points to LINE and COLUMN in a buffer visiting that file.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
49 ;; Being a marker it sticks to some text, when the buffer grows or shrinks
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
50 ;; before that point. VISITED is t if we have jumped there, else nil.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
51
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
52 ;;; FILE-STRUCTURE is a list of ((FILENAME . DIRECTORY) FORMATS (LINE LOC ...)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
53 ;;; ...)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
54
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
55 ;; FILENAME is a string parsed from an error message. DIRECTORY is a string
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
56 ;; obtained by following directory change messages. DIRECTORY will be nil for
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
57 ;; an absolute filename. FORMATS is a list of formats to apply to FILENAME if
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
58 ;; a file of that name can't be found.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
59 ;; The rest of the list is an alist of elements with LINE as key. The keys
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
60 ;; are either nil or line numbers. If present, nil comes first, followed by
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
61 ;; the numbers in decreasing order. The LOCs for each line are again an alist
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
62 ;; ordered the same way. Note that the whole file structure is referenced in
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
63 ;; every LOC.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
64
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
65 ;;; MESSAGE is a list of (LOC TYPE END-LOC)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
66
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
67 ;; TYPE is 0 for info or 1 for warning if the message matcher identified it as
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
68 ;; such, 2 otherwise (for a real error). END-LOC is a LOC pointing to the
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
69 ;; other end, if the parsed message contained a range. If the end of the
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
70 ;; range didn't specify a COLUMN, it defaults to -1, meaning end of line.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
71 ;; These are the value of the `message' text-properties in the compilation
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
72 ;; buffer.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
73
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
74
17639
5339baa0a334 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17623
diff changeset
75 (defgroup compilation nil
5339baa0a334 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17623
diff changeset
76 "Run compiler as inferior of Emacs, parse error messages."
5339baa0a334 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17623
diff changeset
77 :group 'tools
5339baa0a334 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17623
diff changeset
78 :group 'processes)
5339baa0a334 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17623
diff changeset
79
569
505a9721e442 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 474
diff changeset
80
505a9721e442 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 474
diff changeset
81 ;;;###autoload
17639
5339baa0a334 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17623
diff changeset
82 (defcustom compilation-mode-hook nil
5339baa0a334 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17623
diff changeset
83 "*List of hook functions run by `compilation-mode' (see `run-hooks')."
5339baa0a334 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17623
diff changeset
84 :type 'hook
5339baa0a334 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17623
diff changeset
85 :group 'compilation)
5339baa0a334 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17623
diff changeset
86
5339baa0a334 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17623
diff changeset
87 ;;;###autoload
5339baa0a334 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17623
diff changeset
88 (defcustom compilation-window-height nil
5339baa0a334 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17623
diff changeset
89 "*Number of lines in a compilation window. If nil, use Emacs default."
5339baa0a334 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17623
diff changeset
90 :type '(choice (const :tag "Default" nil)
5339baa0a334 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17623
diff changeset
91 integer)
5339baa0a334 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17623
diff changeset
92 :group 'compilation)
418
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
93
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
94 (defvar compilation-first-column 1
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
95 "*This is how compilers number the first column, usually 1 or 0.")
71
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96
40294
c3b8e6d5266f (compilation-parse-errors-filename-function):
Gerd Moellmann <gerd@gnu.org>
parents: 40222
diff changeset
97 (defvar compilation-parse-errors-filename-function nil
c3b8e6d5266f (compilation-parse-errors-filename-function):
Gerd Moellmann <gerd@gnu.org>
parents: 40222
diff changeset
98 "Function to call to post-process filenames while parsing error messages.
c3b8e6d5266f (compilation-parse-errors-filename-function):
Gerd Moellmann <gerd@gnu.org>
parents: 40222
diff changeset
99 It takes one arg FILENAME which is the name of a file as found
c3b8e6d5266f (compilation-parse-errors-filename-function):
Gerd Moellmann <gerd@gnu.org>
parents: 40222
diff changeset
100 in the compilation output, and should return a transformed file name.")
c3b8e6d5266f (compilation-parse-errors-filename-function):
Gerd Moellmann <gerd@gnu.org>
parents: 40222
diff changeset
101
474
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 418
diff changeset
102 ;;;###autoload
16985
b0d8e7c0f906 * (compilation-process-setup-function): New variable.
Eli Zaretskii <eliz@gnu.org>
parents: 16950
diff changeset
103 (defvar compilation-process-setup-function nil
b0d8e7c0f906 * (compilation-process-setup-function): New variable.
Eli Zaretskii <eliz@gnu.org>
parents: 16950
diff changeset
104 "*Function to call to customize the compilation process.
b0d8e7c0f906 * (compilation-process-setup-function): New variable.
Eli Zaretskii <eliz@gnu.org>
parents: 16950
diff changeset
105 This functions is called immediately before the compilation process is
b0d8e7c0f906 * (compilation-process-setup-function): New variable.
Eli Zaretskii <eliz@gnu.org>
parents: 16950
diff changeset
106 started. It can be used to set any variables or functions that are used
53140
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
107 while processing the output of the compilation process. The function
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
108 is called with variables `compilation-buffer' and `compilation-window'
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
109 bound to the compilation buffer and window, respectively.")
16985
b0d8e7c0f906 * (compilation-process-setup-function): New variable.
Eli Zaretskii <eliz@gnu.org>
parents: 16950
diff changeset
110
b0d8e7c0f906 * (compilation-process-setup-function): New variable.
Eli Zaretskii <eliz@gnu.org>
parents: 16950
diff changeset
111 ;;;###autoload
418
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
112 (defvar compilation-buffer-name-function nil
1133
f36b965cfeb0 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1072
diff changeset
113 "Function to compute the name of a compilation buffer.
f36b965cfeb0 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1072
diff changeset
114 The function receives one argument, the name of the major mode of the
f36b965cfeb0 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1072
diff changeset
115 compilation buffer. It should return a string.
f36b965cfeb0 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1072
diff changeset
116 nil means compute the name with `(concat \"*\" (downcase major-mode) \"*\")'.")
71
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117
474
c3bbd755b7da *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 418
diff changeset
118 ;;;###autoload
418
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
119 (defvar compilation-finish-function nil
17639
5339baa0a334 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17623
diff changeset
120 "Function to call when a compilation process finishes.
418
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
121 It is called with two arguments: the compilation buffer, and a string
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
122 describing how the process finished.")
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
123
16042
18414e324084 (compilation-finish-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15084
diff changeset
124 ;;;###autoload
18414e324084 (compilation-finish-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15084
diff changeset
125 (defvar compilation-finish-functions nil
17639
5339baa0a334 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17623
diff changeset
126 "Functions to call when a compilation process finishes.
16042
18414e324084 (compilation-finish-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15084
diff changeset
127 Each function is called with two arguments: the compilation buffer,
18414e324084 (compilation-finish-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15084
diff changeset
128 and a string describing how the process finished.")
18414e324084 (compilation-finish-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15084
diff changeset
129
418
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
130 (defvar compilation-last-buffer nil
1133
f36b965cfeb0 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1072
diff changeset
131 "The most recent compilation buffer.
f36b965cfeb0 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1072
diff changeset
132 A buffer becomes most recent when its compilation is started
f36b965cfeb0 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1072
diff changeset
133 or when it is used with \\[next-error] or \\[compile-goto-error].")
71
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134
740
b39d858a0b19 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 732
diff changeset
135 (defvar compilation-in-progress nil
b39d858a0b19 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 732
diff changeset
136 "List of compilation processes now running.")
b39d858a0b19 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 732
diff changeset
137 (or (assq 'compilation-in-progress minor-mode-alist)
b39d858a0b19 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 732
diff changeset
138 (setq minor-mode-alist (cons '(compilation-in-progress " Compiling")
b39d858a0b19 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 732
diff changeset
139 minor-mode-alist)))
b39d858a0b19 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 732
diff changeset
140
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
141 (defvar compilation-error "error"
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
142 "Stem of message to print when no matches are found.")
1133
f36b965cfeb0 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1072
diff changeset
143
17866
7d458582345c (compilation-parse-errors): Fix paren error.
Richard M. Stallman <rms@gnu.org>
parents: 17653
diff changeset
144 (defvar compilation-arguments nil
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
145 "Arguments that were given to `compilation-start'.")
17866
7d458582345c (compilation-parse-errors): Fix paren error.
Richard M. Stallman <rms@gnu.org>
parents: 17653
diff changeset
146
1133
f36b965cfeb0 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1072
diff changeset
147 (defvar compilation-num-errors-found)
71
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
149 (defconst compilation-error-regexp-alist-alist
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
150 '((absoft
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
151 "^\\(?:[Ee]rror on \\|[Ww]arning on\\( \\)\\)?[Ll]ine[ \t]+\\([0-9]+\\)[ \t]+\
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
152 of[ \t]+\"?\\([a-zA-Z]?:?[^\":\n]+\\)\"?:" 3 2 nil (1))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
153
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
154 (ada
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
155 "\\(warning: .*\\)? at \\([^ \n]+\\):\\([0-9]+\\)$" 2 3 nil (1))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
156
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
157 (aix
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
158 " in line \\([0-9]+\\) of file \\([^ \n]+[^. \n]\\)\\.? " 2 1)
2461
1ecb75748794 (compilation-error-regexp-alist): Merged HP-UX 7.0 fc regexp with the
Roland McGrath <roland@gnu.org>
parents: 2460
diff changeset
159
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
160 (ant
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
161 "^[ \t]*\\[[^] \n]+\\][ \t]*\\([^: \n]+\\):\\([0-9]+\\):\\(?:\\([0-9]+\\):[0-9]+:[0-9]+:\\)?\
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
162 \\( warning\\)?" 1 2 3 (4))
23866
b1adb6a721dd (compilation-error-regexp-alist): Insist on a non-digit in the file name.
Karl Heuer <kwzh@gnu.org>
parents: 23865
diff changeset
163
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
164 (bash
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
165 "^\\([^: \n\t]+\\): line \\([0-9]+\\):" 1 2)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
166
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
167 (borland
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
168 "^\\(?:Error\\|Warnin\\(g\\)\\) \\(?:[FEW][0-9]+ \\)?\
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
169 \\([a-zA-Z]?:?[^:( \t\n]+\\)\
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
170 \\([0-9]+\\)\\(?:[) \t]\\|:[^0-9\n]\\)" 2 3 nil (1))
8398
38513039d818 (compilation-error-regexp-alist): Make separate
Richard M. Stallman <rms@gnu.org>
parents: 8359
diff changeset
171
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
172 (caml
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
173 "^ *File \"\\([^,\" \n\t]+\\)\", lines? \\([0-9]+\\)-?\\([0-9]+\\)?,\
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
174 \\(?: characters? \\([0-9]+\\)-?\\([0-9]+\\)?:\\)?\\([ \n]Warning:\\)?"
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
175 1 (2 . 3) (4 . 5) (6))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
176
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
177 (comma
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
178 "^\"\\([^,\" \n\t]+\\)\", line \\([0-9]+\\)\
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
179 \\(?:[(. pos]+\\([0-9]+\\))?\\)?[:.,; (-]\\( warning:\\|[-0-9 ]*(W)\\)?" 1 2 3 (4))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
180
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
181 (epc
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
182 "^Error [0-9]+ at (\\([0-9]*\\):\\([^)\n]+\\))" 2 1)
44413
2b898d069325 (compilation-error-regexp-alist):
Richard M. Stallman <rms@gnu.org>
parents: 44209
diff changeset
183
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
184 (iar
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
185 "^\"\\(.*\\)\",\\([0-9]+\\)\\s-+\\(?:Error\\|Warnin\\(g\\)\\)\\[[0-9]+\\]:"
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
186 1 2 nil (3))
15084
01518892abad (compilation-error-regexp-alist): Add regexp
Richard M. Stallman <rms@gnu.org>
parents: 14807
diff changeset
187
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
188 (ibm
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
189 "^\\([^( \n\t]+\\)(\\([0-9]+\\):\\([0-9]+\\)) :\
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
190 \\(?:warnin\\(g\\)\\|informationa\\(l\\)\\)?" 1 2 3 (4 . 5))
2461
1ecb75748794 (compilation-error-regexp-alist): Merged HP-UX 7.0 fc regexp with the
Roland McGrath <roland@gnu.org>
parents: 2460
diff changeset
191
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
192 (irix
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
193 "^[a-z0-9/]+: \\(?:[eE]rror\\|[wW]arnin\\(g\\)\\)[0-9 ]*:\
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
194 \\([^,\" \n\t]+\\)\\(?:, line\\|:\\) \\([0-9]+\\):" 2 3 nil (1))
2461
1ecb75748794 (compilation-error-regexp-alist): Merged HP-UX 7.0 fc regexp with the
Roland McGrath <roland@gnu.org>
parents: 2460
diff changeset
195
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
196 (java
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
197 "^\\(?:[ \t]+at \\|==[0-9]+== +\\(?:at\\|b\\(y\\)\\)\\).+(\\([^()\n]+\\):\\([0-9]+\\))$" 2 3 nil (1))
14048
1a0cc425fb62 Mon Nov 6 18:01:01 1995 Dave Love <d.love@dl.ac.uk>
Roland McGrath <roland@gnu.org>
parents: 14047
diff changeset
198
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
199 (jikes-file
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
200 "^\\(?:Found\\|Issued\\) .* compiling \"\\(.+\\)\":$" 1 nil nil 0)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
201 (jikes-line
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
202 "^ *\\([0-9]+\\)\\.[ \t]+.*\n +\\(<-*>\n\\*\\*\\* \\(?:Error\\|Warnin\\(g\\)\\)\\)"
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
203 nil 1 nil 2 0
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
204 (2 (compilation-face '(3))))
2461
1ecb75748794 (compilation-error-regexp-alist): Merged HP-UX 7.0 fc regexp with the
Roland McGrath <roland@gnu.org>
parents: 2460
diff changeset
205
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
206 (gcc-include
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
207 "^\\(?:In file included\\| \\) from \
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
208 \\(.+\\):\\([0-9]+\\)\\(?:\\(:\\)\\|\\(,\\)\\)?" 1 2 nil (3 . 4))
3606
713c76a95b74 * compile.el (compilation-error-list): When we haven't yet
Jim Blandy <jimb@redhat.com>
parents: 3514
diff changeset
209
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
210 (gnu
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
211 "^\\(?:[a-zA-Z][-a-zA-Z0-9.]+: ?\\)?\
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
212 \\([/.]*[a-zA-Z]:?[^ \t\n:]*\\): ?\
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
213 \\([0-9]+\\)\\([.:]?\\)\\([0-9]+\\)?\
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
214 \\(?:-\\(?:\\([0-9]+\\)\\3\\)?\\.?\\([0-9]+\\)?\\)?:\
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
215 \\(?: *\\(\\(?:Future\\|Runtime\\)?[Ww]arning\\|W:\\)\\|\
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
216 *\\([Ii]nfo\\(?:\\>\\|rmationa?l?\\)\\|I:\\)\\)?"
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
217 1 (2 . 5) (4 . 6) (7 . 8))
2461
1ecb75748794 (compilation-error-regexp-alist): Merged HP-UX 7.0 fc regexp with the
Roland McGrath <roland@gnu.org>
parents: 2460
diff changeset
218
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
219 (lcc
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
220 "^\\(?:E\\|\\(W\\)\\), \\([^(\n]+\\)(\\([0-9]+\\),[ \t]*\\([0-9]+\\)"
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
221 2 3 4 (1))
11791
34dbef732b27 (compilation-error-regexp-alist): Add regexps for IBM and Cray compilers.
Roland McGrath <roland@gnu.org>
parents: 11618
diff changeset
222
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
223 (makepp
54368
95647cc2d932 (compilation-error-regexp-alist-alist): Whitespace fixup.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54361
diff changeset
224 "^makepp: \\(?:\\(?:warning\\(:\\).*?\\|\\(Scanning\\|[LR]e?l?oading makefile\\) \\|.*?\\)\
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
225 `\\(\\(\\S +?\\)\\(?::\\([0-9]+\\)\\)?\\)'\\)"
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
226 4 5 nil (1 . 2) 3
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
227 ("`\\(\\(\\S +?\\)\\(?::\\([0-9]+\\)\\)?\\)'" nil nil
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
228 (2 compilation-info-face)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
229 (3 compilation-line-face nil t)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
230 (1 (compilation-error-properties 2 3 nil nil nil 2 nil)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
231 append)))
12767
287cc74602fa (compilation-error-regexp-alist): Add regexp for Sun ada.
Roland McGrath <roland@gnu.org>
parents: 12256
diff changeset
232
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
233 (mips-1
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
234 " (\\([0-9]+\\)) in \\([^ \n]+\\)" 2 1)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
235 (mips-2
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
236 " in \\([^()\n ]+\\)(\\([0-9]+\\))$" 1 2)
17582
52780f61eb76 (compilation-error-regexp-alist): Add regexp for Perl -w.
Richard M. Stallman <rms@gnu.org>
parents: 17277
diff changeset
237
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
238 (msft
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
239 "^\\(\\(?:[a-zA-Z]:\\)?[^:(\t\n]+\\)(\\([0-9]+\\)) \
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
240 : \\(?:error\\|warnin\\(g\\)\\) C[0-9]+:" 1 2 nil (3))
18477
270080940256 (compilation-error-regexp-alist): New item, for Oracle compiler.
Richard M. Stallman <rms@gnu.org>
parents: 18273
diff changeset
241
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
242 (oracle
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
243 "^Semantic error at line \\([0-9]+\\), column \\([0-9]+\\), file \\(.*\\):$"
18477
270080940256 (compilation-error-regexp-alist): New item, for Oracle compiler.
Richard M. Stallman <rms@gnu.org>
parents: 18273
diff changeset
244 3 1 2)
18984
d2c26a873eb4 (compilation-error-regexp-alist): Add elt for EPC F90.
Richard M. Stallman <rms@gnu.org>
parents: 18619
diff changeset
245
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
246 (perl
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
247 " at \\([^ \n]+\\) line \\([0-9]+\\)\\(?:[,.]\\|$\\)" 1 2)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
248
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
249 (rxp
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
250 "^\\(?:Error\\|Warnin\\(g\\)\\):.*\n.* line \\([0-9]+\\) char\
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
251 \\([0-9]+\\) of file://\\(.+\\)"
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
252 4 2 3 (1))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
253
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
254 (sparc-pascal-file
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
255 "^\\w\\w\\w \\w\\w\\w +[0-3]?[0-9] +[0-2][0-9]:[0-5][0-9]:[0-5][0-9]\
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
256 [12][09][0-9][0-9] +\\(.*\\):$"
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
257 1 nil nil 0)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
258 (sparc-pascal-line
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
259 "^\\(\\(?:E\\|\\(w\\)\\) +[0-9]+\\) line \\([0-9]+\\) - "
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
260 nil 3 nil (2) nil (1 (compilation-face '(2))))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
261 (sparc-pascal-example
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
262 "^ +\\([0-9]+\\) +.*\n\\(\\(?:e\\|\\(w\\)\\) [0-9]+\\)-+"
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
263 nil 1 nil (3) nil (2 (compilation-face '(3))))
20187
0ee26e03e911 (compilation-error-regexp-alist):
Karl Heuer <kwzh@gnu.org>
parents: 20059
diff changeset
264
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
265 (sun
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
266 ": \\(?:ERROR\\|WARNIN\\(G\\)\\|REMAR\\(K\\)\\) \\(?:[a-zA-Z0-9 ]+, \\)?\
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
267 File = \\(.+\\), Line = \\([0-9]+\\)\\(?:, Column = \\([0-9]+\\)\\)?"
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
268 3 4 5 (1 . 2))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
269
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
270 (sun-ada
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
271 "^\\([^, \n\t]+\\), line \\([0-9]+\\), char \\([0-9]+\\)[:., \(-]" 1 2 3)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
272
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
273 (ultrix
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
274 "^\\(?:cfe\\|fort\\): \\(Warning\\)?[^:\n]*: \\([^ \n]*\\), line \\([0-9]+\\):" 2 3 nil (1))
25435
5ff4e59e5f02 (compilation-error-regexp-alist): New item for SGI IRIX MipsPro compilers.
Richard M. Stallman <rms@gnu.org>
parents: 25433
diff changeset
275
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
276 (4bsd
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
277 "\\(?:^\\|:: \\|\\S ( \\)\\(/[^ \n\t()]+\\)(\\([0-9]+\\))\
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
278 \\(?:: \\(warning:\\)?\\|$\\| ),\\)" 1 2 nil (3)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
279 "Alist of values for `compilation-error-regexp-alist'.")
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
280
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
281 (defcustom compilation-error-regexp-alist
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
282 (mapcar 'car compilation-error-regexp-alist-alist)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
283 "Alist that specifies how to match errors in compiler output.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
284 Note that on Unix exerything is a valid filename, so these
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
285 matchers must make some common sense assumptions, which catch
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
286 normal cases. A shorter list will be lighter on resource usage.
41843
ab6cfeb406ab (compilation-error-regexp-alist): Added regexps for RXP.
Miles Bader <miles@gnu.org>
parents: 41037
diff changeset
287
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
288 Instead of an alist element, you can use a symbol, which is
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
289 looked up in `compilation-error-regexp-alist-alist'. You can see
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
290 the predefined symbols and their effects in the file
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
291 `etc/compilation.txt' (linked below if your are customizing this).
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
292
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
293 Each elt has the form (REGEXP FILE [LINE COLUMN TYPE HYPERLINK
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
294 HIGHLIGHT...]). If REGEXP matches, the FILE'th subexpression
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
295 gives the file name, and the LINE'th subexpression gives the line
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
296 number. The COLUMN'th subexpression gives the column number on
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
297 that line.
52219
cf7c59950b0a 2003-08-14 Thu Jari Aalto <jari.aalto@poboxes.com>
Alex Schroeder <alex@gnu.org>
parents: 52061
diff changeset
298
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
299 If FILE, LINE or COLUMN are nil or that index didn't match, that
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
300 information is not present on the matched line. In that case the
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
301 file name is assumed to be the same as the previous one in the
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
302 buffer, line number defaults to 1 and column defaults to
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
303 beginning of line's indentation.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
304
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
305 FILE can also have the form (FILE FORMAT...), where the FORMATs
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
306 \(e.g. \"%s.c\") will be applied in turn to the recognized file
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
307 name, until a file of that name is found. Or FILE can also be a
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
308 function to return the filename.
52219
cf7c59950b0a 2003-08-14 Thu Jari Aalto <jari.aalto@poboxes.com>
Alex Schroeder <alex@gnu.org>
parents: 52061
diff changeset
309
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
310 LINE can also be of the form (LINE . END-LINE) meaning a range
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
311 of lines. COLUMN can also be of the form (COLUMN . END-COLUMN)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
312 meaning a range of columns starting on LINE and ending on
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
313 END-LINE, if that matched.
52219
cf7c59950b0a 2003-08-14 Thu Jari Aalto <jari.aalto@poboxes.com>
Alex Schroeder <alex@gnu.org>
parents: 52061
diff changeset
314
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
315 TYPE is 2 or nil for a real error or 1 for warning or 0 for info.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
316 TYPE can also be of the form (WARNING . INFO). In that case this
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
317 will be equivalent to 1 if the WARNING'th subexpression matched
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
318 or else equivalent to 0 if the INFO'th subexpression matched.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
319 See `compilation-error-face', `compilation-warning-face',
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
320 `compilation-info-face' and `compilation-skip-threshold'.
26229
11ac69b74132 (compilation-error-regexp-alist): Recognize
Gerd Moellmann <gerd@gnu.org>
parents: 26222
diff changeset
321
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
322 What matched the HYPERLINK'th subexpression has `mouse-face' and
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
323 `compilation-message-face' applied. If this is nil, the text
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
324 matched by the whole REGEXP becomes the hyperlink.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
325
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
326 Additional HIGHLIGHTs as described under `font-lock-keywords' can
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
327 be added."
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
328 :type `(set :menu-tag "Pick"
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
329 ,@(mapcar (lambda (elt)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
330 (list 'const (car elt)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
331 compilation-error-regexp-alist-alist))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
332 :link `(file-link :tag "example file"
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
333 ,(concat doc-directory "compilation.txt"))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
334 :group 'compilation)
71
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335
53978
227623e374e8 (compilation-directory): New defvar.
Eli Zaretskii <eliz@is.elta.co.il>
parents: 53493
diff changeset
336 (defvar compilation-directory nil
227623e374e8 (compilation-directory): New defvar.
Eli Zaretskii <eliz@is.elta.co.il>
parents: 53493
diff changeset
337 "Directory to restore to when doing `recompile'.")
227623e374e8 (compilation-directory): New defvar.
Eli Zaretskii <eliz@is.elta.co.il>
parents: 53493
diff changeset
338
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
339 (defvar compilation-directory-matcher
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
340 '("\\(?:Entering\\|Leavin\\(g\\)\\) directory `\\(.+\\)'$" (2 . 1))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
341 "A list for tracking when directories are entered or left.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
342 Nil means not to track directories, e.g. if all file names are absolute. The
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
343 first element is the REGEXP matching these messages. It can match any number
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
344 of variants, e.g. different languages. The remaining elements are all of the
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
345 form (DIR . LEAVE). If for any one of these the DIR'th subexpression
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
346 matches, that is a directory name. If LEAVE is nil or the corresponding
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
347 LEAVE'th subexpression doesn't match, this message is about going into another
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
348 directory. If it does match anything, this message is about going back to the
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
349 directory we were in before the last entering message. If you change this,
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
350 you may also want to change `compilation-page-delimiter'.")
17623
a09fd9348b0d Support compilers that give a message each time the file being
Richard M. Stallman <rms@gnu.org>
parents: 17582
diff changeset
351
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
352 (defvar compilation-page-delimiter
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
353 "^\\(?:\f\\|.*\\(?:Entering\\|Leaving\\) directory `.+'\n\\)+"
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
354 "Value of `page-delimiter' in Compilation mode.")
17623
a09fd9348b0d Support compilers that give a message each time the file being
Richard M. Stallman <rms@gnu.org>
parents: 17582
diff changeset
355
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
356 (defvar compilation-mode-font-lock-keywords
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
357 '(;; configure output lines.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
358 ("^[Cc]hecking \\(?:[Ff]or \\|[Ii]f \\|[Ww]hether \\(?:to \\)?\\)?\\(.+\\)\\.\\.\\. *\\(?:(cached) *\\)?\\(\\(yes\\(?: .+\\)?\\)\\|no\\|\\(.*\\)\\)$"
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
359 (1 font-lock-variable-name-face)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
360 (2 (compilation-face '(4 . 3))))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
361 ;; Command output lines. Recognize `make[n]:' lines too.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
362 ("^\\([A-Za-z_0-9/.+-]+\\)\\(\\[\\([0-9]+\\)\\]\\)?[ \t]*:"
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
363 (1 font-lock-function-name-face) (3 compilation-line-face nil t))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
364 (" --?o\\(?:utfile\\|utput\\)?[= ]?\\(\\S +\\)" . 1)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
365 ("^Compilation finished" . compilation-info-face)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
366 ("^Compilation exited abnormally" . compilation-error-face))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
367 "Additional things to highlight in Compilation mode.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
368 This gets tacked on the end of the generated expressions.")
17623
a09fd9348b0d Support compilers that give a message each time the file being
Richard M. Stallman <rms@gnu.org>
parents: 17582
diff changeset
369
53140
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
370 (defvar compilation-highlight-regexp t
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
371 "Regexp matching part of visited source lines to highlight temporarily.
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
372 Highlight entire line if t; don't highlight source lines if nil.")
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
373
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
374 (defvar compilation-highlight-overlay nil
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
375 "Overlay used to temporarily highlight compilation matches.")
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
376
23263
03626baa368a (compilation-error-screen-columns): New
Andreas Schwab <schwab@suse.de>
parents: 23228
diff changeset
377 (defcustom compilation-error-screen-columns t
03626baa368a (compilation-error-screen-columns): New
Andreas Schwab <schwab@suse.de>
parents: 23228
diff changeset
378 "*If non-nil, column numbers in error messages are screen columns.
03626baa368a (compilation-error-screen-columns): New
Andreas Schwab <schwab@suse.de>
parents: 23228
diff changeset
379 Otherwise they are interpreted as character positions, with
03626baa368a (compilation-error-screen-columns): New
Andreas Schwab <schwab@suse.de>
parents: 23228
diff changeset
380 each character occupying one column.
03626baa368a (compilation-error-screen-columns): New
Andreas Schwab <schwab@suse.de>
parents: 23228
diff changeset
381 The default is to use screen columns, which requires that the compilation
03626baa368a (compilation-error-screen-columns): New
Andreas Schwab <schwab@suse.de>
parents: 23228
diff changeset
382 program and Emacs agree about the display width of the characters,
03626baa368a (compilation-error-screen-columns): New
Andreas Schwab <schwab@suse.de>
parents: 23228
diff changeset
383 especially the TAB character."
03626baa368a (compilation-error-screen-columns): New
Andreas Schwab <schwab@suse.de>
parents: 23228
diff changeset
384 :type 'boolean
03626baa368a (compilation-error-screen-columns): New
Andreas Schwab <schwab@suse.de>
parents: 23228
diff changeset
385 :group 'compilation
03626baa368a (compilation-error-screen-columns): New
Andreas Schwab <schwab@suse.de>
parents: 23228
diff changeset
386 :version "20.4")
03626baa368a (compilation-error-screen-columns): New
Andreas Schwab <schwab@suse.de>
parents: 23228
diff changeset
387
17639
5339baa0a334 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17623
diff changeset
388 (defcustom compilation-read-command t
26222
35c7eab893ab Checkdoc-inspired fixes.
Dave Love <fx@gnu.org>
parents: 25623
diff changeset
389 "*Non-nil means \\[compile] reads the compilation command to use.
35c7eab893ab Checkdoc-inspired fixes.
Dave Love <fx@gnu.org>
parents: 25623
diff changeset
390 Otherwise, \\[compile] just uses the value of `compile-command'."
17639
5339baa0a334 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17623
diff changeset
391 :type 'boolean
5339baa0a334 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17623
diff changeset
392 :group 'compilation)
5406
d9a58377567c (compilation-read-command, compilation-ask-about-save): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 5260
diff changeset
393
19766
0790c7dab24d (compilation-ask-about-save): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 19616
diff changeset
394 ;;;###autoload
17639
5339baa0a334 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17623
diff changeset
395 (defcustom compilation-ask-about-save t
26222
35c7eab893ab Checkdoc-inspired fixes.
Dave Love <fx@gnu.org>
parents: 25623
diff changeset
396 "*Non-nil means \\[compile] asks which buffers to save before compiling.
17639
5339baa0a334 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17623
diff changeset
397 Otherwise, it saves all modified buffers without asking."
5339baa0a334 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17623
diff changeset
398 :type 'boolean
5339baa0a334 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17623
diff changeset
399 :group 'compilation)
5406
d9a58377567c (compilation-read-command, compilation-ask-about-save): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 5260
diff changeset
400
569
505a9721e442 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 474
diff changeset
401 ;;;###autoload
17639
5339baa0a334 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17623
diff changeset
402 (defcustom compilation-search-path '(nil)
569
505a9721e442 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 474
diff changeset
403 "*List of directories to search for source files named in error messages.
418
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
404 Elements should be directory names, not file names of directories.
17639
5339baa0a334 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17623
diff changeset
405 nil as an element means to try the default directory."
5339baa0a334 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17623
diff changeset
406 :type '(repeat (choice (const :tag "Default" nil)
5339baa0a334 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17623
diff changeset
407 (string :tag "Directory")))
5339baa0a334 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17623
diff changeset
408 :group 'compilation)
71
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
409
17639
5339baa0a334 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17623
diff changeset
410 (defcustom compile-command "make -k "
5339baa0a334 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17623
diff changeset
411 "*Last shell command used to do a compilation; default for next compilation.
71
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
412
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
413 Sometimes it is useful for files to supply local values for this variable.
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
414 You might also use mode hooks to specify it in certain modes, like this:
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415
19007
1606d5205bbc (compile-command): More doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 18987
diff changeset
416 (add-hook 'c-mode-hook
1606d5205bbc (compile-command): More doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 18987
diff changeset
417 (lambda ()
1606d5205bbc (compile-command): More doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 18987
diff changeset
418 (unless (or (file-exists-p \"makefile\")
1606d5205bbc (compile-command): More doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 18987
diff changeset
419 (file-exists-p \"Makefile\"))
38493
864c2b4076f8 (compilation-parse-errors): `linenum' might return a this-error using
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
420 (set (make-local-variable 'compile-command)
864c2b4076f8 (compilation-parse-errors): `linenum' might return a this-error using
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
421 (concat \"make -k \"
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
422 (file-name-sans-extension buffer-file-name))))))"
17639
5339baa0a334 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17623
diff changeset
423 :type 'string
5339baa0a334 Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17623
diff changeset
424 :group 'compilation)
71
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
426 ;; A weak per-compilation-buffer hash indexed by (FILENAME . DIRECTORY). Each
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
427 ;; value is a FILE-STRUCTURE as described above, with the car eq to the hash
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
428 ;; key. This holds the tree seen from root, for storing new nodes.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
429 (defvar compilation-locs ())
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
430
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
431 (defvar compilation-debug nil
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
432 "*Set this to `t' before creating a *compilation* buffer.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
433 Then every error line will have a debug text property with the matcher that
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
434 fit this line and the match data. Use `describe-text-properties'.")
418
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
435
12920
905444ab8d92 (compilation-exit-message-function): New variable.
Roland McGrath <roland@gnu.org>
parents: 12767
diff changeset
436 (defvar compilation-exit-message-function nil "\
905444ab8d92 (compilation-exit-message-function): New variable.
Roland McGrath <roland@gnu.org>
parents: 12767
diff changeset
437 If non-nil, called when a compilation process dies to return a status message.
14045
1300c7703f67 (compilation-handle-exit): New function, broken out of compilation-sentinel.
Roland McGrath <roland@gnu.org>
parents: 13972
diff changeset
438 This should be a function of three arguments: process status, exit status,
1300c7703f67 (compilation-handle-exit): New function, broken out of compilation-sentinel.
Roland McGrath <roland@gnu.org>
parents: 13972
diff changeset
439 and exit message; it returns a cons (MESSAGE . MODELINE) of the strings to
1300c7703f67 (compilation-handle-exit): New function, broken out of compilation-sentinel.
Roland McGrath <roland@gnu.org>
parents: 13972
diff changeset
440 write into the compilation buffer, and to put in its mode line.")
12920
905444ab8d92 (compilation-exit-message-function): New variable.
Roland McGrath <roland@gnu.org>
parents: 12767
diff changeset
441
52061
d11e55dcc374 2003-07-28 Tak Ota <Takaaki.Ota@am.sony.com> (tiny change)
John Paul Wallington <jpw@pobox.com>
parents: 51797
diff changeset
442 (defvar compilation-environment nil
d11e55dcc374 2003-07-28 Tak Ota <Takaaki.Ota@am.sony.com> (tiny change)
John Paul Wallington <jpw@pobox.com>
parents: 51797
diff changeset
443 "*List of environment variables for compilation to inherit.
d11e55dcc374 2003-07-28 Tak Ota <Takaaki.Ota@am.sony.com> (tiny change)
John Paul Wallington <jpw@pobox.com>
parents: 51797
diff changeset
444 Each element should be a string of the form ENVVARNAME=VALUE.
d11e55dcc374 2003-07-28 Tak Ota <Takaaki.Ota@am.sony.com> (tiny change)
John Paul Wallington <jpw@pobox.com>
parents: 51797
diff changeset
445 This list is temporarily prepended to `process-environment' prior to
d11e55dcc374 2003-07-28 Tak Ota <Takaaki.Ota@am.sony.com> (tiny change)
John Paul Wallington <jpw@pobox.com>
parents: 51797
diff changeset
446 starting the compilation process.")
d11e55dcc374 2003-07-28 Tak Ota <Takaaki.Ota@am.sony.com> (tiny change)
John Paul Wallington <jpw@pobox.com>
parents: 51797
diff changeset
447
864
fe5f6b7c9727 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
448 ;; History of compile commands.
fe5f6b7c9727 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
449 (defvar compile-history nil)
fe5f6b7c9727 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
450
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
451 (defface compilation-warning-face
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
452 '((((type tty) (class color)) (:foreground "cyan" :weight bold))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
453 (((class color)) (:foreground "Orange" :weight bold))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
454 (t (:weight bold)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
455 "Face used to highlight compiler warnings."
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
456 :group 'font-lock-highlighting-faces)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
457
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
458 (defface compilation-info-face
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
459 '((((type tty) (class color)) (:foreground "green" :weight bold))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
460 (((class color) (background light)) (:foreground "Green3" :weight bold))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
461 (((class color) (background dark)) (:foreground "Green" :weight bold))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
462 (t (:weight bold)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
463 "Face used to highlight compiler warnings."
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
464 :group 'font-lock-highlighting-faces)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
465
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
466 (defvar compilation-message-face nil
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
467 "Face name to use for whole messages.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
468 Faces `compilation-error-face', `compilation-warning-face',
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
469 `compilation-info-face', `compilation-line-face' and
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
470 `compilation-column-face' get prepended to this, when applicable.")
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
471
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
472 (defvar compilation-error-face 'font-lock-warning-face
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
473 "Face name to use for file name in error messages.")
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
474
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
475 (defvar compilation-warning-face 'compilation-warning-face
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
476 "Face name to use for file name in warning messages.")
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
477
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
478 (defvar compilation-info-face 'compilation-info-face
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
479 "Face name to use for file name in informational messages.")
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
480
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
481 (defvar compilation-line-face 'font-lock-variable-name-face
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
482 "Face name to use for line number in message.")
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
483
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
484 (defvar compilation-column-face 'font-lock-type-face
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
485 "Face name to use for column number in message.")
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
486
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
487 ;; same faces as dired uses
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
488 (defvar compilation-enter-directory-face 'font-lock-function-name-face
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
489 "Face name to use for column number in message.")
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
490
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
491 (defvar compilation-leave-directory-face 'font-lock-type-face
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
492 "Face name to use for column number in message.")
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
493
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
494
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
495
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
496 (defun compilation-face (type)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
497 (or (and (car type) (match-end (car type)) compilation-warning-face)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
498 (and (cdr type) (match-end (cdr type)) compilation-info-face)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
499 compilation-error-face))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
500
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
501 (defun compilation-directory-properties (idx leave)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
502 (if leave (setq leave (match-end leave)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
503 ;; find previous stack, and push onto it, or if `leave' pop it
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
504 (let ((dir (previous-single-property-change (point) 'directory)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
505 (setq dir (if dir (or (get-text-property (1- dir) 'directory)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
506 (get-text-property dir 'directory))))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
507 `(face ,(if leave
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
508 compilation-leave-directory-face
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
509 compilation-enter-directory-face)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
510 directory ,(if leave
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
511 (or (cdr dir)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
512 '(nil)) ; nil only isn't a property-change
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
513 (cons (match-string-no-properties idx) dir))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
514 mouse-face highlight
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
515 help-echo "mouse-2: visit current directory")))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
516
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
517 ;; Data type `reverse-ordered-alist' retriever. This function retrieves the
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
518 ;; KEY element from the ALIST, creating it in the right position if not already
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
519 ;; present. ALIST structure is
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
520 ;; '(ANCHOR (KEY1 ...) (KEY2 ...)... (KEYn ALIST ...))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
521 ;; ANCHOR is ignored, but necessary so that elements can be inserted. KEY1
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
522 ;; may be nil. The other KEYs are ordered backwards so that growing line
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
523 ;; numbers can be inserted in front and searching can abort after half the
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
524 ;; list on average.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
525 (defmacro compilation-assq (key alist)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
526 `(let* ((l1 ,alist)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
527 (l2 (cdr l1)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
528 (car (if (if (null ,key)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
529 (if l2 (null (caar l2)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
530 (while (if l2 (if (caar l2) (< ,key (caar l2)) t))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
531 (setq l1 l2
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
532 l2 (cdr l1)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
533 (if l2 (eq ,key (caar l2))))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
534 l2
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
535 (setcdr l1 (cons (list ,key) l2))))))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
536
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
537
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
538 ;; This function is the central driver, called when font-locking to gather
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
539 ;; all information needed to later jump to corresponding source code.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
540 ;; Return a property list with all meta information on this error location.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
541 (defun compilation-error-properties (file line end-line col end-col type fmt)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
542 (unless (< (next-single-property-change (match-beginning 0) 'directory nil (point))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
543 (point))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
544 (if file
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
545 (if (functionp file)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
546 (setq file (funcall file))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
547 (let (dir)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
548 (setq file (match-string-no-properties file))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
549 (unless (file-name-absolute-p file)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
550 (setq dir (previous-single-property-change (point) 'directory)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
551 dir (if dir (or (get-text-property (1- dir) 'directory)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
552 (get-text-property dir 'directory)))))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
553 (setq file (cons file (car dir)) ; top of dir stack is current
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
554 file (or (gethash file compilation-locs)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
555 (puthash file (list file fmt) compilation-locs)))))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
556 ;; This message didn't mention one, get it from previous
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
557 (setq file (previous-single-property-change (point) 'message)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
558 file (or (if file
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
559 (nth 2 (car (or (get-text-property (1- file) 'message)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
560 (get-text-property file 'message)))))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
561 ;; no previous either -- let font-lock continue
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
562 (gethash (setq file '("*unknown*")) compilation-locs)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
563 (puthash file (list file fmt) compilation-locs))))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
564 ;; All of these fields are optional, get them only if we have an index, and
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
565 ;; it matched some part of the message.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
566 (and line
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
567 (setq line (match-string-no-properties line))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
568 (setq line (string-to-number line)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
569 (and end-line
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
570 (setq end-line (match-string-no-properties end-line))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
571 (setq end-line (string-to-number end-line)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
572 (and col
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
573 (setq col (match-string-no-properties col))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
574 (setq col (- (string-to-number col) compilation-first-column)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
575 (if (and end-col (setq end-col (match-string-no-properties end-col)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
576 (setq end-col (- (string-to-number end-col) compilation-first-column))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
577 (if end-line (setq end-col -1)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
578 (if (consp type) ; not a preset type, check what it is.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
579 (setq type (or (and (car type) (match-end (car type)) 1)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
580 (and (cdr type) (match-end (cdr type)) 0)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
581 2)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
582 ;; Get any (first) already existing marker (if any has one, all have one).
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
583 ;; Do this first, as the next assq`s may create new nodes.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
584 (let ((marker (nth 3 (car (cdar (cddr file)))))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
585 (loc (compilation-assq line (cdr file)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
586 end-loc)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
587 (if end-line
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
588 (setq end-loc (compilation-assq end-line (cdr file))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
589 end-loc (compilation-assq end-col end-loc))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
590 (if end-col ; use same line element
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
591 (setq end-loc (compilation-assq end-col loc))))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
592 (setq loc (compilation-assq col loc))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
593 ;; If they are new, make the loc(s) reference the file they point to.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
594 (or (cdr loc) (setcdr loc (list line file)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
595 (if end-loc
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
596 (or (cdr end-loc) (setcdr end-loc (list (or end-line line) file))))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
597 ;; If we'd found a marker, ensure that the new locs also get markers
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
598 (when (and marker
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
599 (not (or (cddr loc) (cddr end-loc))) ; maybe new node w/o marker
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
600 (marker-buffer marker)) ; other marker still valid
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
601 (or line (setq line 1)) ; normalize no linenumber to line 1
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
602 (catch 'marker ; find nearest loc, at least one exists
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
603 (dolist (x (cddr file))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
604 (if (> (or (car x) 1) line)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
605 (setq marker x)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
606 (if (eq (or (car x) 1) line)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
607 (if (cdr (cddr x)) ; at least one other column
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
608 (throw 'marker (setq marker x))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
609 (if marker (throw 'marker t)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
610 (throw 'marker (or marker (setq marker x)))))))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
611 (setq marker (if (eq (car (cddr marker)) col)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
612 (nthcdr 3 marker)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
613 (cddr marker))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
614 file compilation-error-screen-columns)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
615 (save-excursion
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
616 (set-buffer (marker-buffer (cddr marker)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
617 (save-restriction
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
618 (widen)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
619 (goto-char (marker-position (cddr marker)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
620 (beginning-of-line (- line (car (cadr marker)) -1))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
621 (if file ; original c.-error-screen-columns
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
622 (move-to-column (car loc))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
623 (forward-char (car loc)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
624 (setcdr (cdr loc) (point-marker))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
625 (when end-loc
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
626 (beginning-of-line (- end-line line -1))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
627 (if (< end-col 0)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
628 (end-of-line)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
629 (if file ; original c.-error-screen-columns
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
630 (move-to-column (car end-loc))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
631 (forward-char (car end-loc))))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
632 (setcdr (cdr end-loc) (point-marker))))))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
633 ;; Must start with face
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
634 `(face ,compilation-message-face
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
635 message (,loc ,type ,end-loc)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
636 ,@(if compilation-debug
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
637 `(debug (,(assoc (with-no-warnings matcher) font-lock-keywords)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
638 ,@(match-data))))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
639 help-echo ,(if col
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
640 "mouse-2: visit this file, line and column"
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
641 (if line
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
642 "mouse-2: visit this file and line"
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
643 "mouse-2: visit this file"))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
644 mouse-face highlight))))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
645
17056
0f7992bc968f Rewrite Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 17054
diff changeset
646 (defun compilation-mode-font-lock-keywords ()
0f7992bc968f Rewrite Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 17054
diff changeset
647 "Return expressions to highlight in Compilation mode."
0f7992bc968f Rewrite Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 17054
diff changeset
648 (nconc
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
649 ;; make directory tracking
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
650 (if compilation-directory-matcher
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
651 `((,(car compilation-directory-matcher)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
652 ,@(mapcar (lambda (elt)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
653 `(,(car elt)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
654 (compilation-directory-properties
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
655 ,(car elt) ,(cdr elt))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
656 t))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
657 (cdr compilation-directory-matcher)))))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
658
17056
0f7992bc968f Rewrite Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 17054
diff changeset
659 ;; Compiler warning/error lines.
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
660 (mapcar (lambda (item)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
661 (if (symbolp item)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
662 (setq item (cdr (assq item
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
663 compilation-error-regexp-alist-alist))))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
664 (let ((file (nth 1 item))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
665 (line (nth 2 item))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
666 (col (nth 3 item))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
667 (type (nth 4 item))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
668 end-line end-col fmt)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
669 (if (consp file) (setq fmt (cdr file) file (car file)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
670 (if (consp line) (setq end-line (cdr line) line (car line)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
671 (if (consp col) (setq end-col (cdr col) col (car col)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
672
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
673 `(,(nth 0 item)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
674
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
675 ,@(when (integerp file)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
676 `((,file ,(if (consp type)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
677 `(compilation-face ',type)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
678 (aref [compilation-info-face
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
679 compilation-warning-face
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
680 compilation-error-face]
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
681 (or type 2))))))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
682
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
683 ,@(when line
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
684 `((,line compilation-line-face nil t)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
685 ,@(when end-line
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
686 `((,end-line compilation-line-face nil t)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
687
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
688 ,@(when col
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
689 `((,col compilation-column-face nil t)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
690 ,@(when end-col
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
691 `((,end-col compilation-column-face nil t)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
692
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
693 ,@(nthcdr 6 item)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
694 (,(or (nth 5 item) 0)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
695 (compilation-error-properties ',file ,line ,end-line
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
696 ,col ,end-col ',(or type 2)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
697 ',fmt)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
698 append)))) ; for compilation-message-face
17056
0f7992bc968f Rewrite Font Lock support.
Simon Marshall <simon@gnu.org>
parents: 17054
diff changeset
699 compilation-error-regexp-alist)
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
700
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
701 compilation-mode-font-lock-keywords))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
702
12920
905444ab8d92 (compilation-exit-message-function): New variable.
Roland McGrath <roland@gnu.org>
parents: 12767
diff changeset
703
418
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
704 ;;;###autoload
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
705 (defun compile (command &optional comint)
71
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
706 "Compile the program including the current buffer. Default: run `make'.
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
707 Runs COMMAND, a shell command, in a separate process asynchronously
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
708 with output going to the buffer `*compilation*'.
418
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
709
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
710 If optional second arg COMINT is t the buffer will be in comint mode with
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
711 `compilation-shell-minor-mode'.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
712
71
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
713 You can then use the command \\[next-error] to find the next error message
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
714 and move to the source code that caused it.
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
715
9888
9d7972f4657c (compile): With prefix arg, prompt even if (not compilation-read-command).
Roland McGrath <roland@gnu.org>
parents: 9868
diff changeset
716 Interactively, prompts for the command if `compilation-read-command' is
9d7972f4657c (compile): With prefix arg, prompt even if (not compilation-read-command).
Roland McGrath <roland@gnu.org>
parents: 9868
diff changeset
717 non-nil; otherwise uses `compile-command'. With prefix arg, always prompts.
9d7972f4657c (compile): With prefix arg, prompt even if (not compilation-read-command).
Roland McGrath <roland@gnu.org>
parents: 9868
diff changeset
718
51797
7ea30d8ab42d (compile-auto-highlight): Default now t.
Richard M. Stallman <rms@gnu.org>
parents: 51452
diff changeset
719 To run more than one compilation at once, start one and rename
7ea30d8ab42d (compile-auto-highlight): Default now t.
Richard M. Stallman <rms@gnu.org>
parents: 51452
diff changeset
720 the \`*compilation*' buffer to some other name with
7ea30d8ab42d (compile-auto-highlight): Default now t.
Richard M. Stallman <rms@gnu.org>
parents: 51452
diff changeset
721 \\[rename-buffer]. Then start the next one. On most systems,
7ea30d8ab42d (compile-auto-highlight): Default now t.
Richard M. Stallman <rms@gnu.org>
parents: 51452
diff changeset
722 termination of the main compilation process kills its
7ea30d8ab42d (compile-auto-highlight): Default now t.
Richard M. Stallman <rms@gnu.org>
parents: 51452
diff changeset
723 subprocesses.
418
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
724
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
725 The name used for the buffer is actually whatever is returned by
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
726 the function in `compilation-buffer-name-function', so you can set that
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
727 to a function that generates a unique name."
5406
d9a58377567c (compilation-read-command, compilation-ask-about-save): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 5260
diff changeset
728 (interactive
9888
9d7972f4657c (compile): With prefix arg, prompt even if (not compilation-read-command).
Roland McGrath <roland@gnu.org>
parents: 9868
diff changeset
729 (if (or compilation-read-command current-prefix-arg)
5406
d9a58377567c (compilation-read-command, compilation-ask-about-save): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 5260
diff changeset
730 (list (read-from-minibuffer "Compile command: "
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
731 (eval compile-command) nil nil
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
732 '(compile-history . 1)))
38493
864c2b4076f8 (compilation-parse-errors): `linenum' might return a this-error using
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
733 (list (eval compile-command))))
864c2b4076f8 (compilation-parse-errors): `linenum' might return a this-error using
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
734 (unless (equal command (eval compile-command))
864c2b4076f8 (compilation-parse-errors): `linenum' might return a this-error using
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
735 (setq compile-command command))
5406
d9a58377567c (compilation-read-command, compilation-ask-about-save): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 5260
diff changeset
736 (save-some-buffers (not compilation-ask-about-save) nil)
53978
227623e374e8 (compilation-directory): New defvar.
Eli Zaretskii <eliz@is.elta.co.il>
parents: 53493
diff changeset
737 (setq compilation-directory default-directory)
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
738 (compilation-start command comint))
71
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
739
38493
864c2b4076f8 (compilation-parse-errors): `linenum' might return a this-error using
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
740 ;; run compile with the default command line
8425
8b8835f1630a Set up a "Compile" menubar item.
Richard M. Stallman <rms@gnu.org>
parents: 8406
diff changeset
741 (defun recompile ()
41037
5dd37d315c33 (recompile): Use compilation-arguments if set, so as to be able to M-x
Richard M. Stallman <rms@gnu.org>
parents: 40902
diff changeset
742 "Re-compile the program including the current buffer.
5dd37d315c33 (recompile): Use compilation-arguments if set, so as to be able to M-x
Richard M. Stallman <rms@gnu.org>
parents: 40902
diff changeset
743 If this is run in a compilation-mode buffer, re-use the arguments from the
5dd37d315c33 (recompile): Use compilation-arguments if set, so as to be able to M-x
Richard M. Stallman <rms@gnu.org>
parents: 40902
diff changeset
744 original use. Otherwise, it recompiles using `compile-command'."
8425
8b8835f1630a Set up a "Compile" menubar item.
Richard M. Stallman <rms@gnu.org>
parents: 8406
diff changeset
745 (interactive)
8b8835f1630a Set up a "Compile" menubar item.
Richard M. Stallman <rms@gnu.org>
parents: 8406
diff changeset
746 (save-some-buffers (not compilation-ask-about-save) nil)
53978
227623e374e8 (compilation-directory): New defvar.
Eli Zaretskii <eliz@is.elta.co.il>
parents: 53493
diff changeset
747 (let ((default-directory (or compilation-directory default-directory)))
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
748 (apply 'compilation-start (or compilation-arguments
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
749 `(,(eval compile-command))))))
12256
e50e5d419c51 (grep-null-device): Defined.
Richard M. Stallman <rms@gnu.org>
parents: 12219
diff changeset
750
20877
4b22b9a5bd8e (compilation-scroll-output): New variable.
Dave Love <fx@gnu.org>
parents: 20187
diff changeset
751 (defcustom compilation-scroll-output nil
4b22b9a5bd8e (compilation-scroll-output): New variable.
Dave Love <fx@gnu.org>
parents: 20187
diff changeset
752 "*Non-nil to scroll the *compilation* buffer window as output appears.
4b22b9a5bd8e (compilation-scroll-output): New variable.
Dave Love <fx@gnu.org>
parents: 20187
diff changeset
753
4b22b9a5bd8e (compilation-scroll-output): New variable.
Dave Love <fx@gnu.org>
parents: 20187
diff changeset
754 Setting it causes the compilation-mode commands to put point at the
4b22b9a5bd8e (compilation-scroll-output): New variable.
Dave Love <fx@gnu.org>
parents: 20187
diff changeset
755 end of their output window so that the end of the output is always
4b22b9a5bd8e (compilation-scroll-output): New variable.
Dave Love <fx@gnu.org>
parents: 20187
diff changeset
756 visible rather than the begining."
4b22b9a5bd8e (compilation-scroll-output): New variable.
Dave Love <fx@gnu.org>
parents: 20187
diff changeset
757 :type 'boolean
22291
7c8d8ad75d43 (compilation-scroll-output): Correct the :version
Karl Heuer <kwzh@gnu.org>
parents: 22208
diff changeset
758 :version "20.3"
20877
4b22b9a5bd8e (compilation-scroll-output): New variable.
Dave Love <fx@gnu.org>
parents: 20187
diff changeset
759 :group 'compilation)
4b22b9a5bd8e (compilation-scroll-output): New variable.
Dave Love <fx@gnu.org>
parents: 20187
diff changeset
760
39602
8c4c4c89b007 (compilation-buffer-name): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 39599
diff changeset
761
8c4c4c89b007 (compilation-buffer-name): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 39599
diff changeset
762 (defun compilation-buffer-name (mode-name name-function)
8c4c4c89b007 (compilation-buffer-name): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 39599
diff changeset
763 "Return the name of a compilation buffer to use.
8c4c4c89b007 (compilation-buffer-name): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 39599
diff changeset
764 If NAME-FUNCTION is non-nil, call it with one argument MODE-NAME
8c4c4c89b007 (compilation-buffer-name): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 39599
diff changeset
765 to determine the buffer name.
8c4c4c89b007 (compilation-buffer-name): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 39599
diff changeset
766 Likewise if `compilation-buffer-name-function' is non-nil.
8c4c4c89b007 (compilation-buffer-name): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 39599
diff changeset
767 If current buffer is in Compilation mode for the same mode name
8c4c4c89b007 (compilation-buffer-name): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 39599
diff changeset
768 return the name of the current buffer, so that it gets reused.
8c4c4c89b007 (compilation-buffer-name): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 39599
diff changeset
769 Otherwise, construct a buffer name from MODE-NAME."
48035
c27fdc870952 (grep-find-use-xargs): Fix docstring. Patch from Matt Swift
Juanma Barranquero <lekktu@gmail.com>
parents: 47787
diff changeset
770 (cond (name-function
39602
8c4c4c89b007 (compilation-buffer-name): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 39599
diff changeset
771 (funcall name-function mode-name))
48035
c27fdc870952 (grep-find-use-xargs): Fix docstring. Patch from Matt Swift
Juanma Barranquero <lekktu@gmail.com>
parents: 47787
diff changeset
772 (compilation-buffer-name-function
39602
8c4c4c89b007 (compilation-buffer-name): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 39599
diff changeset
773 (funcall compilation-buffer-name-function mode-name))
8c4c4c89b007 (compilation-buffer-name): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 39599
diff changeset
774 ((and (eq major-mode 'compilation-mode)
8c4c4c89b007 (compilation-buffer-name): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 39599
diff changeset
775 (equal mode-name (nth 2 compilation-arguments)))
8c4c4c89b007 (compilation-buffer-name): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 39599
diff changeset
776 (buffer-name))
8c4c4c89b007 (compilation-buffer-name): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 39599
diff changeset
777 (t
8c4c4c89b007 (compilation-buffer-name): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 39599
diff changeset
778 (concat "*" (downcase mode-name) "*"))))
8c4c4c89b007 (compilation-buffer-name): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 39599
diff changeset
779
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
780 ;; This is a rough emulation of the old hack, until the transition to new
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
781 ;; compile is complete.
71
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
782 (defun compile-internal (command error-message
17623
a09fd9348b0d Support compilers that give a message each time the file being
Richard M. Stallman <rms@gnu.org>
parents: 17582
diff changeset
783 &optional name-of-mode parser
a09fd9348b0d Support compilers that give a message each time the file being
Richard M. Stallman <rms@gnu.org>
parents: 17582
diff changeset
784 error-regexp-alist name-function
a09fd9348b0d Support compilers that give a message each time the file being
Richard M. Stallman <rms@gnu.org>
parents: 17582
diff changeset
785 enter-regexp-alist leave-regexp-alist
47300
5128d5a8980c (compile-internal): Add optional argument no-async.
Colin Walters <walters@gnu.org>
parents: 46344
diff changeset
786 file-regexp-alist nomessage-regexp-alist
53140
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
787 no-async highlight-regexp local-map)
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
788 (if parser
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
789 (error "Compile now works very differently, see `compilation-error-regexp-alist'"))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
790 (let ((compilation-error-regexp-alist
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
791 (append file-regexp-alist (or error-regexp-alist
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
792 compilation-error-regexp-alist)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
793 (compilation-error (replace-regexp-in-string "^No more \\(.+\\)s\\.?"
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
794 "\\1" error-message)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
795 (compilation-start command nil name-function highlight-regexp)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
796 (make-obsolete 'compile-internal 'compilation-start)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
797
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
798 (defun compilation-start (command &optional mode name-function highlight-regexp)
71
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
799 "Run compilation command COMMAND (low level interface).
53140
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
800 The rest of the arguments are optional; for them, nil means use the default.
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
801
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
802 MODE is the major mode to set in the compilation buffer. Mode
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
803 may also be `t' meaning `compilation-shell-minor-mode' under `comint-mode'.
53140
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
804 NAME-FUNCTION is a function called to name the buffer.
47300
5128d5a8980c (compile-internal): Add optional argument no-async.
Colin Walters <walters@gnu.org>
parents: 46344
diff changeset
805
53140
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
806 If HIGHLIGHT-REGEXP is non-nil, `next-error' will temporarily highlight
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
807 matching section of the visited source line; the default is to use the
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
808 global value of `compilation-highlight-regexp'.
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
809
894
41507a5a8fd7 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 885
diff changeset
810 Returns the compilation buffer created."
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
811 (or mode (setq mode 'compilation-mode))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
812 (let ((name-of-mode
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
813 (if (eq mode t)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
814 (prog1 "compilation" (require 'comint))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
815 (replace-regexp-in-string "-mode$" "" (symbol-name mode))))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
816 (process-environment
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
817 (append
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
818 compilation-environment
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
819 (if (and (boundp 'system-uses-terminfo)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
820 system-uses-terminfo)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
821 (list "TERM=dumb" "TERMCAP="
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
822 (format "COLUMNS=%d" (window-width)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
823 (list "TERM=emacs"
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
824 (format "TERMCAP=emacs:co#%d:tc=unknown:"
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
825 (window-width))))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
826 ;; Set the EMACS variable, but
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
827 ;; don't override users' setting of $EMACS.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
828 (unless (getenv "EMACS") '("EMACS=t"))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
829 process-environment))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
830 (thisdir default-directory)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
831 outwin outbuf)
71
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
832 (save-excursion
418
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
833 (setq outbuf
39602
8c4c4c89b007 (compilation-buffer-name): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 39599
diff changeset
834 (get-buffer-create (compilation-buffer-name name-of-mode
8c4c4c89b007 (compilation-buffer-name): New function.
Gerd Moellmann <gerd@gnu.org>
parents: 39599
diff changeset
835 name-function)))
71
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
836 (set-buffer outbuf)
418
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
837 (let ((comp-proc (get-buffer-process (current-buffer))))
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
838 (if comp-proc
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
839 (if (or (not (eq (process-status comp-proc) 'run))
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
840 (yes-or-no-p
1554
5af75a1a9a24 * compile.el (compile-internal): Use NAME-OF-MODE in the prompt
Jim Blandy <jimb@redhat.com>
parents: 1294
diff changeset
841 (format "A %s process is running; kill it? "
5af75a1a9a24 * compile.el (compile-internal): Use NAME-OF-MODE in the prompt
Jim Blandy <jimb@redhat.com>
parents: 1294
diff changeset
842 name-of-mode)))
418
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
843 (condition-case ()
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
844 (progn
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
845 (interrupt-process comp-proc)
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
846 (sit-for 1)
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
847 (delete-process comp-proc))
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
848 (error nil))
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
849 (error "Cannot have two processes in `%s' at once"
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
850 (buffer-name)))))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
851 ;; Clear out the compilation buffer and make it writable.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
852 ;; Change its default-directory to the directory where the compilation
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
853 ;; will happen, and insert a `cd' command to indicate this.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
854 (setq buffer-read-only nil)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
855 (buffer-disable-undo (current-buffer))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
856 (erase-buffer)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
857 (buffer-enable-undo (current-buffer))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
858 (setq default-directory thisdir)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
859 ;; output a mode setter, for saving and later reloading this buffer
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
860 (insert "cd " thisdir " # -*-" name-of-mode
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
861 "-*-\nEntering directory `" thisdir "'\n" command "\n")
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
862 (set-buffer-modified-p nil))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
863 ;; If we're already in the compilation buffer, go to the end
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
864 ;; of the buffer, so point will track the compilation output.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
865 (if (eq outbuf (current-buffer))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
866 (goto-char (point-max)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
867 ;; Pop up the compilation buffer.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
868 (setq outwin (display-buffer outbuf nil t))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
869 (with-current-buffer outbuf
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
870 (if (not (eq mode t))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
871 (funcall mode)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
872 (with-no-warnings (comint-mode))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
873 (compilation-shell-minor-mode))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
874 ;; In what way is it non-ergonomic ? -stef
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
875 ;; (toggle-read-only 1) ;;; Non-ergonomic.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
876 (if highlight-regexp
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
877 (set (make-local-variable 'compilation-highlight-regexp)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
878 highlight-regexp))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
879 (set (make-local-variable 'compilation-arguments)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
880 (list command mode name-function highlight-regexp))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
881 (set (make-local-variable 'revert-buffer-function)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
882 'compilation-revert-buffer)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
883 (set-window-start outwin (point-min))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
884 (or (eq outwin (selected-window))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
885 (set-window-point outwin (point)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
886 ;; The setup function is called before compilation-set-window-height
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
887 ;; so it can set the compilation-window-height buffer locally.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
888 (if compilation-process-setup-function
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
889 (funcall compilation-process-setup-function))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
890 (compilation-set-window-height outwin)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
891 ;; Start the compilation.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
892 (if (fboundp 'start-process)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
893 (let ((proc (if (eq mode t)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
894 (get-buffer-process
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
895 (with-no-warnings
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
896 (comint-exec outbuf (downcase mode-name)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
897 shell-file-name nil `("-c" ,command))))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
898 (start-process-shell-command (downcase mode-name)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
899 outbuf command))))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
900 ;; Make the buffer's mode line show process state.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
901 (setq mode-line-process '(":%s"))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
902 (set-process-sentinel proc 'compilation-sentinel)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
903 (set-process-filter proc 'compilation-filter)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
904 (set-marker (process-mark proc) (point) outbuf)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
905 (setq compilation-in-progress
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
906 (cons proc compilation-in-progress)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
907 ;; No asynchronous processes available.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
908 (message "Executing `%s'..." command)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
909 ;; Fake modeline display as if `start-process' were run.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
910 (setq mode-line-process ":run")
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
911 (force-mode-line-update)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
912 (let ((status (call-process shell-file-name nil outbuf nil "-c"
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
913 command)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
914 (cond ((numberp status)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
915 (compilation-handle-exit 'exit status
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
916 (if (zerop status)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
917 "finished\n"
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
918 (format "\
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
919 exited abnormally with code %d\n"
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
920 status))))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
921 ((stringp status)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
922 (compilation-handle-exit 'signal status
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
923 (concat status "\n")))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
924 (t
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
925 (compilation-handle-exit 'bizarre status status))))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
926 (message "Executing `%s'...done" command)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
927 (if (buffer-local-value 'compilation-scroll-output outbuf)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
928 (save-selected-window
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
929 (select-window outwin)
54424
6ea174960a93 (compilation-start): Always set compilation-last-buffer and return it.
Kim F. Storm <storm@cua.dk>
parents: 54368
diff changeset
930 (goto-char (point-max))))
6ea174960a93 (compilation-start): Always set compilation-last-buffer and return it.
Kim F. Storm <storm@cua.dk>
parents: 54368
diff changeset
931 ;; Make it so the next C-x ` will use this buffer.
6ea174960a93 (compilation-start): Always set compilation-last-buffer and return it.
Kim F. Storm <storm@cua.dk>
parents: 54368
diff changeset
932 (setq compilation-last-buffer outbuf)))
71
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
933
8483
19dbc8373bec (compilation-set-window-height): New function,
Richard M. Stallman <rms@gnu.org>
parents: 8425
diff changeset
934 (defun compilation-set-window-height (window)
26222
35c7eab893ab Checkdoc-inspired fixes.
Dave Love <fx@gnu.org>
parents: 25623
diff changeset
935 "Set the height of WINDOW according to `compilation-window-height'."
53140
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
936 (let ((height (buffer-local-value 'compilation-window-height (window-buffer window))))
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
937 (and height
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
938 (= (window-width window) (frame-width (window-frame window)))
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
939 ;; If window is alone in its frame, aside from a minibuffer,
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
940 ;; don't change its height.
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
941 (not (eq window (frame-root-window (window-frame window))))
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
942 ;; This save-current-buffer prevents us from changing the current
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
943 ;; buffer, which might not be the same as the selected window's buffer.
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
944 (save-current-buffer
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
945 (save-selected-window
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
946 (select-window window)
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
947 (enlarge-window (- height (window-height))))))))
8483
19dbc8373bec (compilation-set-window-height): New function,
Richard M. Stallman <rms@gnu.org>
parents: 8425
diff changeset
948
48204
1ee4b312fef0 (grep-default-command): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48197
diff changeset
949 (defvar compilation-menu-map
1ee4b312fef0 (grep-default-command): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48197
diff changeset
950 (let ((map (make-sparse-keymap "Errors")))
1ee4b312fef0 (grep-default-command): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48197
diff changeset
951 (define-key map [stop-subjob]
48835
750e9e67d3e9 (compilation-menu-map): Use `kill-compilation' to stop compilation.
Markus Rost <rost@math.uni-bielefeld.de>
parents: 48721
diff changeset
952 '("Stop Compilation" . kill-compilation))
48204
1ee4b312fef0 (grep-default-command): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48197
diff changeset
953 (define-key map [compilation-mode-separator2]
1ee4b312fef0 (grep-default-command): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48197
diff changeset
954 '("----" . nil))
53140
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
955 (define-key map [compilation-first-error]
48204
1ee4b312fef0 (grep-default-command): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48197
diff changeset
956 '("First Error" . first-error))
53140
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
957 (define-key map [compilation-previous-error]
48204
1ee4b312fef0 (grep-default-command): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48197
diff changeset
958 '("Previous Error" . previous-error))
53140
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
959 (define-key map [compilation-next-error]
48204
1ee4b312fef0 (grep-default-command): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48197
diff changeset
960 '("Next Error" . next-error))
1ee4b312fef0 (grep-default-command): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48197
diff changeset
961 map))
1ee4b312fef0 (grep-default-command): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48197
diff changeset
962
2603
f80a342fd945 Add compilation-minor-mode to minor-mode-alist and minor-mode-map-alist.
Roland McGrath <roland@gnu.org>
parents: 2478
diff changeset
963 (defvar compilation-minor-mode-map
71
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
964 (let ((map (make-sparse-keymap)))
6595
7fbc171fd1b5 (compile-mouse-goto-error): New command.
Richard M. Stallman <rms@gnu.org>
parents: 6412
diff changeset
965 (define-key map [mouse-2] 'compile-mouse-goto-error)
71
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
966 (define-key map "\C-c\C-c" 'compile-goto-error)
10268
84777124c262 (compilation-minor-mode-map): Bind C-m to compilation-goto-error.
Richard M. Stallman <rms@gnu.org>
parents: 10096
diff changeset
967 (define-key map "\C-m" 'compile-goto-error)
418
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
968 (define-key map "\C-c\C-k" 'kill-compilation)
894
41507a5a8fd7 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 885
diff changeset
969 (define-key map "\M-n" 'compilation-next-error)
41507a5a8fd7 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 885
diff changeset
970 (define-key map "\M-p" 'compilation-previous-error)
946
ef045ff2cb94 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 936
diff changeset
971 (define-key map "\M-{" 'compilation-previous-file)
ef045ff2cb94 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 936
diff changeset
972 (define-key map "\M-}" 'compilation-next-file)
48204
1ee4b312fef0 (grep-default-command): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48197
diff changeset
973 ;; Set up the menu-bar
1ee4b312fef0 (grep-default-command): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48197
diff changeset
974 (define-key map [menu-bar compilation]
1ee4b312fef0 (grep-default-command): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48197
diff changeset
975 (cons "Errors" compilation-menu-map))
71
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
976 map)
2760
1c7595e3089b (Setting minor-mode-map-alist):
Richard M. Stallman <rms@gnu.org>
parents: 2603
diff changeset
977 "Keymap for `compilation-minor-mode'.")
2603
f80a342fd945 Add compilation-minor-mode to minor-mode-alist and minor-mode-map-alist.
Roland McGrath <roland@gnu.org>
parents: 2478
diff changeset
978
17623
a09fd9348b0d Support compilers that give a message each time the file being
Richard M. Stallman <rms@gnu.org>
parents: 17582
diff changeset
979 (defvar compilation-shell-minor-mode-map
a09fd9348b0d Support compilers that give a message each time the file being
Richard M. Stallman <rms@gnu.org>
parents: 17582
diff changeset
980 (let ((map (make-sparse-keymap)))
a09fd9348b0d Support compilers that give a message each time the file being
Richard M. Stallman <rms@gnu.org>
parents: 17582
diff changeset
981 (define-key map [mouse-2] 'compile-mouse-goto-error)
a09fd9348b0d Support compilers that give a message each time the file being
Richard M. Stallman <rms@gnu.org>
parents: 17582
diff changeset
982 (define-key map "\M-\C-m" 'compile-goto-error)
a09fd9348b0d Support compilers that give a message each time the file being
Richard M. Stallman <rms@gnu.org>
parents: 17582
diff changeset
983 (define-key map "\M-\C-n" 'compilation-next-error)
a09fd9348b0d Support compilers that give a message each time the file being
Richard M. Stallman <rms@gnu.org>
parents: 17582
diff changeset
984 (define-key map "\M-\C-p" 'compilation-previous-error)
a09fd9348b0d Support compilers that give a message each time the file being
Richard M. Stallman <rms@gnu.org>
parents: 17582
diff changeset
985 (define-key map "\M-{" 'compilation-previous-file)
a09fd9348b0d Support compilers that give a message each time the file being
Richard M. Stallman <rms@gnu.org>
parents: 17582
diff changeset
986 (define-key map "\M-}" 'compilation-next-file)
a09fd9348b0d Support compilers that give a message each time the file being
Richard M. Stallman <rms@gnu.org>
parents: 17582
diff changeset
987 ;; Set up the menu-bar
48204
1ee4b312fef0 (grep-default-command): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48197
diff changeset
988 (define-key map [menu-bar compilation]
1ee4b312fef0 (grep-default-command): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48197
diff changeset
989 (cons "Errors" compilation-menu-map))
17623
a09fd9348b0d Support compilers that give a message each time the file being
Richard M. Stallman <rms@gnu.org>
parents: 17582
diff changeset
990 map)
a09fd9348b0d Support compilers that give a message each time the file being
Richard M. Stallman <rms@gnu.org>
parents: 17582
diff changeset
991 "Keymap for `compilation-shell-minor-mode'.")
a09fd9348b0d Support compilers that give a message each time the file being
Richard M. Stallman <rms@gnu.org>
parents: 17582
diff changeset
992
2603
f80a342fd945 Add compilation-minor-mode to minor-mode-alist and minor-mode-map-alist.
Roland McGrath <roland@gnu.org>
parents: 2478
diff changeset
993 (defvar compilation-mode-map
48204
1ee4b312fef0 (grep-default-command): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48197
diff changeset
994 (let ((map (make-sparse-keymap)))
1ee4b312fef0 (grep-default-command): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48197
diff changeset
995 (set-keymap-parent map compilation-minor-mode-map)
2603
f80a342fd945 Add compilation-minor-mode to minor-mode-alist and minor-mode-map-alist.
Roland McGrath <roland@gnu.org>
parents: 2478
diff changeset
996 (define-key map " " 'scroll-up)
f80a342fd945 Add compilation-minor-mode to minor-mode-alist and minor-mode-map-alist.
Roland McGrath <roland@gnu.org>
parents: 2478
diff changeset
997 (define-key map "\^?" 'scroll-down)
53140
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
998
8425
8b8835f1630a Set up a "Compile" menubar item.
Richard M. Stallman <rms@gnu.org>
parents: 8406
diff changeset
999 ;; Set up the menu-bar
48204
1ee4b312fef0 (grep-default-command): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48197
diff changeset
1000 (define-key map [menu-bar compilation]
8425
8b8835f1630a Set up a "Compile" menubar item.
Richard M. Stallman <rms@gnu.org>
parents: 8406
diff changeset
1001 (cons "Compile" (make-sparse-keymap "Compile")))
48204
1ee4b312fef0 (grep-default-command): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48197
diff changeset
1002 (define-key map [menu-bar compilation compilation-separator2]
8425
8b8835f1630a Set up a "Compile" menubar item.
Richard M. Stallman <rms@gnu.org>
parents: 8406
diff changeset
1003 '("----" . nil))
53140
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
1004 (define-key map [menu-bar compilation compilation-grep]
20000
ccccaf435fdd (compilation-mode-map): Use more meaningful menu name.
Karl Heuer <kwzh@gnu.org>
parents: 19887
diff changeset
1005 '("Search Files (grep)" . grep))
53140
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
1006 (define-key map [menu-bar compilation compilation-recompile]
8425
8b8835f1630a Set up a "Compile" menubar item.
Richard M. Stallman <rms@gnu.org>
parents: 8406
diff changeset
1007 '("Recompile" . recompile))
53140
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
1008 (define-key map [menu-bar compilation compilation-compile]
17057
e54588a6cea9 Add ... to relevant menu entries.
Simon Marshall <simon@gnu.org>
parents: 17056
diff changeset
1009 '("Compile..." . compile))
2603
f80a342fd945 Add compilation-minor-mode to minor-mode-alist and minor-mode-map-alist.
Roland McGrath <roland@gnu.org>
parents: 2478
diff changeset
1010 map)
f80a342fd945 Add compilation-minor-mode to minor-mode-alist and minor-mode-map-alist.
Roland McGrath <roland@gnu.org>
parents: 2478
diff changeset
1011 "Keymap for compilation log buffers.
48204
1ee4b312fef0 (grep-default-command): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48197
diff changeset
1012 `compilation-minor-mode-map' is a parent of this.")
71
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1013
17653
b7810d4fb620 (compilation-mode): Add a mode-class property.
Richard M. Stallman <rms@gnu.org>
parents: 17639
diff changeset
1014 (put 'compilation-mode 'mode-class 'special)
b7810d4fb620 (compilation-mode): Add a mode-class property.
Richard M. Stallman <rms@gnu.org>
parents: 17639
diff changeset
1015
13755
5f7ea59f14b6 (compilation-mode): Add autoload cookie.
Roland McGrath <roland@gnu.org>
parents: 13540
diff changeset
1016 ;;;###autoload
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1017 (defun compilation-mode ()
71
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1018 "Major mode for compilation log buffers.
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1019 \\<compilation-mode-map>To visit the source for a line-numbered error,
418
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
1020 move point to the error message line and type \\[compile-goto-error].
569
505a9721e442 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 474
diff changeset
1021 To kill the compilation, type \\[kill-compilation].
505a9721e442 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 474
diff changeset
1022
505a9721e442 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 474
diff changeset
1023 Runs `compilation-mode-hook' with `run-hooks' (which see)."
71
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1024 (interactive)
9376
f0ac347309e2 (compilation-mode-font-lock-keywords): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 8976
diff changeset
1025 (kill-all-local-variables)
71
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1026 (use-local-map compilation-mode-map)
2603
f80a342fd945 Add compilation-minor-mode to minor-mode-alist and minor-mode-map-alist.
Roland McGrath <roland@gnu.org>
parents: 2478
diff changeset
1027 (setq major-mode 'compilation-mode
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1028 mode-name "Compilation")
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1029 (set (make-local-variable 'page-delimiter)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1030 compilation-page-delimiter)
2603
f80a342fd945 Add compilation-minor-mode to minor-mode-alist and minor-mode-map-alist.
Roland McGrath <roland@gnu.org>
parents: 2478
diff changeset
1031 (compilation-setup)
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1032 (run-mode-hooks 'compilation-mode-hook))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1033
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1034 (defmacro define-compilation-mode (mode name doc &rest body)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1035 "This is like `define-derived-mode' without the PARENT argument.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1036 The parent is always `compilation-mode' and the customizable `compilation-...'
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1037 variables are also set from the name of the mode you have chosen, by replacing
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1038 the fist word, e.g `compilation-scroll-output' from `grep-scroll-output' if that
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1039 variable exists."
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1040 (let ((mode-name (replace-regexp-in-string "-mode\\'" "" (symbol-name mode))))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1041 `(define-derived-mode ,mode compilation-mode ,name
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1042 ,doc
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1043 ,@(mapcar (lambda (v)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1044 (setq v (cons v
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1045 (intern-soft (replace-regexp-in-string
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1046 "^compilation" mode-name
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1047 (symbol-name v)))))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1048 (and (cdr v)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1049 (or (boundp (cdr v))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1050 (if (boundp 'byte-compile-bound-variables)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1051 (memq (cdr v) byte-compile-bound-variables)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1052 `(set (make-local-variable ',(car v)) ,(cdr v))))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1053 '(compilation-buffer-name-function
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1054 compilation-directory-matcher
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1055 compilation-error
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1056 compilation-error-regexp-alist
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1057 compilation-error-regexp-alist-alist
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1058 compilation-error-screen-columns
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1059 compilation-finish-function
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1060 compilation-finish-functions
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1061 compilation-first-column
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1062 compilation-mode-font-lock-keywords
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1063 compilation-page-delimiter
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1064 compilation-parse-errors-filename-function
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1065 compilation-process-setup-function
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1066 compilation-scroll-output
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1067 compilation-search-path
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1068 compilation-skip-threshold
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1069 compilation-window-height))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1070 ,@body)))
2603
f80a342fd945 Add compilation-minor-mode to minor-mode-alist and minor-mode-map-alist.
Roland McGrath <roland@gnu.org>
parents: 2478
diff changeset
1071
17866
7d458582345c (compilation-parse-errors): Fix paren error.
Richard M. Stallman <rms@gnu.org>
parents: 17653
diff changeset
1072 (defun compilation-revert-buffer (ignore-auto noconfirm)
49186
ce4ad428dcab (compilation-revert-buffer): If buffer has a file, revert it in the normal way.
Richard M. Stallman <rms@gnu.org>
parents: 48844
diff changeset
1073 (if buffer-file-name
ce4ad428dcab (compilation-revert-buffer): If buffer has a file, revert it in the normal way.
Richard M. Stallman <rms@gnu.org>
parents: 48844
diff changeset
1074 (let (revert-buffer-function)
53140
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
1075 (revert-buffer ignore-auto noconfirm))
49186
ce4ad428dcab (compilation-revert-buffer): If buffer has a file, revert it in the normal way.
Richard M. Stallman <rms@gnu.org>
parents: 48844
diff changeset
1076 (if (or noconfirm (yes-or-no-p (format "Restart compilation? ")))
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1077 (apply 'compilation-start compilation-arguments))))
17866
7d458582345c (compilation-parse-errors): Fix paren error.
Richard M. Stallman <rms@gnu.org>
parents: 17653
diff changeset
1078
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1079 ;; A function name can't be a hook, must be something with a value.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1080 (defconst compilation-turn-on-font-lock 'turn-on-font-lock)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1081
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1082 (defun compilation-setup (&optional minor)
26222
35c7eab893ab Checkdoc-inspired fixes.
Dave Love <fx@gnu.org>
parents: 25623
diff changeset
1083 "Prepare the buffer for the compilation parsing commands to work."
30688
f0a91dd9685b (compilation-setup): Make variable
Gerd Moellmann <gerd@gnu.org>
parents: 29121
diff changeset
1084 (make-local-variable 'compilation-error-screen-columns)
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1085 (setq compilation-last-buffer (current-buffer))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1086 (if minor
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1087 (if font-lock-defaults
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1088 (font-lock-add-keywords nil (compilation-mode-font-lock-keywords))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1089 (set (make-local-variable 'font-lock-defaults)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1090 '(compilation-mode-font-lock-keywords t)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1091 (set (make-local-variable 'font-lock-defaults)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1092 '(compilation-mode-font-lock-keywords t)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1093 (set (make-local-variable 'font-lock-extra-managed-props)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1094 '(directory message help-echo mouse-face debug))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1095 (set (make-local-variable 'compilation-locs)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1096 (make-hash-table :test 'equal :weakness 'value))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1097 ;; lazy-lock would never find the message unless it's scrolled to
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1098 ;; jit-lock might fontify some things too late
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1099 (if (font-lock-value-in-major-mode font-lock-support-mode)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1100 (set (make-local-variable 'font-lock-support-mode) nil))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1101 (set (make-local-variable 'font-lock-maximum-size) nil)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1102 (if minor
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1103 (if font-lock-mode
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1104 (font-lock-fontify-buffer)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1105 (turn-on-font-lock))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1106 ;; maybe defer font-lock till after derived mode is set up
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1107 (run-mode-hooks 'compilation-turn-on-font-lock)))
2603
f80a342fd945 Add compilation-minor-mode to minor-mode-alist and minor-mode-map-alist.
Roland McGrath <roland@gnu.org>
parents: 2478
diff changeset
1108
48204
1ee4b312fef0 (grep-default-command): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48197
diff changeset
1109 ;;;###autoload
1ee4b312fef0 (grep-default-command): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48197
diff changeset
1110 (define-minor-mode compilation-shell-minor-mode
1ee4b312fef0 (grep-default-command): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48197
diff changeset
1111 "Toggle compilation shell minor mode.
1ee4b312fef0 (grep-default-command): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48197
diff changeset
1112 With arg, turn compilation mode on if and only if arg is positive.
17623
a09fd9348b0d Support compilers that give a message each time the file being
Richard M. Stallman <rms@gnu.org>
parents: 17582
diff changeset
1113 In this minor mode, all the error-parsing commands of the
a09fd9348b0d Support compilers that give a message each time the file being
Richard M. Stallman <rms@gnu.org>
parents: 17582
diff changeset
1114 Compilation major mode are available but bound to keys that don't
48204
1ee4b312fef0 (grep-default-command): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48197
diff changeset
1115 collide with Shell mode. See `compilation-mode'.
1ee4b312fef0 (grep-default-command): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48197
diff changeset
1116 Turning the mode on runs the normal hook `compilation-shell-minor-mode-hook'."
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1117 nil " Shell-Compile"
48400
e57b9088b4a1 (compilation-shell-minor-mode): Add group.
Markus Rost <rost@math.uni-bielefeld.de>
parents: 48279
diff changeset
1118 :group 'compilation
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1119 (if compilation-shell-minor-mode
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1120 (compilation-setup t)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1121 (font-lock-remove-keywords nil (compilation-mode-font-lock-keywords))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1122 (font-lock-fontify-buffer)))
2603
f80a342fd945 Add compilation-minor-mode to minor-mode-alist and minor-mode-map-alist.
Roland McGrath <roland@gnu.org>
parents: 2478
diff changeset
1123
4445
a1e412873732 (compilation-minor-mode): Make variable buffer-local.
Roland McGrath <roland@gnu.org>
parents: 4350
diff changeset
1124 ;;;###autoload
48204
1ee4b312fef0 (grep-default-command): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48197
diff changeset
1125 (define-minor-mode compilation-minor-mode
2603
f80a342fd945 Add compilation-minor-mode to minor-mode-alist and minor-mode-map-alist.
Roland McGrath <roland@gnu.org>
parents: 2478
diff changeset
1126 "Toggle compilation minor mode.
f80a342fd945 Add compilation-minor-mode to minor-mode-alist and minor-mode-map-alist.
Roland McGrath <roland@gnu.org>
parents: 2478
diff changeset
1127 With arg, turn compilation mode on if and only if arg is positive.
48204
1ee4b312fef0 (grep-default-command): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48197
diff changeset
1128 In this minor mode, all the error-parsing commands of the
1ee4b312fef0 (grep-default-command): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48197
diff changeset
1129 Compilation major mode are available. See `compilation-mode'.
14607
3c86ac6a871a (compilation-minor-mode): Run compilation-minor-mode-hook.
Roland McGrath <roland@gnu.org>
parents: 14562
diff changeset
1130 Turning the mode on runs the normal hook `compilation-minor-mode-hook'."
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1131 nil " Compilation"
48400
e57b9088b4a1 (compilation-shell-minor-mode): Add group.
Markus Rost <rost@math.uni-bielefeld.de>
parents: 48279
diff changeset
1132 :group 'compilation
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1133 (if compilation-minor-mode
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1134 (compilation-setup t)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1135 (font-lock-remove-keywords nil (compilation-mode-font-lock-keywords))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1136 (font-lock-fontify-buffer)))
71
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1137
14045
1300c7703f67 (compilation-handle-exit): New function, broken out of compilation-sentinel.
Roland McGrath <roland@gnu.org>
parents: 13972
diff changeset
1138 (defun compilation-handle-exit (process-status exit-status msg)
26222
35c7eab893ab Checkdoc-inspired fixes.
Dave Love <fx@gnu.org>
parents: 25623
diff changeset
1139 "Write msg in the current buffer and hack its mode-line-process."
14045
1300c7703f67 (compilation-handle-exit): New function, broken out of compilation-sentinel.
Roland McGrath <roland@gnu.org>
parents: 13972
diff changeset
1140 (let ((buffer-read-only nil)
1300c7703f67 (compilation-handle-exit): New function, broken out of compilation-sentinel.
Roland McGrath <roland@gnu.org>
parents: 13972
diff changeset
1141 (status (if compilation-exit-message-function
1300c7703f67 (compilation-handle-exit): New function, broken out of compilation-sentinel.
Roland McGrath <roland@gnu.org>
parents: 13972
diff changeset
1142 (funcall compilation-exit-message-function
1300c7703f67 (compilation-handle-exit): New function, broken out of compilation-sentinel.
Roland McGrath <roland@gnu.org>
parents: 13972
diff changeset
1143 process-status exit-status msg)
1300c7703f67 (compilation-handle-exit): New function, broken out of compilation-sentinel.
Roland McGrath <roland@gnu.org>
parents: 13972
diff changeset
1144 (cons msg exit-status)))
1300c7703f67 (compilation-handle-exit): New function, broken out of compilation-sentinel.
Roland McGrath <roland@gnu.org>
parents: 13972
diff changeset
1145 (omax (point-max))
1300c7703f67 (compilation-handle-exit): New function, broken out of compilation-sentinel.
Roland McGrath <roland@gnu.org>
parents: 13972
diff changeset
1146 (opoint (point)))
1300c7703f67 (compilation-handle-exit): New function, broken out of compilation-sentinel.
Roland McGrath <roland@gnu.org>
parents: 13972
diff changeset
1147 ;; Record where we put the message, so we can ignore it
1300c7703f67 (compilation-handle-exit): New function, broken out of compilation-sentinel.
Roland McGrath <roland@gnu.org>
parents: 13972
diff changeset
1148 ;; later on.
1300c7703f67 (compilation-handle-exit): New function, broken out of compilation-sentinel.
Roland McGrath <roland@gnu.org>
parents: 13972
diff changeset
1149 (goto-char omax)
1300c7703f67 (compilation-handle-exit): New function, broken out of compilation-sentinel.
Roland McGrath <roland@gnu.org>
parents: 13972
diff changeset
1150 (insert ?\n mode-name " " (car status))
44209
9501986a69c8 (compilation-handle-exit):
Richard M. Stallman <rms@gnu.org>
parents: 44139
diff changeset
1151 (if (and (numberp compilation-window-height)
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1152 (zerop compilation-window-height))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1153 (message "%s" (cdr status)))
24558
ea8a9509b52f (compilation-handle-exit): Do right thing
Richard M. Stallman <rms@gnu.org>
parents: 24326
diff changeset
1154 (if (bolp)
ea8a9509b52f (compilation-handle-exit): Do right thing
Richard M. Stallman <rms@gnu.org>
parents: 24326
diff changeset
1155 (forward-char -1))
14045
1300c7703f67 (compilation-handle-exit): New function, broken out of compilation-sentinel.
Roland McGrath <roland@gnu.org>
parents: 13972
diff changeset
1156 (insert " at " (substring (current-time-string) 0 19))
24558
ea8a9509b52f (compilation-handle-exit): Do right thing
Richard M. Stallman <rms@gnu.org>
parents: 24326
diff changeset
1157 (goto-char (point-max))
42939
0786ea38f9fd (compilation-handle-exit):
Richard M. Stallman <rms@gnu.org>
parents: 42408
diff changeset
1158 ;; Prevent that message from being recognized as a compilation error.
0786ea38f9fd (compilation-handle-exit):
Richard M. Stallman <rms@gnu.org>
parents: 42408
diff changeset
1159 (add-text-properties omax (point)
0786ea38f9fd (compilation-handle-exit):
Richard M. Stallman <rms@gnu.org>
parents: 42408
diff changeset
1160 (append '(compilation-handle-exit t) nil))
14260
4577848d3ef2 (compilation-handle-exit): Undo previous change.
Karl Heuer <kwzh@gnu.org>
parents: 14250
diff changeset
1161 (setq mode-line-process (format ":%s [%s]" process-status (cdr status)))
14045
1300c7703f67 (compilation-handle-exit): New function, broken out of compilation-sentinel.
Roland McGrath <roland@gnu.org>
parents: 13972
diff changeset
1162 ;; Force mode line redisplay soon.
1300c7703f67 (compilation-handle-exit): New function, broken out of compilation-sentinel.
Roland McGrath <roland@gnu.org>
parents: 13972
diff changeset
1163 (force-mode-line-update)
1300c7703f67 (compilation-handle-exit): New function, broken out of compilation-sentinel.
Roland McGrath <roland@gnu.org>
parents: 13972
diff changeset
1164 (if (and opoint (< opoint omax))
1300c7703f67 (compilation-handle-exit): New function, broken out of compilation-sentinel.
Roland McGrath <roland@gnu.org>
parents: 13972
diff changeset
1165 (goto-char opoint))
1300c7703f67 (compilation-handle-exit): New function, broken out of compilation-sentinel.
Roland McGrath <roland@gnu.org>
parents: 13972
diff changeset
1166 (if compilation-finish-function
16042
18414e324084 (compilation-finish-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15084
diff changeset
1167 (funcall compilation-finish-function (current-buffer) msg))
18414e324084 (compilation-finish-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15084
diff changeset
1168 (let ((functions compilation-finish-functions))
18414e324084 (compilation-finish-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15084
diff changeset
1169 (while functions
18414e324084 (compilation-finish-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15084
diff changeset
1170 (funcall (car functions) (current-buffer) msg)
18414e324084 (compilation-finish-functions): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15084
diff changeset
1171 (setq functions (cdr functions))))))
14045
1300c7703f67 (compilation-handle-exit): New function, broken out of compilation-sentinel.
Roland McGrath <roland@gnu.org>
parents: 13972
diff changeset
1172
71
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1173 ;; Called when compilation process changes state.
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1174 (defun compilation-sentinel (proc msg)
418
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
1175 "Sentinel for compilation buffers."
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
1176 (let ((buffer (process-buffer proc)))
740
b39d858a0b19 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 732
diff changeset
1177 (if (memq (process-status proc) '(signal exit))
b39d858a0b19 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 732
diff changeset
1178 (progn
b39d858a0b19 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 732
diff changeset
1179 (if (null (buffer-name buffer))
b39d858a0b19 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 732
diff changeset
1180 ;; buffer killed
b39d858a0b19 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 732
diff changeset
1181 (set-process-buffer proc nil)
14045
1300c7703f67 (compilation-handle-exit): New function, broken out of compilation-sentinel.
Roland McGrath <roland@gnu.org>
parents: 13972
diff changeset
1182 (let ((obuf (current-buffer)))
740
b39d858a0b19 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 732
diff changeset
1183 ;; save-excursion isn't the right thing if
b39d858a0b19 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 732
diff changeset
1184 ;; process-buffer is current-buffer
b39d858a0b19 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 732
diff changeset
1185 (unwind-protect
b39d858a0b19 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 732
diff changeset
1186 (progn
b39d858a0b19 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 732
diff changeset
1187 ;; Write something in the compilation buffer
b39d858a0b19 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 732
diff changeset
1188 ;; and hack its mode line.
b39d858a0b19 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 732
diff changeset
1189 (set-buffer buffer)
14045
1300c7703f67 (compilation-handle-exit): New function, broken out of compilation-sentinel.
Roland McGrath <roland@gnu.org>
parents: 13972
diff changeset
1190 (compilation-handle-exit (process-status proc)
1300c7703f67 (compilation-handle-exit): New function, broken out of compilation-sentinel.
Roland McGrath <roland@gnu.org>
parents: 13972
diff changeset
1191 (process-exit-status proc)
1300c7703f67 (compilation-handle-exit): New function, broken out of compilation-sentinel.
Roland McGrath <roland@gnu.org>
parents: 13972
diff changeset
1192 msg)
1300c7703f67 (compilation-handle-exit): New function, broken out of compilation-sentinel.
Roland McGrath <roland@gnu.org>
parents: 13972
diff changeset
1193 ;; Since the buffer and mode line will show that the
1300c7703f67 (compilation-handle-exit): New function, broken out of compilation-sentinel.
Roland McGrath <roland@gnu.org>
parents: 13972
diff changeset
1194 ;; process is dead, we can delete it now. Otherwise it
1300c7703f67 (compilation-handle-exit): New function, broken out of compilation-sentinel.
Roland McGrath <roland@gnu.org>
parents: 13972
diff changeset
1195 ;; will stay around until M-x list-processes.
1300c7703f67 (compilation-handle-exit): New function, broken out of compilation-sentinel.
Roland McGrath <roland@gnu.org>
parents: 13972
diff changeset
1196 (delete-process proc))
1133
f36b965cfeb0 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1072
diff changeset
1197 (set-buffer obuf))))
740
b39d858a0b19 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 732
diff changeset
1198 (setq compilation-in-progress (delq proc compilation-in-progress))
b39d858a0b19 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 732
diff changeset
1199 ))))
71
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1200
2472
f911936cec3f (compilation-filter): New function.
Roland McGrath <roland@gnu.org>
parents: 2471
diff changeset
1201 (defun compilation-filter (proc string)
f911936cec3f (compilation-filter): New function.
Roland McGrath <roland@gnu.org>
parents: 2471
diff changeset
1202 "Process filter for compilation buffers.
2760
1c7595e3089b (Setting minor-mode-map-alist):
Richard M. Stallman <rms@gnu.org>
parents: 2603
diff changeset
1203 Just inserts the text, but uses `insert-before-markers'."
9511
3b5dbd9c44f5 (compilation-filter): Do nothing if buffer is dead.
Richard M. Stallman <rms@gnu.org>
parents: 9473
diff changeset
1204 (if (buffer-name (process-buffer proc))
2472
f911936cec3f (compilation-filter): New function.
Roland McGrath <roland@gnu.org>
parents: 2471
diff changeset
1205 (save-excursion
9511
3b5dbd9c44f5 (compilation-filter): Do nothing if buffer is dead.
Richard M. Stallman <rms@gnu.org>
parents: 9473
diff changeset
1206 (set-buffer (process-buffer proc))
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1207 (let ((buffer-read-only nil))
9511
3b5dbd9c44f5 (compilation-filter): Do nothing if buffer is dead.
Richard M. Stallman <rms@gnu.org>
parents: 9473
diff changeset
1208 (save-excursion
3b5dbd9c44f5 (compilation-filter): Do nothing if buffer is dead.
Richard M. Stallman <rms@gnu.org>
parents: 9473
diff changeset
1209 (goto-char (process-mark proc))
3b5dbd9c44f5 (compilation-filter): Do nothing if buffer is dead.
Richard M. Stallman <rms@gnu.org>
parents: 9473
diff changeset
1210 (insert-before-markers string)
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1211 (run-hooks 'compilation-filter-hook))))))
920
7b984ce24013 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 907
diff changeset
1212
5472
ed690a728e13 (compilation-buffer-p): Move defsubst before all callers.
Roland McGrath <roland@gnu.org>
parents: 5456
diff changeset
1213 (defsubst compilation-buffer-p (buffer)
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1214 (local-variable-p 'compilation-locs buffer))
5472
ed690a728e13 (compilation-buffer-p): Move defsubst before all callers.
Roland McGrath <roland@gnu.org>
parents: 5456
diff changeset
1215
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1216 (defmacro compilation-loop (< property-change 1+ error)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1217 `(while (,< n 0)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1218 (or (setq pt (,property-change pt 'message))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1219 (error ,error compilation-error))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1220 ;; prop 'message usually has 2 changes, on and off, so re-search if off
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1221 (or (setq msg (get-text-property pt 'message))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1222 (if (setq pt (,property-change pt 'message))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1223 (setq msg (get-text-property pt 'message)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1224 (error ,error compilation-error))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1225 (or (< (cadr msg) compilation-skip-threshold)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1226 (if different-file
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1227 (eq (prog1 last (setq last (nth 2 (car msg))))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1228 last))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1229 (if compilation-skip-visited
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1230 (nthcdr 4 (car msg)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1231 (if compilation-skip-to-next-location
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1232 (eq (car msg) loc))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1233 ;; count this message only if none of the above are true
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1234 (setq n (,1+ n)))))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1235
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1236 (defun compilation-next-error (n &optional different-file)
894
41507a5a8fd7 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 885
diff changeset
1237 "Move point to the next error in the compilation buffer.
26222
35c7eab893ab Checkdoc-inspired fixes.
Dave Love <fx@gnu.org>
parents: 25623
diff changeset
1238 Prefix arg N says how many error messages to move forwards (or
35c7eab893ab Checkdoc-inspired fixes.
Dave Love <fx@gnu.org>
parents: 25623
diff changeset
1239 backwards, if negative).
894
41507a5a8fd7 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 885
diff changeset
1240 Does NOT find the source line like \\[next-error]."
41507a5a8fd7 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 885
diff changeset
1241 (interactive "p")
41507a5a8fd7 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 885
diff changeset
1242 (or (compilation-buffer-p (current-buffer))
26222
35c7eab893ab Checkdoc-inspired fixes.
Dave Love <fx@gnu.org>
parents: 25623
diff changeset
1243 (error "Not in a compilation buffer"))
894
41507a5a8fd7 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 885
diff changeset
1244 (setq compilation-last-buffer (current-buffer))
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1245 (let* ((pt (point))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1246 (msg (get-text-property pt 'message))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1247 (loc (car msg))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1248 last)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1249 (if (zerop n)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1250 (unless (or msg ; find message near here
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1251 (setq msg (get-text-property (max (1- pt) 1) 'message)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1252 (setq pt (previous-single-property-change pt 'message nil
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1253 (save-excursion
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1254 (beginning-of-line)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1255 (point))))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1256 (if pt
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1257 (setq msg (get-text-property (max (1- pt) 1) 'message))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1258 (setq pt (next-single-property-change pt 'message nil
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1259 (save-excursion
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1260 (end-of-line)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1261 (point))))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1262 (if pt
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1263 (setq msg (get-text-property pt 'message))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1264 (setq pt (point)))))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1265 (setq last (nth 2 (car msg)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1266 ;; These loops search only either forwards or backwards
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1267 (compilation-loop > next-single-property-change 1-
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1268 (if (get-buffer-process (current-buffer))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1269 "No more %ss yet"
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1270 "Moved past last %s"))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1271 (compilation-loop < previous-single-property-change 1+
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1272 "Moved back before first %s"))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1273 (goto-char pt)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1274 (or msg
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1275 (error "No %s here" compilation-error))))
894
41507a5a8fd7 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 885
diff changeset
1276
41507a5a8fd7 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 885
diff changeset
1277 (defun compilation-previous-error (n)
41507a5a8fd7 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 885
diff changeset
1278 "Move point to the previous error in the compilation buffer.
26222
35c7eab893ab Checkdoc-inspired fixes.
Dave Love <fx@gnu.org>
parents: 25623
diff changeset
1279 Prefix arg N says how many error messages to move backwards (or
35c7eab893ab Checkdoc-inspired fixes.
Dave Love <fx@gnu.org>
parents: 25623
diff changeset
1280 forwards, if negative).
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1281 Does NOT find the source line like \\[previous-error]."
894
41507a5a8fd7 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 885
diff changeset
1282 (interactive "p")
41507a5a8fd7 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 885
diff changeset
1283 (compilation-next-error (- n)))
41507a5a8fd7 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 885
diff changeset
1284
53140
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
1285 (defun next-error-no-select (n)
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
1286 "Move point to the next error in the compilation buffer and highlight match.
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
1287 Prefix arg N says how many error messages to move forwards.
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
1288 Finds and highlights the source line like \\[next-error], but does not
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
1289 select the source buffer."
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
1290 (interactive "p")
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
1291 (next-error n)
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
1292 (pop-to-buffer compilation-last-buffer))
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
1293
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
1294 (defun previous-error-no-select (n)
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
1295 "Move point to the previous error in the compilation buffer and highlight match.
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
1296 Prefix arg N says how many error messages to move forwards.
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1297 Finds and highlights the source line like \\[previous-error], but does not
53140
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
1298 select the source buffer."
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
1299 (interactive "p")
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1300 (next-error-no-select (- n)))
4153
787df5416fba (compilation-error-list): An elt's cdr's car is again a cons (DIRECTORY .
Roland McGrath <roland@gnu.org>
parents: 4093
diff changeset
1301
920
7b984ce24013 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 907
diff changeset
1302 (defun compilation-next-file (n)
7b984ce24013 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 907
diff changeset
1303 "Move point to the next error for a different file than the current one."
7b984ce24013 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 907
diff changeset
1304 (interactive "p")
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1305 (compilation-next-error n t))
920
7b984ce24013 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 907
diff changeset
1306
7b984ce24013 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 907
diff changeset
1307 (defun compilation-previous-file (n)
7b984ce24013 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 907
diff changeset
1308 "Move point to the previous error for a different file than the current one."
7b984ce24013 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 907
diff changeset
1309 (interactive "p")
7b984ce24013 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 907
diff changeset
1310 (compilation-next-file (- n)))
7b984ce24013 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 907
diff changeset
1311
71
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1312 (defun kill-compilation ()
45582
08fe4d419957 Modified doc string to say that the kill-compilation function also
Robert J. Chassell <bob@rattlesnake.com>
parents: 45215
diff changeset
1313 "Kill the process made by the \\[compile] or \\[grep] commands."
71
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1314 (interactive)
418
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
1315 (let ((buffer (compilation-find-buffer)))
71
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1316 (if (get-buffer-process buffer)
418
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
1317 (interrupt-process (get-buffer-process buffer))
26222
35c7eab893ab Checkdoc-inspired fixes.
Dave Love <fx@gnu.org>
parents: 25623
diff changeset
1318 (error "The compilation process is not running"))))
71
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1319
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1320 (defun compile-mouse-goto-error (event)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1321 "Visit the source for the error message the mouse is pointing at."
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1322 (interactive "e")
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1323 (mouse-set-point event)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1324 (if (get-text-property (point) 'directory)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1325 (dired-other-window (car (get-text-property (point) 'directory)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1326 (next-error 0)))
418
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
1327
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1328 (defun compile-goto-error ()
71
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1329 "Visit the source for the error message point is on.
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1330 Use this command in a compilation log buffer. Sets the mark at point there."
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1331 (interactive)
418
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
1332 (or (compilation-buffer-p (current-buffer))
26222
35c7eab893ab Checkdoc-inspired fixes.
Dave Love <fx@gnu.org>
parents: 25623
diff changeset
1333 (error "Not in a compilation buffer"))
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1334 (if (get-text-property (point) 'directory)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1335 (dired-other-window (car (get-text-property (point) 'directory)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1336 (push-mark)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1337 (next-error 0)))
71
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1338
418
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
1339 ;; Return a compilation buffer.
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
1340 ;; If the current buffer is a compilation buffer, return it.
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
1341 ;; If compilation-last-buffer is set to a live buffer, use that.
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
1342 ;; Otherwise, look for a compilation buffer and signal an error
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
1343 ;; if there are none.
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 569
diff changeset
1344 (defun compilation-find-buffer (&optional other-buffer)
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 569
diff changeset
1345 (if (and (not other-buffer)
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 569
diff changeset
1346 (compilation-buffer-p (current-buffer)))
418
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
1347 ;; The current buffer is a compilation buffer.
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
1348 (current-buffer)
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 569
diff changeset
1349 (if (and compilation-last-buffer (buffer-name compilation-last-buffer)
14807
db1942b2425e (compilation-find-buffer): Only choose compilation-last-buffer if it is
Roland McGrath <roland@gnu.org>
parents: 14730
diff changeset
1350 (compilation-buffer-p compilation-last-buffer)
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 569
diff changeset
1351 (or (not other-buffer) (not (eq compilation-last-buffer
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 569
diff changeset
1352 (current-buffer)))))
418
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
1353 compilation-last-buffer
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
1354 (let ((buffers (buffer-list)))
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 569
diff changeset
1355 (while (and buffers (or (not (compilation-buffer-p (car buffers)))
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 569
diff changeset
1356 (and other-buffer
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 569
diff changeset
1357 (eq (car buffers) (current-buffer)))))
418
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
1358 (setq buffers (cdr buffers)))
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
1359 (if buffers
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
1360 (car buffers)
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 569
diff changeset
1361 (or (and other-buffer
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 569
diff changeset
1362 (compilation-buffer-p (current-buffer))
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 569
diff changeset
1363 ;; The current buffer is a compilation buffer.
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 569
diff changeset
1364 (progn
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 569
diff changeset
1365 (if other-buffer
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 569
diff changeset
1366 (message "This is the only compilation buffer."))
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 569
diff changeset
1367 (current-buffer)))
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 569
diff changeset
1368 (error "No compilation started!")))))))
418
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
1369
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
1370 ;;;###autoload
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1371 (defun next-error (n)
71
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1372 "Visit next compilation error message and corresponding source code.
22966
77b190eb087b (next-error): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 22787
diff changeset
1373
30878
13a1a0ec31e5 (grep): Provide a default set of files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30688
diff changeset
1374 A prefix ARGP specifies how many error messages to move;
71
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1375 negative means move back to previous error messages.
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1376
22966
77b190eb087b (next-error): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 22787
diff changeset
1377 \\[next-error] normally uses the most recently started compilation or
77b190eb087b (next-error): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 22787
diff changeset
1378 grep buffer. However, it can operate on any buffer with output from
77b190eb087b (next-error): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 22787
diff changeset
1379 the \\[compile] and \\[grep] commands, or, more generally, on any
77b190eb087b (next-error): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 22787
diff changeset
1380 buffer in Compilation mode or with Compilation Minor mode enabled. To
77b190eb087b (next-error): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 22787
diff changeset
1381 specify use of a particular buffer for error messages, type
77b190eb087b (next-error): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 22787
diff changeset
1382 \\[next-error] in that buffer.
71
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1383
22966
77b190eb087b (next-error): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 22787
diff changeset
1384 Once \\[next-error] has chosen the buffer for error messages,
77b190eb087b (next-error): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 22787
diff changeset
1385 it stays with that buffer until you use it in some other buffer which
77b190eb087b (next-error): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 22787
diff changeset
1386 uses Compilation mode or Compilation Minor mode.
71
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1387
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1388 See variable `compilation-error-regexp-alist' for customization ideas."
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1389 (interactive "p")
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1390 (set-buffer (setq compilation-last-buffer (compilation-find-buffer)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1391 (let* ((columns compilation-error-screen-columns) ; buffer's local value
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1392 (last 1)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1393 (loc (compilation-next-error n))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1394 (end-loc (nth 2 loc))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1395 (marker (point-marker)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1396 (setq loc (car loc))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1397 ;; If loc contains no marker, no error in that file has been visited. If
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1398 ;; the marker is invalid the buffer has been killed. So, recalculate all
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1399 ;; markers for that file.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1400 (unless (and (nthcdr 3 loc) (marker-buffer (nth 3 loc)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1401 (save-excursion
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1402 (set-buffer (compilation-find-file marker (caar (nth 2 loc))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1403 (or (cdar (nth 2 loc))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1404 default-directory)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1405 (save-restriction
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1406 (widen)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1407 (goto-char 1)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1408 ;; Treat file's found lines in forward order, 1 by 1.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1409 (dolist (line (reverse (cddr (nth 2 loc))))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1410 (when (car line) ; else this is a filename w/o a line#
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1411 (beginning-of-line (- (car line) last -1))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1412 (setq last (car line)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1413 ;; Treat line's found columns and store/update a marker for each.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1414 (dolist (col (cdr line))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1415 (if (car col)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1416 (if (eq (car col) -1) ; special case for range end
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1417 (end-of-line)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1418 (if columns
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1419 (move-to-column (car col))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1420 (beginning-of-line)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1421 (forward-char (car col))))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1422 (beginning-of-line)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1423 (skip-chars-forward " \t"))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1424 (if (nthcdr 3 col)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1425 (set-marker (nth 3 col) (point))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1426 (setcdr (nthcdr 2 col) `(,(point-marker)))))))))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1427 (compilation-goto-locus marker (nth 3 loc) (nth 3 end-loc))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1428 (setcdr (nthcdr 3 loc) t))) ; Set this one as visited.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1429
6240
5ce2192f76e1 (compile-reinitialize-errors): Rename first arg from ARGP to REPARSE.
Roland McGrath <roland@gnu.org>
parents: 6197
diff changeset
1430 ;;;###autoload (define-key ctl-x-map "`" 'next-error)
5ce2192f76e1 (compile-reinitialize-errors): Rename first arg from ARGP to REPARSE.
Roland McGrath <roland@gnu.org>
parents: 6197
diff changeset
1431
52394
1c091699d00e (previous-error): Accept a prefix argument, similarly to next-error.
Eli Zaretskii <eliz@gnu.org>
parents: 52219
diff changeset
1432 (defun previous-error (argp)
8425
8b8835f1630a Set up a "Compile" menubar item.
Richard M. Stallman <rms@gnu.org>
parents: 8406
diff changeset
1433 "Visit previous compilation error message and corresponding source code.
52394
1c091699d00e (previous-error): Accept a prefix argument, similarly to next-error.
Eli Zaretskii <eliz@gnu.org>
parents: 52219
diff changeset
1434
1c091699d00e (previous-error): Accept a prefix argument, similarly to next-error.
Eli Zaretskii <eliz@gnu.org>
parents: 52219
diff changeset
1435 A prefix ARGP specifies how many error messages to move;
1c091699d00e (previous-error): Accept a prefix argument, similarly to next-error.
Eli Zaretskii <eliz@gnu.org>
parents: 52219
diff changeset
1436 negative means move forward to next error messages.
1c091699d00e (previous-error): Accept a prefix argument, similarly to next-error.
Eli Zaretskii <eliz@gnu.org>
parents: 52219
diff changeset
1437
1c091699d00e (previous-error): Accept a prefix argument, similarly to next-error.
Eli Zaretskii <eliz@gnu.org>
parents: 52219
diff changeset
1438 This operates on the output from the \\[compile] and \\[grep] commands."
1c091699d00e (previous-error): Accept a prefix argument, similarly to next-error.
Eli Zaretskii <eliz@gnu.org>
parents: 52219
diff changeset
1439 (interactive "P")
1c091699d00e (previous-error): Accept a prefix argument, similarly to next-error.
Eli Zaretskii <eliz@gnu.org>
parents: 52219
diff changeset
1440 (next-error (- (prefix-numeric-value argp))))
8425
8b8835f1630a Set up a "Compile" menubar item.
Richard M. Stallman <rms@gnu.org>
parents: 8406
diff changeset
1441
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1442 (defun first-error (arg)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1443 "Restart at the first error.
8425
8b8835f1630a Set up a "Compile" menubar item.
Richard M. Stallman <rms@gnu.org>
parents: 8406
diff changeset
1444 Visit corresponding source code.
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1445 With prefix ARG, visit the source code of the ARGth error.
8425
8b8835f1630a Set up a "Compile" menubar item.
Richard M. Stallman <rms@gnu.org>
parents: 8406
diff changeset
1446 This operates on the output from the \\[compile] command."
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1447 (interactive "p")
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1448 (set-buffer (setq compilation-last-buffer (compilation-find-buffer)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1449 (goto-char (point-min))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1450 (next-error arg))
8425
8b8835f1630a Set up a "Compile" menubar item.
Richard M. Stallman <rms@gnu.org>
parents: 8406
diff changeset
1451
16448
39556b6d7c6e (compilation-skip-to-next-location): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 16042
diff changeset
1452 (defvar compilation-skip-to-next-location nil
39556b6d7c6e (compilation-skip-to-next-location): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 16042
diff changeset
1453 "*If non-nil, skip multiple error messages for the same source location.")
39556b6d7c6e (compilation-skip-to-next-location): Defined.
Karl Heuer <kwzh@gnu.org>
parents: 16042
diff changeset
1454
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1455 (defcustom compilation-skip-threshold 1
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1456 "*Compilation motion commands skip less important messages.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1457 The value can be either 2 -- skip anything less than error, 1 --
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1458 skip anything less than warning or 0 -- don't skip any messages.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1459 Note that all messages not positively identified as warning or
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1460 info, are considered errors."
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1461 :type '(choice (const :tag "Warnings and info" 2)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1462 (const :tag "Info" 1)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1463 (const :tag "None" 0))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1464 :group 'compilation)
6240
5ce2192f76e1 (compile-reinitialize-errors): Rename first arg from ARGP to REPARSE.
Roland McGrath <roland@gnu.org>
parents: 6197
diff changeset
1465
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1466 (defcustom compilation-skip-visited nil
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1467 "*Compilation motion commands skip visited messages if this is t.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1468 Visited messages are ones for which the file, line and column have been jumped
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1469 to from the current content in the current compilation buffer, even if it was
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1470 from a different message."
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1471 :type 'boolean
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1472 :group 'compilation)
6240
5ce2192f76e1 (compile-reinitialize-errors): Rename first arg from ARGP to REPARSE.
Roland McGrath <roland@gnu.org>
parents: 6197
diff changeset
1473
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1474 (defcustom compilation-context-lines next-screen-context-lines
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1475 "*Display this many lines of leading context before message."
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1476 :type 'integer
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1477 :group 'compilation)
418
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
1478
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1479 (defsubst compilation-set-window (w mk)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1480 ;; Align the compilation output window W with marker MK near top.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1481 (set-window-start w (save-excursion
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1482 (goto-char mk)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1483 (beginning-of-line (- 1 compilation-context-lines))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1484 (point)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1485 (set-window-point w mk))
418
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
1486
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1487 (defun compilation-goto-locus (msg mk end-mk)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1488 "Jump to an error MESSAGE and SOURCE.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1489 All arguments are markers. If SOURCE-END is non nil, mark is set there."
24108
5f499867bc7e (compilation-goto-locus): If already in the
Richard M. Stallman <rms@gnu.org>
parents: 24053
diff changeset
1490 (if (eq (window-buffer (selected-window))
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1491 (marker-buffer msg))
24108
5f499867bc7e (compilation-goto-locus): If already in the
Richard M. Stallman <rms@gnu.org>
parents: 24053
diff changeset
1492 ;; If the compilation buffer window is selected,
5f499867bc7e (compilation-goto-locus): If already in the
Richard M. Stallman <rms@gnu.org>
parents: 24053
diff changeset
1493 ;; keep the compilation buffer in this window;
5f499867bc7e (compilation-goto-locus): If already in the
Richard M. Stallman <rms@gnu.org>
parents: 24053
diff changeset
1494 ;; display the source in another window.
5f499867bc7e (compilation-goto-locus): If already in the
Richard M. Stallman <rms@gnu.org>
parents: 24053
diff changeset
1495 (let ((pop-up-windows t))
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1496 (pop-to-buffer (marker-buffer mk)))
39835
81c88c75006b (compile-mouse-goto-error, compile-goto-error):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39602
diff changeset
1497 (if (window-dedicated-p (selected-window))
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1498 (pop-to-buffer (marker-buffer mk))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1499 (switch-to-buffer (marker-buffer mk))))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1500 ;; If narrowing gets in the way of going to the right place, widen.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1501 (unless (eq (goto-char mk) (point))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1502 (widen)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1503 (goto-char mk))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1504 (if end-mk
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1505 (push-mark end-mk nil t)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1506 (if mark-active (setq mark-active)))
26990
5d153e0fe112 (compilation-goto-locus): Delete hideshow overlays if they interfere.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26488
diff changeset
1507 ;; If hideshow got in the way of
5d153e0fe112 (compilation-goto-locus): Delete hideshow overlays if they interfere.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26488
diff changeset
1508 ;; seeing the right place, open permanently.
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1509 (dolist (ov (overlays-at (point)))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1510 (when (eq 'hs (overlay-get ov 'invisible))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1511 (delete-overlay ov)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1512 (goto-char mk)))
418
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
1513
6240
5ce2192f76e1 (compile-reinitialize-errors): Rename first arg from ARGP to REPARSE.
Roland McGrath <roland@gnu.org>
parents: 6197
diff changeset
1514 ;; Show compilation buffer in other window, scrolled to this error.
5ce2192f76e1 (compile-reinitialize-errors): Rename first arg from ARGP to REPARSE.
Roland McGrath <roland@gnu.org>
parents: 6197
diff changeset
1515 (let* ((pop-up-windows t)
11804
7a7da7fca594 (compilation-next-error-locus): Ignore zero column number.
Roland McGrath <roland@gnu.org>
parents: 11791
diff changeset
1516 ;; Use an existing window if it is in a visible frame.
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1517 (w (or (get-buffer-window (marker-buffer msg) 'visible)
11804
7a7da7fca594 (compilation-next-error-locus): Ignore zero column number.
Roland McGrath <roland@gnu.org>
parents: 11791
diff changeset
1518 ;; Pop up a window.
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1519 (display-buffer (marker-buffer msg))))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1520 (highlight-regexp (with-current-buffer (marker-buffer msg)
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1521 ;; also do this while we change buffer
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1522 (compilation-set-window w msg)
53140
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
1523 compilation-highlight-regexp)))
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
1524 (compilation-set-window-height w)
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
1525
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1526 (when (and highlight-regexp
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1527 (not (and end-mk transient-mark-mode)))
53140
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
1528 (unless compilation-highlight-overlay
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
1529 (setq compilation-highlight-overlay (make-overlay 1 1))
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
1530 (overlay-put compilation-highlight-overlay 'face 'region))
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1531 (with-current-buffer (marker-buffer mk)
53140
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
1532 (save-excursion
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
1533 (end-of-line)
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
1534 (let ((end (point)) olay)
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
1535 (beginning-of-line)
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
1536 (if (and (stringp highlight-regexp)
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1537 (re-search-forward highlight-regexp end t))
53140
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
1538 (progn
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
1539 (goto-char (match-beginning 0))
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
1540 (move-overlay compilation-highlight-overlay (match-beginning 0) (match-end 0)))
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
1541 (move-overlay compilation-highlight-overlay (point) end))
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
1542 (sit-for 0 500)
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
1543 (delete-overlay compilation-highlight-overlay)))))))
00845c3bc4e4 (grep-command, grep-use-null-device)
Kim F. Storm <storm@cua.dk>
parents: 52892
diff changeset
1544
6240
5ce2192f76e1 (compile-reinitialize-errors): Rename first arg from ARGP to REPARSE.
Roland McGrath <roland@gnu.org>
parents: 6197
diff changeset
1545
10928
a008a9d8966a (compilation-buffer-p): Fix braino in last change: switch to the buffer first.
Roland McGrath <roland@gnu.org>
parents: 10842
diff changeset
1546 (defun compilation-find-file (marker filename dir &rest formats)
26222
35c7eab893ab Checkdoc-inspired fixes.
Dave Love <fx@gnu.org>
parents: 25623
diff changeset
1547 "Find a buffer for file FILENAME.
30878
13a1a0ec31e5 (grep): Provide a default set of files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30688
diff changeset
1548 Search the directories in `compilation-search-path'.
13a1a0ec31e5 (grep): Provide a default set of files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30688
diff changeset
1549 A nil in `compilation-search-path' means to try the
26222
35c7eab893ab Checkdoc-inspired fixes.
Dave Love <fx@gnu.org>
parents: 25623
diff changeset
1550 current directory, which is passed in DIR.
35c7eab893ab Checkdoc-inspired fixes.
Dave Love <fx@gnu.org>
parents: 25623
diff changeset
1551 If FILENAME is not found at all, ask the user where to find it.
35c7eab893ab Checkdoc-inspired fixes.
Dave Love <fx@gnu.org>
parents: 25623
diff changeset
1552 Pop up the buffer containing MARKER and scroll to MARKER if we ask the user."
10928
a008a9d8966a (compilation-buffer-p): Fix braino in last change: switch to the buffer first.
Roland McGrath <roland@gnu.org>
parents: 10842
diff changeset
1553 (or formats (setq formats '("%s")))
26990
5d153e0fe112 (compilation-goto-locus): Delete hideshow overlays if they interfere.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26488
diff changeset
1554 (save-excursion
5d153e0fe112 (compilation-goto-locus): Delete hideshow overlays if they interfere.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26488
diff changeset
1555 (let ((dirs compilation-search-path)
5d153e0fe112 (compilation-goto-locus): Delete hideshow overlays if they interfere.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26488
diff changeset
1556 buffer thisdir fmts name)
5d153e0fe112 (compilation-goto-locus): Delete hideshow overlays if they interfere.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26488
diff changeset
1557 (if (file-name-absolute-p filename)
38493
864c2b4076f8 (compilation-parse-errors): `linenum' might return a this-error using
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
1558 ;; The file name is absolute. Use its explicit directory as
864c2b4076f8 (compilation-parse-errors): `linenum' might return a this-error using
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
1559 ;; the first in the search path, and strip it from FILENAME.
864c2b4076f8 (compilation-parse-errors): `linenum' might return a this-error using
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
1560 (setq filename (abbreviate-file-name (expand-file-name filename))
864c2b4076f8 (compilation-parse-errors): `linenum' might return a this-error using
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
1561 dirs (cons (file-name-directory filename) dirs)
864c2b4076f8 (compilation-parse-errors): `linenum' might return a this-error using
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
1562 filename (file-name-nondirectory filename)))
26990
5d153e0fe112 (compilation-goto-locus): Delete hideshow overlays if they interfere.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26488
diff changeset
1563 ;; Now search the path.
5d153e0fe112 (compilation-goto-locus): Delete hideshow overlays if they interfere.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26488
diff changeset
1564 (while (and dirs (null buffer))
5d153e0fe112 (compilation-goto-locus): Delete hideshow overlays if they interfere.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26488
diff changeset
1565 (setq thisdir (or (car dirs) dir)
5d153e0fe112 (compilation-goto-locus): Delete hideshow overlays if they interfere.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26488
diff changeset
1566 fmts formats)
5d153e0fe112 (compilation-goto-locus): Delete hideshow overlays if they interfere.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26488
diff changeset
1567 ;; For each directory, try each format string.
5d153e0fe112 (compilation-goto-locus): Delete hideshow overlays if they interfere.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26488
diff changeset
1568 (while (and fmts (null buffer))
5d153e0fe112 (compilation-goto-locus): Delete hideshow overlays if they interfere.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26488
diff changeset
1569 (setq name (expand-file-name (format (car fmts) filename) thisdir)
5d153e0fe112 (compilation-goto-locus): Delete hideshow overlays if they interfere.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26488
diff changeset
1570 buffer (and (file-exists-p name)
30878
13a1a0ec31e5 (grep): Provide a default set of files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30688
diff changeset
1571 (find-file-noselect name))
26990
5d153e0fe112 (compilation-goto-locus): Delete hideshow overlays if they interfere.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26488
diff changeset
1572 fmts (cdr fmts)))
5d153e0fe112 (compilation-goto-locus): Delete hideshow overlays if they interfere.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26488
diff changeset
1573 (setq dirs (cdr dirs)))
5d153e0fe112 (compilation-goto-locus): Delete hideshow overlays if they interfere.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26488
diff changeset
1574 (or buffer
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1575 ;; The file doesn't exist. Ask the user where to find it.
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1576 (let ((pop-up-windows t))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1577 (compilation-set-window (display-buffer (marker-buffer marker))
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1578 marker)
26990
5d153e0fe112 (compilation-goto-locus): Delete hideshow overlays if they interfere.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26488
diff changeset
1579 (let ((name (expand-file-name
5d153e0fe112 (compilation-goto-locus): Delete hideshow overlays if they interfere.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26488
diff changeset
1580 (read-file-name
5d153e0fe112 (compilation-goto-locus): Delete hideshow overlays if they interfere.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26488
diff changeset
1581 (format "Find this error in: (default %s) "
5d153e0fe112 (compilation-goto-locus): Delete hideshow overlays if they interfere.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26488
diff changeset
1582 filename)
5d153e0fe112 (compilation-goto-locus): Delete hideshow overlays if they interfere.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26488
diff changeset
1583 dir filename t))))
5d153e0fe112 (compilation-goto-locus): Delete hideshow overlays if they interfere.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26488
diff changeset
1584 (if (file-directory-p name)
5d153e0fe112 (compilation-goto-locus): Delete hideshow overlays if they interfere.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26488
diff changeset
1585 (setq name (expand-file-name filename name)))
5d153e0fe112 (compilation-goto-locus): Delete hideshow overlays if they interfere.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26488
diff changeset
1586 (setq buffer (and (file-exists-p name)
5d153e0fe112 (compilation-goto-locus): Delete hideshow overlays if they interfere.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26488
diff changeset
1587 (find-file name))))))
5d153e0fe112 (compilation-goto-locus): Delete hideshow overlays if they interfere.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26488
diff changeset
1588 ;; Make intangible overlays tangible.
5d153e0fe112 (compilation-goto-locus): Delete hideshow overlays if they interfere.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26488
diff changeset
1589 (mapcar (function (lambda (ov)
5d153e0fe112 (compilation-goto-locus): Delete hideshow overlays if they interfere.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26488
diff changeset
1590 (when (overlay-get ov 'intangible)
5d153e0fe112 (compilation-goto-locus): Delete hideshow overlays if they interfere.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26488
diff changeset
1591 (overlay-put ov 'intangible nil))))
5d153e0fe112 (compilation-goto-locus): Delete hideshow overlays if they interfere.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26488
diff changeset
1592 (overlays-in (point-min) (point-max)))
5d153e0fe112 (compilation-goto-locus): Delete hideshow overlays if they interfere.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26488
diff changeset
1593 buffer)))
5d153e0fe112 (compilation-goto-locus): Delete hideshow overlays if they interfere.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26488
diff changeset
1594
46324
d992f5698971 (compilation-normalize-filename):
Richard M. Stallman <rms@gnu.org>
parents: 45829
diff changeset
1595 (defun compilation-normalize-filename (filename)
d992f5698971 (compilation-normalize-filename):
Richard M. Stallman <rms@gnu.org>
parents: 45829
diff changeset
1596 "Convert a filename string found in an error message to make it usable."
d992f5698971 (compilation-normalize-filename):
Richard M. Stallman <rms@gnu.org>
parents: 45829
diff changeset
1597
d992f5698971 (compilation-normalize-filename):
Richard M. Stallman <rms@gnu.org>
parents: 45829
diff changeset
1598 ;; Check for a comint-file-name-prefix and prepend it if
d992f5698971 (compilation-normalize-filename):
Richard M. Stallman <rms@gnu.org>
parents: 45829
diff changeset
1599 ;; appropriate. (This is very useful for
d992f5698971 (compilation-normalize-filename):
Richard M. Stallman <rms@gnu.org>
parents: 45829
diff changeset
1600 ;; compilation-minor-mode in an rlogin-mode buffer.)
d992f5698971 (compilation-normalize-filename):
Richard M. Stallman <rms@gnu.org>
parents: 45829
diff changeset
1601 (and (boundp 'comint-file-name-prefix)
d992f5698971 (compilation-normalize-filename):
Richard M. Stallman <rms@gnu.org>
parents: 45829
diff changeset
1602 ;; If file name is relative, default-directory will
d992f5698971 (compilation-normalize-filename):
Richard M. Stallman <rms@gnu.org>
parents: 45829
diff changeset
1603 ;; already contain the comint-file-name-prefix (done
d992f5698971 (compilation-normalize-filename):
Richard M. Stallman <rms@gnu.org>
parents: 45829
diff changeset
1604 ;; by compile-abbreviate-directory).
d992f5698971 (compilation-normalize-filename):
Richard M. Stallman <rms@gnu.org>
parents: 45829
diff changeset
1605 (file-name-absolute-p filename)
d992f5698971 (compilation-normalize-filename):
Richard M. Stallman <rms@gnu.org>
parents: 45829
diff changeset
1606 (setq filename
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1607 (concat (with-no-warnings 'comint-file-name-prefix) filename)))
46324
d992f5698971 (compilation-normalize-filename):
Richard M. Stallman <rms@gnu.org>
parents: 45829
diff changeset
1608
d992f5698971 (compilation-normalize-filename):
Richard M. Stallman <rms@gnu.org>
parents: 45829
diff changeset
1609 ;; If compilation-parse-errors-filename-function is
d992f5698971 (compilation-normalize-filename):
Richard M. Stallman <rms@gnu.org>
parents: 45829
diff changeset
1610 ;; defined, use it to process the filename.
d992f5698971 (compilation-normalize-filename):
Richard M. Stallman <rms@gnu.org>
parents: 45829
diff changeset
1611 (when compilation-parse-errors-filename-function
d992f5698971 (compilation-normalize-filename):
Richard M. Stallman <rms@gnu.org>
parents: 45829
diff changeset
1612 (setq filename
d992f5698971 (compilation-normalize-filename):
Richard M. Stallman <rms@gnu.org>
parents: 45829
diff changeset
1613 (funcall compilation-parse-errors-filename-function
d992f5698971 (compilation-normalize-filename):
Richard M. Stallman <rms@gnu.org>
parents: 45829
diff changeset
1614 filename)))
d992f5698971 (compilation-normalize-filename):
Richard M. Stallman <rms@gnu.org>
parents: 45829
diff changeset
1615
d992f5698971 (compilation-normalize-filename):
Richard M. Stallman <rms@gnu.org>
parents: 45829
diff changeset
1616 ;; Some compilers (e.g. Sun's java compiler, reportedly)
d992f5698971 (compilation-normalize-filename):
Richard M. Stallman <rms@gnu.org>
parents: 45829
diff changeset
1617 ;; produce bogus file names like "./bar//foo.c" for file
d992f5698971 (compilation-normalize-filename):
Richard M. Stallman <rms@gnu.org>
parents: 45829
diff changeset
1618 ;; "bar/foo.c"; expand-file-name will collapse these into
d992f5698971 (compilation-normalize-filename):
Richard M. Stallman <rms@gnu.org>
parents: 45829
diff changeset
1619 ;; "/foo.c" and fail to find the appropriate file. So we
d992f5698971 (compilation-normalize-filename):
Richard M. Stallman <rms@gnu.org>
parents: 45829
diff changeset
1620 ;; look for doubled slashes in the file name and fix them
d992f5698971 (compilation-normalize-filename):
Richard M. Stallman <rms@gnu.org>
parents: 45829
diff changeset
1621 ;; up in the buffer.
d992f5698971 (compilation-normalize-filename):
Richard M. Stallman <rms@gnu.org>
parents: 45829
diff changeset
1622 (setq filename (command-line-normalize-file-name filename)))
418
21a228b6a238 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 71
diff changeset
1623
71
a35b34e246fe Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1624
3940
aa9f37730d77 (compile-abbreviate-directory): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3875
diff changeset
1625 ;; If directory DIR is a subdir of ORIG or of ORIG's parent,
aa9f37730d77 (compile-abbreviate-directory): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3875
diff changeset
1626 ;; return a relative name for it starting from ORIG or its parent.
aa9f37730d77 (compile-abbreviate-directory): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3875
diff changeset
1627 ;; ORIG-EXPANDED is an expanded version of ORIG.
aa9f37730d77 (compile-abbreviate-directory): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3875
diff changeset
1628 ;; PARENT-EXPANDED is an expanded version of ORIG's parent.
aa9f37730d77 (compile-abbreviate-directory): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3875
diff changeset
1629 ;; Those two args could be computed here, but we run faster by
aa9f37730d77 (compile-abbreviate-directory): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3875
diff changeset
1630 ;; having the caller compute them just once.
aa9f37730d77 (compile-abbreviate-directory): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3875
diff changeset
1631 (defun compile-abbreviate-directory (dir orig orig-expanded parent-expanded)
12219
7c0b93d3df6b (compilation-find-file): If FILENAME is absolute, apply
Roland McGrath <roland@gnu.org>
parents: 12029
diff changeset
1632 ;; Apply canonical abbreviations to DIR first thing.
7c0b93d3df6b (compilation-find-file): If FILENAME is absolute, apply
Roland McGrath <roland@gnu.org>
parents: 12029
diff changeset
1633 ;; Those abbreviations are already done in the other arguments passed.
7c0b93d3df6b (compilation-find-file): If FILENAME is absolute, apply
Roland McGrath <roland@gnu.org>
parents: 12029
diff changeset
1634 (setq dir (abbreviate-file-name dir))
7c0b93d3df6b (compilation-find-file): If FILENAME is absolute, apply
Roland McGrath <roland@gnu.org>
parents: 12029
diff changeset
1635
5475
e723f6be6239 (compilation-parse-errors): Prepend comint-file-name-prefix (if boundp) to
Roland McGrath <roland@gnu.org>
parents: 5472
diff changeset
1636 ;; Check for a comint-file-name-prefix and prepend it if appropriate.
e723f6be6239 (compilation-parse-errors): Prepend comint-file-name-prefix (if boundp) to
Roland McGrath <roland@gnu.org>
parents: 5472
diff changeset
1637 ;; (This is very useful for compilation-minor-mode in an rlogin-mode
e723f6be6239 (compilation-parse-errors): Prepend comint-file-name-prefix (if boundp) to
Roland McGrath <roland@gnu.org>
parents: 5472
diff changeset
1638 ;; buffer.)
e723f6be6239 (compilation-parse-errors): Prepend comint-file-name-prefix (if boundp) to
Roland McGrath <roland@gnu.org>
parents: 5472
diff changeset
1639 (if (boundp 'comint-file-name-prefix)
e723f6be6239 (compilation-parse-errors): Prepend comint-file-name-prefix (if boundp) to
Roland McGrath <roland@gnu.org>
parents: 5472
diff changeset
1640 (setq dir (concat comint-file-name-prefix dir)))
e723f6be6239 (compilation-parse-errors): Prepend comint-file-name-prefix (if boundp) to
Roland McGrath <roland@gnu.org>
parents: 5472
diff changeset
1641
3940
aa9f37730d77 (compile-abbreviate-directory): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3875
diff changeset
1642 (if (and (> (length dir) (length orig-expanded))
aa9f37730d77 (compile-abbreviate-directory): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3875
diff changeset
1643 (string= orig-expanded
aa9f37730d77 (compile-abbreviate-directory): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3875
diff changeset
1644 (substring dir 0 (length orig-expanded))))
aa9f37730d77 (compile-abbreviate-directory): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3875
diff changeset
1645 (setq dir
aa9f37730d77 (compile-abbreviate-directory): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3875
diff changeset
1646 (concat orig
aa9f37730d77 (compile-abbreviate-directory): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3875
diff changeset
1647 (substring dir (length orig-expanded)))))
aa9f37730d77 (compile-abbreviate-directory): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3875
diff changeset
1648 (if (and (> (length dir) (length parent-expanded))
aa9f37730d77 (compile-abbreviate-directory): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3875
diff changeset
1649 (string= parent-expanded
aa9f37730d77 (compile-abbreviate-directory): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3875
diff changeset
1650 (substring dir 0 (length parent-expanded))))
aa9f37730d77 (compile-abbreviate-directory): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3875
diff changeset
1651 (setq dir
aa9f37730d77 (compile-abbreviate-directory): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3875
diff changeset
1652 (concat (file-name-directory
aa9f37730d77 (compile-abbreviate-directory): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3875
diff changeset
1653 (directory-file-name orig))
aa9f37730d77 (compile-abbreviate-directory): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3875
diff changeset
1654 (substring dir (length parent-expanded)))))
aa9f37730d77 (compile-abbreviate-directory): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3875
diff changeset
1655 dir)
aa9f37730d77 (compile-abbreviate-directory): New function.
Richard M. Stallman <rms@gnu.org>
parents: 3875
diff changeset
1656
54361
63ef4a00326a (compile-auto-highlight)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 53978
diff changeset
1657 (add-to-list 'debug-ignored-errors "^No more [-a-z ]+s yet$")
29078
2e20146198ce Add to debug-ignored-errors.
Dave Love <fx@gnu.org>
parents: 28936
diff changeset
1658
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 569
diff changeset
1659 (provide 'compile)
712
16823e891d56 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 621
diff changeset
1660
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 52394
diff changeset
1661 ;;; arch-tag: 12465727-7382-4f72-b234-79855a00dd8c
712
16823e891d56 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 621
diff changeset
1662 ;;; compile.el ends here