From unknown Tue Sep 09 06:30:23 2025 X-Loop: help-debbugs@gnu.org Subject: bug#14217: 24.3.50; patch: flymake.el -- warning predicate Resent-From: Eduard Wiebe Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 16 Apr 2013 19:42:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 14217 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 14217@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.136614126516956 (code B ref -1); Tue, 16 Apr 2013 19:42:01 +0000 Received: (at submit) by debbugs.gnu.org; 16 Apr 2013 19:41:05 +0000 Received: from localhost ([127.0.0.1]:55175 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1USBkW-0004PQ-7Q for submit@debbugs.gnu.org; Tue, 16 Apr 2013 15:41:04 -0400 Received: from eggs.gnu.org ([208.118.235.92]:36983) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1USBkT-0004P9-Vu for submit@debbugs.gnu.org; Tue, 16 Apr 2013 15:41:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1USBgE-0003CT-SM for submit@debbugs.gnu.org; Tue, 16 Apr 2013 15:36:43 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:47633) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USBgE-0003CP-Q8 for submit@debbugs.gnu.org; Tue, 16 Apr 2013 15:36:38 -0400 Received: from eggs.gnu.org ([208.118.235.92]:48291) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USBg6-0000On-DO for bug-gnu-emacs@gnu.org; Tue, 16 Apr 2013 15:36:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1USBg0-0002uI-Cw for bug-gnu-emacs@gnu.org; Tue, 16 Apr 2013 15:36:30 -0400 Received: from wp093.webpack.hosteurope.de ([80.237.132.100]:45434) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USBfz-0002to-VR for bug-gnu-emacs@gnu.org; Tue, 16 Apr 2013 15:36:24 -0400 Received: from f049237196.adsl.alicedsl.de ([78.49.237.196] helo=nirvana); authenticated by wp093.webpack.hosteurope.de running ExIM with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) id 1USBfw-0007kM-N0; Tue, 16 Apr 2013 21:36:21 +0200 Received: from ew by nirvana with local (Exim 4.72) (envelope-from ) id 1USDYE-0000gr-Am for bug-gnu-emacs@gnu.org; Tue, 16 Apr 2013 23:36:30 +0200 From: Eduard Wiebe Date: Tue, 16 Apr 2013 23:36:29 +0200 Message-ID: <87y5ci5faa.fsf@pusto.de> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-bounce-key: webpack.hosteurope.de;ew@pusto.de;1366140983;6d925acb; X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 208.118.235.17 X-Spam-Score: -4.2 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.9 (------) --=-=-= Content-Type: text/plain Hello, here is a patch, which extends current flymake mechanism for classifing error text as warning. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=flymake.warn.pred.patch 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 + + * flymake.texi (Parsing the output, Customizable variables): Add + reference to `flymake-warning-predicate'. + 2013-04-15 Michael Albinus * 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 + + 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 * 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 "")) - (if (and err-text (string-match flymake-warning-re err-text)) - (setq err-type "w") - ) + (if (null err-text) + (setq err-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 + + 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 * automated/add-log-tests.el: New file. (Bug#14112) --=-=-= Content-Type: text/plain The corresponding test driver: --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=flymake-tests.el Content-Transfer-Encoding: quoted-printable ;;; flymake-tests.el --- Test suite for flymake ;; Copyright (C) 2011-2013 Free Software Foundation, Inc. ;; Author: Eduard Wiebe ;; This file is part of GNU Emacs. ;; GNU Emacs is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs. If not, see . ;;; Commentary: ;;; Code: (require 'ert) (require 'flymake) (defgroup flymake-tests nil "Test suite for flymake.") ;; Warning predicate (defun flymake-tests--current-face (file predicate) (let ((buffer (find-file-noselect file))) (unwind-protect (with-current-buffer (find-file-noselect file) (setq-local flymake-warning-predicate predicate) (goto-char (point-min)) (flymake-mode 1) (sleep-for (+ 0.5 flymake-no-changes-timeout)) ; XXX: is this rel= iable enough? (flymake-goto-next-error) (face-at-point)) (and buffer (kill-buffer buffer))))) (ert-deftest warnining-predicate-rx-gcc () "Test GCC warning via regexp predicate." :expected-result (if (executable-find "gcc") :passed :failed) (should (eq 'flymake-warnline (flymake-tests--current-face "flymake/warnpred/test.c" "^[Ww]arning")))) (ert-deftest warning-predicate-function-gcc () "Test GCC warning via function predicate." :expected-result (if (and (executable-find "gcc") (executable-find "make"= )) :passed :failed) (should (eq 'flymake-warnline (flymake-tests--current-face "flymake/warnpred/test.c" (lambda (msg) (string-match "^[Ww]arning" msg)))))) (ert-deftest warning-predicate-rx-perl () "Test perl warning via regular expression predicate." :expected-result (if (executable-find "perl") :passed :failed) (should (eq 'flymake-warnline (flymake-tests--current-face "flymake/warnpred/test.pl" "^Scalar value")))) (ert-deftest warning-predicate-function-perl () "Test perl warning via function predicate." :expected-result (if (executable-find "perl") :passed :failed) (should (eq 'flymake-warnline (flymake-tests--current-face "flymake/warnpred/test.pl" (lambda (msg) (string-match "^Scalar value" msg)))))) (provide 'flymake-tests) ;;; flymake.el ends here --=-=-= Content-Type: text/plain Following files are test helper and should be placed under test/automated/flymake/warnpred directory. --=-=-= Content-Type: application/octet-stream Content-Disposition: attachment; filename=Makefile Content-Transfer-Encoding: base64 IyBNYWtlZmlsZSBmb3IgZmx5bWFrZSB0ZXN0cwoKQ0NfT1BUUyA9IC1XYWxsCgpjaGVjay1zeW50 YXg6CgkkKENDKSAkKENDX09QVFMpICR7Q0hLX1NPVVJDRVN9CgojIGVvZgo= --=-=-= Content-Type: text/x-csrc Content-Disposition: attachment; filename=test.c int main() { char c = 1000; return c; } --=-=-= Content-Type: text/x-perl Content-Disposition: attachment; filename=test.pl @arr = [1,2,3,4]; @arr[1] = -1; --=-=-=-- From unknown Tue Sep 09 06:30:23 2025 X-Loop: help-debbugs@gnu.org Subject: bug#14217: Acknowledgement (24.3.50; patch: flymake.el -- warning predicate) Resent-From: Eduard Wiebe Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 01 Jun 2013 15:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 14217 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 14217@debbugs.gnu.org Received: via spool by 14217-submit@debbugs.gnu.org id=B14217.137010205018259 (code B ref 14217); Sat, 01 Jun 2013 15:55:02 +0000 Received: (at 14217) by debbugs.gnu.org; 1 Jun 2013 15:54:10 +0000 Received: from localhost ([127.0.0.1]:46303 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Uio89-0004kM-9C for submit@debbugs.gnu.org; Sat, 01 Jun 2013 11:54:10 -0400 Received: from wp093.webpack.hosteurope.de ([80.237.132.100]:43286) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Uio86-0004jg-CY for 14217@debbugs.gnu.org; Sat, 01 Jun 2013 11:54:07 -0400 Received: from f048164085.adsl.alicedsl.de ([78.48.164.85] helo=nirvana); authenticated by wp093.webpack.hosteurope.de running ExIM with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) id 1Uio6M-0006aO-Ow; Sat, 01 Jun 2013 17:52:18 +0200 Received: from ew by nirvana with local (Exim 4.72) (envelope-from ) id 1Uio6F-0000ej-Rz for 14217@debbugs.gnu.org; Sat, 01 Jun 2013 17:52:11 +0200 From: Eduard Wiebe References: <87y5ci5faa.fsf@pusto.de> Date: Sat, 01 Jun 2013 17:52:11 +0200 In-Reply-To: (GNU bug Tracking System's message of "Tue, 16 Apr 2013 19:42:01 +0000") Message-ID: <87obbpx1zo.fsf@pusto.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-bounce-key: webpack.hosteurope.de;ew@pusto.de;1370101945;2894c9a5; X-Spam-Score: 0.1 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) Any concerns? -- Eduard Wiebe From unknown Tue Sep 09 06:30:23 2025 X-Loop: help-debbugs@gnu.org Subject: bug#14217: 24.3.50; patch: flymake.el -- warning predicate Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 16 Jun 2013 01:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 14217 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Eduard Wiebe Cc: 14217@debbugs.gnu.org Received: via spool by 14217-submit@debbugs.gnu.org id=B14217.13713468841142 (code B ref 14217); Sun, 16 Jun 2013 01:42:02 +0000 Received: (at 14217) by debbugs.gnu.org; 16 Jun 2013 01:41:24 +0000 Received: from localhost ([127.0.0.1]:47232 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Uo1y7-0000IJ-Mc for submit@debbugs.gnu.org; Sat, 15 Jun 2013 21:41:23 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.182]:50571) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Uo1y5-0000Hv-KY for 14217@debbugs.gnu.org; Sat, 15 Jun 2013 21:41:21 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av8EABK/CFFFpZVy/2dsb2JhbABEuzWDWRdzgh4BAQQBViMFCwsOJhIUGA0kiB4GwS2RCgOkeoFegxM X-IPAS-Result: Av8EABK/CFFFpZVy/2dsb2JhbABEuzWDWRdzgh4BAQQBViMFCwsOJhIUGA0kiB4GwS2RCgOkeoFegxM X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="16487683" Received: from 69-165-149-114.dsl.teksavvy.com (HELO fmsmemgm.homelinux.net) ([69.165.149.114]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 15 Jun 2013 21:41:10 -0400 Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id 97067AE2E2; Sat, 15 Jun 2013 21:41:15 -0400 (EDT) From: Stefan Monnier Message-ID: References: <87y5ci5faa.fsf@pusto.de> Date: Sat, 15 Jun 2013 21:41:15 -0400 In-Reply-To: <87y5ci5faa.fsf@pusto.de> (Eduard Wiebe's message of "Tue, 16 Apr 2013 23:36:29 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.3 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.3 (/) > here is a patch, which extends current flymake mechanism for classifing > error text as warning. Looks good, thanks, please install. Stefan From unknown Tue Sep 09 06:30:23 2025 X-Loop: help-debbugs@gnu.org Subject: bug#14217: 24.3.50; patch: flymake.el -- warning predicate Resent-From: Eduard Wiebe Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 16 Jun 2013 10:29:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 14217 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Stefan Monnier Cc: 14217@debbugs.gnu.org Received: via spool by 14217-submit@debbugs.gnu.org id=B14217.13713785013558 (code B ref 14217); Sun, 16 Jun 2013 10:29:02 +0000 Received: (at 14217) by debbugs.gnu.org; 16 Jun 2013 10:28:21 +0000 Received: from localhost ([127.0.0.1]:47707 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1UoAC3-0000vH-VK for submit@debbugs.gnu.org; Sun, 16 Jun 2013 06:28:20 -0400 Received: from wp093.webpack.hosteurope.de ([80.237.132.100]:41264) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1UoAC0-0000uo-R7 for 14217@debbugs.gnu.org; Sun, 16 Jun 2013 06:28:17 -0400 Received: from f049234254.adsl.alicedsl.de ([78.49.234.254] helo=nirvana); authenticated by wp093.webpack.hosteurope.de running ExIM with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) id 1UoABu-0000GP-4s; Sun, 16 Jun 2013 12:28:10 +0200 Received: from ew by nirvana with local (Exim 4.72) (envelope-from ) id 1UoABu-0000oC-Ao; Sun, 16 Jun 2013 12:28:10 +0200 From: Eduard Wiebe In-Reply-To: (Stefan Monnier's message of "Sat, 15 Jun 2013 21:41:15 -0400") References: <87y5ci5faa.fsf@pusto.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) Date: Sun, 16 Jun 2013 12:28:10 +0200 Message-ID: <874ncymjt1.fsf@pusto.de> MIME-Version: 1.0 Content-Type: text/plain X-bounce-key: webpack.hosteurope.de;ew@pusto.de;1371378496;07518067; X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Stefan Monnier 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. From unknown Tue Sep 09 06:30:23 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.503 (Entity 5.503) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Eduard Wiebe Subject: bug#14217: closed (Re: bug#14217: 24.3.50; patch: flymake.el -- warning predicate) Message-ID: References: <87y5ci5faa.fsf@pusto.de> X-Gnu-PR-Message: they-closed 14217 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: patch Reply-To: 14217@debbugs.gnu.org Date: Fri, 21 Jun 2013 14:38:03 +0000 Content-Type: multipart/mixed; boundary="----------=_1371825483-21980-1" This is a multi-part message in MIME format... ------------=_1371825483-21980-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #14217: 24.3.50; patch: flymake.el -- warning predicate which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 14217@debbugs.gnu.org. --=20 14217: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D14217 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1371825483-21980-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 14217-done) by debbugs.gnu.org; 21 Jun 2013 14:37:04 +0000 Received: from localhost ([127.0.0.1]:32847 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Uq2SU-0005fe-Ra for submit@debbugs.gnu.org; Fri, 21 Jun 2013 10:37:03 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.182]:43635) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Uq2SS-0005eq-5O for 14217-done@debbugs.gnu.org; Fri, 21 Jun 2013 10:37:00 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av8EABK/CFFFpZVy/2dsb2JhbABEuzWDWRdzgh4BAQQBViMFCwsOJhIUGA0kiB4GwS2RCgOkeoFegxM X-IPAS-Result: Av8EABK/CFFFpZVy/2dsb2JhbABEuzWDWRdzgh4BAQQBViMFCwsOJhIUGA0kiB4GwS2RCgOkeoFegxM X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="16873862" Received: from 69-165-149-114.dsl.teksavvy.com (HELO pastel.home) ([69.165.149.114]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 21 Jun 2013 10:36:49 -0400 Received: by pastel.home (Postfix, from userid 20848) id C240962CFF; Fri, 21 Jun 2013 10:36:53 -0400 (EDT) From: Stefan Monnier To: Eduard Wiebe Subject: Re: bug#14217: 24.3.50; patch: flymake.el -- warning predicate Message-ID: References: <87y5ci5faa.fsf@pusto.de> Date: Fri, 21 Jun 2013 10:36:53 -0400 In-Reply-To: <87y5ci5faa.fsf@pusto.de> (Eduard Wiebe's message of "Tue, 16 Apr 2013 23:36:29 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 14217-done Cc: 14217-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.3 (/) > here is a patch, which extends current flymake mechanism for classifing > error text as warning. Thank you, installed finally, Stefan ------------=_1371825483-21980-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 16 Apr 2013 19:41:05 +0000 Received: from localhost ([127.0.0.1]:55175 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1USBkW-0004PQ-7Q for submit@debbugs.gnu.org; Tue, 16 Apr 2013 15:41:04 -0400 Received: from eggs.gnu.org ([208.118.235.92]:36983) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1USBkT-0004P9-Vu for submit@debbugs.gnu.org; Tue, 16 Apr 2013 15:41:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1USBgE-0003CT-SM for submit@debbugs.gnu.org; Tue, 16 Apr 2013 15:36:43 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:47633) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USBgE-0003CP-Q8 for submit@debbugs.gnu.org; Tue, 16 Apr 2013 15:36:38 -0400 Received: from eggs.gnu.org ([208.118.235.92]:48291) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USBg6-0000On-DO for bug-gnu-emacs@gnu.org; Tue, 16 Apr 2013 15:36:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1USBg0-0002uI-Cw for bug-gnu-emacs@gnu.org; Tue, 16 Apr 2013 15:36:30 -0400 Received: from wp093.webpack.hosteurope.de ([80.237.132.100]:45434) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USBfz-0002to-VR for bug-gnu-emacs@gnu.org; Tue, 16 Apr 2013 15:36:24 -0400 Received: from f049237196.adsl.alicedsl.de ([78.49.237.196] helo=nirvana); authenticated by wp093.webpack.hosteurope.de running ExIM with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) id 1USBfw-0007kM-N0; Tue, 16 Apr 2013 21:36:21 +0200 Received: from ew by nirvana with local (Exim 4.72) (envelope-from ) id 1USDYE-0000gr-Am for bug-gnu-emacs@gnu.org; Tue, 16 Apr 2013 23:36:30 +0200 From: Eduard Wiebe To: bug-gnu-emacs@gnu.org Subject: 24.3.50; patch: flymake.el -- warning predicate Date: Tue, 16 Apr 2013 23:36:29 +0200 Message-ID: <87y5ci5faa.fsf@pusto.de> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-bounce-key: webpack.hosteurope.de;ew@pusto.de;1366140983;6d925acb; X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 208.118.235.17 X-Spam-Score: -4.2 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.9 (------) --=-=-= Content-Type: text/plain Hello, here is a patch, which extends current flymake mechanism for classifing error text as warning. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=flymake.warn.pred.patch 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 + + * flymake.texi (Parsing the output, Customizable variables): Add + reference to `flymake-warning-predicate'. + 2013-04-15 Michael Albinus * 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 + + 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 * 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 "")) - (if (and err-text (string-match flymake-warning-re err-text)) - (setq err-type "w") - ) + (if (null err-text) + (setq err-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 + + 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 * automated/add-log-tests.el: New file. (Bug#14112) --=-=-= Content-Type: text/plain The corresponding test driver: --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=flymake-tests.el Content-Transfer-Encoding: quoted-printable ;;; flymake-tests.el --- Test suite for flymake ;; Copyright (C) 2011-2013 Free Software Foundation, Inc. ;; Author: Eduard Wiebe ;; This file is part of GNU Emacs. ;; GNU Emacs is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs. If not, see . ;;; Commentary: ;;; Code: (require 'ert) (require 'flymake) (defgroup flymake-tests nil "Test suite for flymake.") ;; Warning predicate (defun flymake-tests--current-face (file predicate) (let ((buffer (find-file-noselect file))) (unwind-protect (with-current-buffer (find-file-noselect file) (setq-local flymake-warning-predicate predicate) (goto-char (point-min)) (flymake-mode 1) (sleep-for (+ 0.5 flymake-no-changes-timeout)) ; XXX: is this rel= iable enough? (flymake-goto-next-error) (face-at-point)) (and buffer (kill-buffer buffer))))) (ert-deftest warnining-predicate-rx-gcc () "Test GCC warning via regexp predicate." :expected-result (if (executable-find "gcc") :passed :failed) (should (eq 'flymake-warnline (flymake-tests--current-face "flymake/warnpred/test.c" "^[Ww]arning")))) (ert-deftest warning-predicate-function-gcc () "Test GCC warning via function predicate." :expected-result (if (and (executable-find "gcc") (executable-find "make"= )) :passed :failed) (should (eq 'flymake-warnline (flymake-tests--current-face "flymake/warnpred/test.c" (lambda (msg) (string-match "^[Ww]arning" msg)))))) (ert-deftest warning-predicate-rx-perl () "Test perl warning via regular expression predicate." :expected-result (if (executable-find "perl") :passed :failed) (should (eq 'flymake-warnline (flymake-tests--current-face "flymake/warnpred/test.pl" "^Scalar value")))) (ert-deftest warning-predicate-function-perl () "Test perl warning via function predicate." :expected-result (if (executable-find "perl") :passed :failed) (should (eq 'flymake-warnline (flymake-tests--current-face "flymake/warnpred/test.pl" (lambda (msg) (string-match "^Scalar value" msg)))))) (provide 'flymake-tests) ;;; flymake.el ends here --=-=-= Content-Type: text/plain Following files are test helper and should be placed under test/automated/flymake/warnpred directory. --=-=-= Content-Type: application/octet-stream Content-Disposition: attachment; filename=Makefile Content-Transfer-Encoding: base64 IyBNYWtlZmlsZSBmb3IgZmx5bWFrZSB0ZXN0cwoKQ0NfT1BUUyA9IC1XYWxsCgpjaGVjay1zeW50 YXg6CgkkKENDKSAkKENDX09QVFMpICR7Q0hLX1NPVVJDRVN9CgojIGVvZgo= --=-=-= Content-Type: text/x-csrc Content-Disposition: attachment; filename=test.c int main() { char c = 1000; return c; } --=-=-= Content-Type: text/x-perl Content-Disposition: attachment; filename=test.pl @arr = [1,2,3,4]; @arr[1] = -1; --=-=-=-- ------------=_1371825483-21980-1--