summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/progmodes/flymake.el30
2 files changed, 28 insertions, 10 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 414650b065..ebed2e2de1 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
+2013-06-21 Eduard Wiebe <usenet@pusto.de>
+
+ Extend flymake's warning predicate to be a function (bug#14217).
+ * progmodes/flymake.el (flymake-warning-predicate): New.
+ (flymake-parse-line): Use it.
+ (flymake-warning-re): Make obsolete alias to
+ `flymake-warning-predicate'.
+
2013-06-21 Stefan Monnier <monnier@iro.umontreal.ca>
* emacs-lisp/package.el (package-alist): Include obsolete packages.
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