aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2019-10-10 01:19:33 +0200
committerLars Ingebrigtsen2019-10-10 01:19:33 +0200
commit3f594fef9eeeda2272dc9858b6b17bbd5fa2f436 (patch)
tree1346624c594c1c075415fc6d3672675fc1e2ae35
parente4efab3f03cec69c87b2e3e28bd70f401821d96f (diff)
downloademacs-3f594fef9eeeda2272dc9858b6b17bbd5fa2f436.tar.gz
emacs-3f594fef9eeeda2272dc9858b6b17bbd5fa2f436.zip
Allow filtering out warnings/errors from compile.el detection
* lisp/progmodes/compile.el (compilation-transform-file-match-alist): New variable (bug#32968). (compilation-error-properties): Use it to remove known false positives. (compilation-error-regexp-alist): Mention it in this doc string.
-rw-r--r--etc/NEWS4
-rw-r--r--lisp/progmodes/compile.el56
2 files changed, 48 insertions, 12 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 49aa7f6007b..3b98ef7d2f5 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -612,6 +612,10 @@ be functions.
612nil, but instead of scrolling the current line to the top of the 612nil, but instead of scrolling the current line to the top of the
613screen when there is no left fringe, it inserts a visible arrow before 613screen when there is no left fringe, it inserts a visible arrow before
614column zero. 614column zero.
615---
616*** The new 'compilation-transform-file-match-alist' variable can be used
617to transform file name matches compilation output, and remove known
618false positives being recognised as warnings/errors.
615 619
616** cl-lib.el 620** cl-lib.el
617+++ 621+++
diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index 50370a4f3ac..b8d1acd1cc6 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -58,6 +58,16 @@ If nil, use Emacs default."
58 :type '(choice (const :tag "Default" nil) 58 :type '(choice (const :tag "Default" nil)
59 integer)) 59 integer))
60 60
61(defcustom compilation-transform-file-match-alist
62 '(("/bin/[a-z]*sh\\'" nil)
63 ("\\*+ \\[\\(Makefile\\)" "\\1"))
64 "Alist of regexp/replacements to alter file names in compilation errors.
65If the replacement is nil, the file will not be considered an
66error after all. If not nil, it should be a regexp replacement
67string."
68 :type '(repeat (list regexp string))
69 :version "27.1")
70
61(defvar compilation-filter-hook nil 71(defvar compilation-filter-hook nil
62 "Hook run after `compilation-filter' has inserted a string into the buffer. 72 "Hook run after `compilation-filter' has inserted a string into the buffer.
63It is called with the variable `compilation-filter-start' bound 73It is called with the variable `compilation-filter-start' bound
@@ -608,7 +618,12 @@ SUBMATCH is the number of a submatch and FACE is an expression
608which evaluates to a face name (a symbol or string). 618which evaluates to a face name (a symbol or string).
609Alternatively, FACE can evaluate to a property list of the 619Alternatively, FACE can evaluate to a property list of the
610form (face FACE PROP1 VAL1 PROP2 VAL2 ...), in which case all the 620form (face FACE PROP1 VAL1 PROP2 VAL2 ...), in which case all the
611listed text properties PROP# are given values VAL# as well." 621listed text properties PROP# are given values VAL# as well.
622
623After identifying errors and warnings determined by this
624variable, the `compilation-transform-file-match-alist' variable
625is then consulted. It allows further transformations of the
626matched file names, and weeding out false positives."
612 :type '(repeat (choice (symbol :tag "Predefined symbol") 627 :type '(repeat (choice (symbol :tag "Predefined symbol")
613 (sexp :tag "Error specification"))) 628 (sexp :tag "Error specification")))
614 :link `(file-link :tag "example file" 629 :link `(file-link :tag "example file"
@@ -1111,7 +1126,7 @@ POS and RES.")
1111 (setq file (if (functionp file) (funcall file) 1126 (setq file (if (functionp file) (funcall file)
1112 (match-string-no-properties file)))) 1127 (match-string-no-properties file))))
1113 (let ((dir 1128 (let ((dir
1114 (unless (file-name-absolute-p file) 1129 (unless (file-name-absolute-p file)
1115 (let ((pos (compilation--previous-directory 1130 (let ((pos (compilation--previous-directory
1116 (match-beginning 0)))) 1131 (match-beginning 0))))
1117 (when pos 1132 (when pos
@@ -1161,19 +1176,36 @@ POS and RES.")
1161 (setq end-col (match-string-no-properties end-col)) 1176 (setq end-col (match-string-no-properties end-col))
1162 (- (string-to-number end-col) -1))) 1177 (- (string-to-number end-col) -1)))
1163 (and end-line -1))) 1178 (and end-line -1)))
1164 (if (consp type) ; not a static type, check what it is. 1179 (if (consp type) ; not a static type, check what it is.
1165 (setq type (or (and (car type) (match-end (car type)) 1) 1180 (setq type (or (and (car type) (match-end (car type)) 1)
1166 (and (cdr type) (match-end (cdr type)) 0) 1181 (and (cdr type) (match-end (cdr type)) 0)
1167 2))) 1182 2)))
1168 1183 ;; Remove matches like /bin/sh and do other file name transforms.
1169 (when (and compilation-auto-jump-to-next 1184 (save-match-data
1170 (>= type compilation-skip-threshold)) 1185 (let ((transformed nil))
1171 (kill-local-variable 'compilation-auto-jump-to-next) 1186 (dolist (f file)
1172 (run-with-timer 0 nil 'compilation-auto-jump 1187 (let ((match
1173 (current-buffer) (match-beginning 0))) 1188 (cl-loop for (regexp replacement)
1174 1189 in compilation-transform-file-match-alist
1175 (compilation-internal-error-properties 1190 when (string-match regexp f)
1176 file line end-line col end-col type fmt))) 1191 return (or replacement t))))
1192 (cond ((not match)
1193 (push f transformed))
1194 ((stringp match)
1195 (push (replace-match match nil nil f) transformed)))))
1196 (setq file (nreverse transformed))))
1197 (if (not file)
1198 ;; If we ignored all the files with errors on this line, then
1199 ;; return nil.
1200 nil
1201 (when (and compilation-auto-jump-to-next
1202 (>= type compilation-skip-threshold))
1203 (kill-local-variable 'compilation-auto-jump-to-next)
1204 (run-with-timer 0 nil 'compilation-auto-jump
1205 (current-buffer) (match-beginning 0)))
1206
1207 (compilation-internal-error-properties
1208 file line end-line col end-col type fmt))))
1177 1209
1178(defun compilation-beginning-of-line (&optional n) 1210(defun compilation-beginning-of-line (&optional n)
1179 "Like `beginning-of-line', but accounts for lines hidden by `selective-display'." 1211 "Like `beginning-of-line', but accounts for lines hidden by `selective-display'."