diff options
author | Eduard Wiebe <usenet@pusto.de> | 2013-06-21 10:36:13 -0400 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2013-06-21 10:36:13 -0400 |
commit | c5b0993e5f54a664d7edbdf9caffb43555618c51 (patch) | |
tree | ecf4f7c6ac5af5b19a3bb86a166ce0d30fbd0551 /lisp/progmodes/flymake.el | |
parent | a7d2d4654e2dd1075df0c45c15cae52924a44ada (diff) |
Extend flymake's warning predicate to be a function. Test suite for flymake.
* lisp/progmodes/flymake.el (flymake-warning-predicate): New.
(flymake-parse-line): Use it.
(flymake-warning-re): Make obsolete alias to
`flymake-warning-predicate'.
* doc/misc/flymake.texi (Parsing the output, Customizable variables):
Add reference to `flymake-warning-predicate'.
* test/automated/flymake-tests.el:
* test/automated/flymake/warnpred/Makefile
* test/automated/flymake/warnpred/test.c
* test/automated/flymake/warnpred/test.pl: New files.
Fixes: debbugs:14217
Diffstat (limited to 'lisp/progmodes/flymake.el')
-rw-r--r-- | lisp/progmodes/flymake.el | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el index 99b48e8d0d..2ead734d16 100644 --- a/lisp/progmodes/flymake.el +++ b/lisp/progmodes/flymake.el @@ -1049,8 +1049,12 @@ from compile.el") ;; :type '(repeat (string number number number)) ;;) -(defvar flymake-warning-re "^[wW]arning" - "Regexp matching against err-text to detect a warning.") +(define-obsolete-variable-alias 'flymake-warning-re 'flymake-warning-predicate "24.4") +(defvar flymake-warning-predicate "^[wW]arning" + "Predicate matching against error text to detect a warning. +Takes a single argument, the error's text and should return non-nil +if it's a warning. +Instead of a function, it can also be a regular expression.") (defun flymake-parse-line (line) "Parse LINE to see if it is an error or warning. @@ -1067,16 +1071,22 @@ Return its components if so, nil otherwise." (line-idx (nth 2 (car patterns)))) (setq raw-file-name (if file-idx (match-string file-idx line) nil)) - (setq line-no (if line-idx (string-to-number (match-string line-idx line)) 0)) + (setq line-no (if line-idx (string-to-number + (match-string line-idx line)) 0)) (setq err-text (if (> (length (car patterns)) 4) (match-string (nth 4 (car patterns)) line) - (flymake-patch-err-text (substring line (match-end 0))))) - (or err-text (setq err-text "<no error text>")) - (if (and err-text (string-match flymake-warning-re err-text)) - (setq err-type "w") - ) - (flymake-log 3 "parse line: file-idx=%s line-idx=%s file=%s line=%s text=%s" file-idx line-idx - raw-file-name line-no err-text) + (flymake-patch-err-text + (substring line (match-end 0))))) + (if (null err-text) + (setq err-text "<no error text>") + (when (cond ((stringp flymake-warning-predicate) + (string-match flymake-warning-predicate err-text)) + ((functionp flymake-warning-predicate) + (funcall flymake-warning-predicate err-text))) + (setq err-type "w"))) + (flymake-log + 3 "parse line: file-idx=%s line-idx=%s file=%s line=%s text=%s" + file-idx line-idx raw-file-name line-no err-text) (setq matched t))) (setq patterns (cdr patterns))) (if matched |