unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#34479: Incorrect classification of messages in compilation-mode buffer
@ 2019-02-14 16:00 Daniel Lopez
  2019-02-14 16:05 ` Daniel Lopez
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Lopez @ 2019-02-14 16:00 UTC (permalink / raw)
  To: 34479

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

Reproduce:

- Open the attached test program compilation_test.c in Emacs
- M-x compile
- Enter compile command "gcc -c compilation_test.c"

In the resulting *compilation* buffer, there should be a mixture of 
"error", "warning" and "note" messages. Trouble is they're all parsed as 
errors - hence they're all coloured in red, and querying any one's type 
by moving point onto it and evaluating "(compilation--message->type 
(get-text-property (point) 'compilation-message))" always returns 2, 
though warnings should return 1 and notes should return 0. Commands that 
jump between previous/next error also behave correspondingly wrongly.

Fix:

The attached fix_compilation_message_type.patch, applied to Git master, 
fixes it for me.

It seems like the old code was accidentally using the same variable for 
the TYPE field of the current rule from compilation-error-regexp-alist, 
and in an inner loop, the actual type that the current message from the 
compilation buffer was resolved to be, so the resolved type of the first 
message tends to get carried down into the following ones.

Daniel

[-- Attachment #2: compilation_test.c --]
[-- Type: text/x-csrc, Size: 165 bytes --]


int main(int argc, char ** argv)
{
    int v = something;

    int w = something_else;

    int x = 4/0;

    #define MM w[10]
    int y = MM;

    return "abc";
}

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

* bug#34479: Incorrect classification of messages in compilation-mode buffer
  2019-02-14 16:00 bug#34479: Incorrect classification of messages in compilation-mode buffer Daniel Lopez
@ 2019-02-14 16:05 ` Daniel Lopez
  2019-02-15  8:02   ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Lopez @ 2019-02-14 16:05 UTC (permalink / raw)
  To: 34479

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

Argh, I forgot to attach the patch. Here it is!

Daniel

[-- Attachment #2: fix_compilation_message_type.patch --]
[-- Type: text/x-patch, Size: 1443 bytes --]

diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index 581a98d56c..0303314c59 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -1425,17 +1425,17 @@ compilation-parse-errors
                              file line end-line col end-col (or type 2) fmt))
 
             (when (integerp file)
-              (setq type (if (consp type)
-                             (compilation-type type)
-                           (or type 2)))
-              (compilation--note-type type)
-
-              (compilation--put-prop
-               file 'font-lock-face
-               (symbol-value (aref [compilation-info-face
-                                    compilation-warning-face
-                                    compilation-error-face]
-                                   type))))
+              (let ((this-type (if (consp type)
+                                   (compilation-type type)
+                                 (or type 2))))
+                (compilation--note-type type)
+
+                (compilation--put-prop
+                 file 'font-lock-face
+                 (symbol-value (aref [compilation-info-face
+                                      compilation-warning-face
+                                      compilation-error-face]
+                                     this-type)))))
 
             (compilation--put-prop
              line 'font-lock-face compilation-line-face)

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

* bug#34479: Incorrect classification of messages in compilation-mode buffer
  2019-02-14 16:05 ` Daniel Lopez
@ 2019-02-15  8:02   ` Eli Zaretskii
  2019-02-25 13:26     ` Tobias Bading
  0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2019-02-15  8:02 UTC (permalink / raw)
  To: Daniel Lopez; +Cc: 34479-done

> From: Daniel Lopez <daniel.lopez999@gmail.com>
> Date: Thu, 14 Feb 2019 16:05:10 +0000
> 
> Argh, I forgot to attach the patch. Here it is!

Thanks.  This is a relatively recent regression, so I pushed it to the
emacs-26 branch.

Please in the future include a ChangeLog-style commit log message with
your patches.





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

* bug#34479: Incorrect classification of messages in compilation-mode buffer
  2019-02-15  8:02   ` Eli Zaretskii
@ 2019-02-25 13:26     ` Tobias Bading
  2019-02-25 16:03       ` Daniel Lopez
  2019-03-01 10:07       ` Eli Zaretskii
  0 siblings, 2 replies; 6+ messages in thread
From: Tobias Bading @ 2019-02-25 13:26 UTC (permalink / raw)
  To: 34479; +Cc: Daniel Lopez

I also discovered this bug a few days ago and came up with the same fix as Daniel. However, there’s a small mistake in his patch which results in incorrect error numbers in the mode line. The compilation--note-type call should look like this:

diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index 146af5a..368b088 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -1441,7 +1441,7 @@ compilation-parse-errors
               (let ((this-type (if (consp type)
                                    (compilation-type type)
                                  (or type 2))))
-                (compilation--note-type type)
+                (compilation--note-type this-type)
 
                 (compilation--put-prop
                  file 'font-lock-face

Regards,
Tobias






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

* bug#34479: Incorrect classification of messages in compilation-mode buffer
  2019-02-25 13:26     ` Tobias Bading
@ 2019-02-25 16:03       ` Daniel Lopez
  2019-03-01 10:07       ` Eli Zaretskii
  1 sibling, 0 replies; 6+ messages in thread
From: Daniel Lopez @ 2019-02-25 16:03 UTC (permalink / raw)
  To: Tobias Bading, 34479

 > diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
 > index 146af5a..368b088 100644
 > --- a/lisp/progmodes/compile.el
 > +++ b/lisp/progmodes/compile.el
 > @@ -1441,7 +1441,7 @@ compilation-parse-errors
 >                 (let ((this-type (if (consp type)
 >                                      (compilation-type type)
 >                                    (or type 2))))
 > -                (compilation--note-type type)
 > +                (compilation--note-type this-type)
 >
 >                   (compilation--put-prop
 >                    file 'font-lock-face

Hi Tobias,

Just verified it here - I agree, that should be changed as well.

(In fact, the copy of the function that's currently in my init file to
replace the original just for now, already has that extra change. Not
sure why that didn't make it into my original patch. Thanks for spotting.)

Daniel





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

* bug#34479: Incorrect classification of messages in compilation-mode buffer
  2019-02-25 13:26     ` Tobias Bading
  2019-02-25 16:03       ` Daniel Lopez
@ 2019-03-01 10:07       ` Eli Zaretskii
  1 sibling, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2019-03-01 10:07 UTC (permalink / raw)
  To: Tobias Bading; +Cc: 34479, daniel.lopez999

> From: Tobias Bading <tbading@web.de>
> Date: Mon, 25 Feb 2019 14:26:38 +0100
> Cc: Daniel Lopez <daniel.lopez999@gmail.com>,
>  Eli Zaretskii <eliz@gnu.org>
> 
> I also discovered this bug a few days ago and came up with the same fix as Daniel. However, there’s a small mistake in his patch which results in incorrect error numbers in the mode line. The compilation--note-type call should look like this:
> 
> diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
> index 146af5a..368b088 100644
> --- a/lisp/progmodes/compile.el
> +++ b/lisp/progmodes/compile.el
> @@ -1441,7 +1441,7 @@ compilation-parse-errors
>                (let ((this-type (if (consp type)
>                                     (compilation-type type)
>                                   (or type 2))))
> -                (compilation--note-type type)
> +                (compilation--note-type this-type)
>  
>                  (compilation--put-prop
>                   file 'font-lock-face

Thanks, pushed to the emacs-26 branch.





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

end of thread, other threads:[~2019-03-01 10:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-14 16:00 bug#34479: Incorrect classification of messages in compilation-mode buffer Daniel Lopez
2019-02-14 16:05 ` Daniel Lopez
2019-02-15  8:02   ` Eli Zaretskii
2019-02-25 13:26     ` Tobias Bading
2019-02-25 16:03       ` Daniel Lopez
2019-03-01 10:07       ` Eli Zaretskii

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).