unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#14217: 24.3.50; patch: flymake.el -- warning predicate
@ 2013-04-16 21:36 Eduard Wiebe
       [not found] ` <handler.14217.B.136614126516956.ack@debbugs.gnu.org>
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Eduard Wiebe @ 2013-04-16 21:36 UTC (permalink / raw)
  To: 14217

[-- Attachment #1: Type: text/plain, Size: 107 bytes --]


  Hello,

here is a patch, which extends current flymake mechanism for classifing
error text as warning.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: flymake.warn.pred.patch --]
[-- Type: text/x-diff, Size: 4563 bytes --]

diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog
index f99b821..ea347ea 100644
--- a/doc/misc/ChangeLog
+++ b/doc/misc/ChangeLog
@@ -1,3 +1,8 @@
+2013-04-16  Eduard Wiebe  <usenet@pusto.de>
+
+	* flymake.texi (Parsing the output, Customizable variables): Add
+	reference to `flymake-warning-predicate'.
+
 2013-04-15  Michael Albinus  <michael.albinus@gmx.de>
 
 	* tramp.texi (Frequently Asked Questions): New item for
diff --git a/doc/misc/flymake.texi b/doc/misc/flymake.texi
index 5dedda1..7196eed 100644
--- a/doc/misc/flymake.texi
+++ b/doc/misc/flymake.texi
@@ -311,6 +311,9 @@ Used when looking for a master file. @xref{Locating a master file}.
 Patterns for error/warning messages in the form @code{(regexp file-idx
 line-idx col-idx err-text-idx)}. @xref{Parsing the output}.
 
+@item flymake-warning-predicate
+Predicate to classify error text as warning. @xref{Parsing the output}.
+
 @item flymake-compilation-prevents-syntax-check
 A flag indicating whether compilation and syntax check of the same
 file cannot be run simultaneously.
@@ -706,7 +709,10 @@ list of items of the form @code{(regexp file-idx line-idx
 err-text-idx)}, used to determine whether a particular line is an
 error message and extract file name, line number and error text,
 respectively. Error type (error/warning) is also guessed by matching
-error text with the '@code{^[wW]arning}' pattern. Anything that was not
+error text with the @code{flymake-warning-predicate} predicate.  The
+predicate is either a regular expression, default @code{"[wW]arning"},
+or a function. When the predicate is a function, it takes error text
+as argument and returns a non-nil for a warning. Anything that was not
 classified as a warning is considered an error. Type is then used to
 sort error menu items, which shows error messages first.
 
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 81868e8..f8cb826 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,12 @@
+2013-04-15  Eduard Wiebe  <usenet@pusto.de>
+
+	Extend flymakes warning predicate.
+
+	* progmodes/flymake.el (flymake-warning-predicate): New.
+	(flymake-parse-line): Use it.
+	(flymake-warning-re): Make obsolete alias to
+	`flymake-warning-predicate'.
+
 2013-04-15  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* minibuffer.el (minibuffer-complete): Don't just scroll
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
index 0f92df9..905ad49 100644
--- a/lisp/progmodes/flymake.el
+++ b/lisp/progmodes/flymake.el
@@ -1002,8 +1002,13 @@ 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")
+(defcustom flymake-warning-predicate "^[wW]arning"
+  "Predicate matching against error text to detect a warning."
+  :group   'flymake
+  :version "24.4"
+  :type    '(choice (regexp   :tag "Regexp predicate")
+                    (function :tag "Function predicate")))
 
 (defun flymake-parse-line (line)
   "Parse LINE to see if it is an error or warning.
@@ -1024,10 +1029,13 @@ Return its components if so, nil otherwise."
 	  (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")
-	    )
+	  (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)))
diff --git a/test/ChangeLog b/test/ChangeLog
index bf68984..21e2f16 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,12 @@
+2013-04-15  Eduard Wiebe  <usenet@pusto.de>
+
+	Test suite for flymake.
+
+	* automated/flymake-tests.el:
+	* automated/flymake/warnpred/Makefile
+	* automated/flymake/warnpred/test.c
+	* automated/flymake/warnpred/test.pl: New files.
+
 2013-04-09  Masatake YAMATO  <yamato@redhat.com>
 
 	* automated/add-log-tests.el: New file. (Bug#14112)

[-- Attachment #3: Type: text/plain, Size: 33 bytes --]


The corresponding test driver:


[-- Attachment #4: flymake-tests.el --]
[-- Type: application/emacs-lisp, Size: 2960 bytes --]

[-- Attachment #5: Type: text/plain, Size: 104 bytes --]


Following files are test helper and should be placed under
test/automated/flymake/warnpred directory.


[-- Attachment #6: Makefile --]
[-- Type: application/octet-stream, Size: 101 bytes --]

# Makefile for flymake tests

CC_OPTS = -Wall

check-syntax:
	$(CC) $(CC_OPTS) ${CHK_SOURCES}

# eof

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #7: test.c --]
[-- Type: text/x-csrc, Size: 44 bytes --]

int main()
{
  char c = 1000;
  return c;
}

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #8: test.pl --]
[-- Type: text/x-perl, Size: 32 bytes --]

@arr = [1,2,3,4];
@arr[1] = -1;

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#14217: Acknowledgement (24.3.50; patch: flymake.el -- warning predicate)
       [not found] ` <handler.14217.B.136614126516956.ack@debbugs.gnu.org>
@ 2013-06-01 15:52   ` Eduard Wiebe
  0 siblings, 0 replies; 5+ messages in thread
From: Eduard Wiebe @ 2013-06-01 15:52 UTC (permalink / raw)
  To: 14217


Any concerns?

-- 
Eduard Wiebe





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#14217: 24.3.50; patch: flymake.el -- warning predicate
  2013-04-16 21:36 bug#14217: 24.3.50; patch: flymake.el -- warning predicate Eduard Wiebe
       [not found] ` <handler.14217.B.136614126516956.ack@debbugs.gnu.org>
@ 2013-06-16  1:41 ` Stefan Monnier
  2013-06-16 10:28   ` Eduard Wiebe
  2013-06-21 14:36 ` Stefan Monnier
  2 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2013-06-16  1:41 UTC (permalink / raw)
  To: Eduard Wiebe; +Cc: 14217

> here is a patch, which extends current flymake mechanism for classifing
> error text as warning.

Looks good, thanks, please install.


        Stefan





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#14217: 24.3.50; patch: flymake.el -- warning predicate
  2013-06-16  1:41 ` bug#14217: 24.3.50; patch: flymake.el -- warning predicate Stefan Monnier
@ 2013-06-16 10:28   ` Eduard Wiebe
  0 siblings, 0 replies; 5+ messages in thread
From: Eduard Wiebe @ 2013-06-16 10:28 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 14217


Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> here is a patch, which extends current flymake mechanism for classifing
>> error text as warning.
>
> Looks good, thanks, please install.

I don't have commit rights, sorry.






^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#14217: 24.3.50; patch: flymake.el -- warning predicate
  2013-04-16 21:36 bug#14217: 24.3.50; patch: flymake.el -- warning predicate Eduard Wiebe
       [not found] ` <handler.14217.B.136614126516956.ack@debbugs.gnu.org>
  2013-06-16  1:41 ` bug#14217: 24.3.50; patch: flymake.el -- warning predicate Stefan Monnier
@ 2013-06-21 14:36 ` Stefan Monnier
  2 siblings, 0 replies; 5+ messages in thread
From: Stefan Monnier @ 2013-06-21 14:36 UTC (permalink / raw)
  To: Eduard Wiebe; +Cc: 14217-done

> here is a patch, which extends current flymake mechanism for classifing
> error text as warning.

Thank you, installed finally,


        Stefan





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-06-21 14:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-16 21:36 bug#14217: 24.3.50; patch: flymake.el -- warning predicate Eduard Wiebe
     [not found] ` <handler.14217.B.136614126516956.ack@debbugs.gnu.org>
2013-06-01 15:52   ` bug#14217: Acknowledgement (24.3.50; patch: flymake.el -- warning predicate) Eduard Wiebe
2013-06-16  1:41 ` bug#14217: 24.3.50; patch: flymake.el -- warning predicate Stefan Monnier
2013-06-16 10:28   ` Eduard Wiebe
2013-06-21 14:36 ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).