unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] Add support for parsing column numbers in Visual Studio messages
       [not found] <b6edc68b-11b1-3567-d908-875d8134cfc3.ref@yahoo.es>
@ 2020-07-26 15:22 ` Daniel Martín
  2020-07-26 15:52   ` Mattias Engdegård
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Martín @ 2020-07-26 15:22 UTC (permalink / raw)
  To: emacs-devel

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

Hi, all:

The other day I opened a compilation log from a recent version of Visual 
Studio in Emacs (Visual Studio 2019) and I noticed that Emacs doesn't 
highlight compilation errors from MSVC 2019 correctly. A simple recipe 
to reproduce the problem is:

1. emacs -Q

2. Paste the following text:

C:\tmp\sample.cpp(101,11): error C4101: 'bias0123': unreferenced local 
variable [C:\tmp\libsample.vcxproj]
C:\tmp\sample.cpp(101,21): error C4101: 'bias4567': unreferenced local 
variable [C:\tmp\libsample.vcxproj]

3. M-x compilation-minor-mode

Expected behavior: Errors are highlighted and you can navigate them 
using compilation-next-error and compilation-previous-error.

Actual behavior: Errors are not highlighted.

The problem seems to happen because the regular expression for MSVC in 
compile.el doesn't take into account column numbers. Attached is a 
proposed patch to implement support for it.

Thanks,

Daniel Mart??n


[-- Attachment #2: 0001-Add-support-for-parsing-column-numbers-in-Visual-Stu.patch --]
[-- Type: text/plain, Size: 4032 bytes --]

From 05db2787aee4ad1559cd5d5867f8ad30ec9323c4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Mart=C3=ADn?= <mardani29@yahoo.es>
Date: Sun, 26 Jul 2020 15:24:59 +0200
Subject: [PATCH] Add support for parsing column numbers in Visual Studio
 messages

* lisp/progmodes/compile.el (compilation-error-regexp-alist-alist):
Extend regular expression to match optional column numbers.
*
test/lisp/progmodes/compile-tests.el (compile-tests--test-regexps-data):
Add a test.
* test/lisp/progmodes/compile-tests.el (compile-test-error-regexps):
Update the total number of compilation errors in a test.
* etc/compilation.txt: Update compilation.txt with the newly supported
message format.
* etc/NEWS: Advertise the feature.
---
 etc/NEWS                             | 3 +++
 etc/compilation.txt                  | 1 +
 lisp/progmodes/compile.el            | 4 ++--
 test/lisp/progmodes/compile-tests.el | 4 +++-
 4 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 650b95867f..99a7a81f90 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -380,6 +380,9 @@ case-insensitive matching of messages when the old behaviour is
 required, but the recommended solution is to use a correctly matching
 regexp instead.
 
+---
+*** Messages from Visual Studio that mention column numbers are now recognized.
+
 ** Hi Lock mode
 
 ---
diff --git a/etc/compilation.txt b/etc/compilation.txt
index 8f7e290678..11aefc6bc6 100644
--- a/etc/compilation.txt
+++ b/etc/compilation.txt
@@ -381,6 +381,7 @@ made it more strict about the error message that follows.
 keyboard handler.c(537) : warning C4005: 'min' : macro redefinition
 d:\tmp\test.c(23) : error C2143: syntax error : missing ';' before 'if'
 d:\tmp\test.c(1145) : see declaration of 'nsRefPtr'
+c:\tmp\test.cpp(101,11): error C4101: 'bias0123': unreferenced local variable [c:\tmp\project.vcxproj]
 1>test_main.cpp(29): error C2144: syntax error : 'int' should be preceded by ';'
 1>test_main.cpp(29): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
 1>
diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index a76a3c44a3..5315957868 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -221,9 +221,9 @@ compilation-error-regexp-alist-alist
      ;; considered before EDG.
      ;; The message may be a "warning", "error", or "fatal error" with
      ;; an error code, or "see declaration of" without an error code.
-     "^ *\\([0-9]+>\\)?\\(\\(?:[a-zA-Z]:\\)?[^ :(\t\n][^:(\t\n]*\\)(\\([0-9]+\\)) ?\
+     "^ *\\([0-9]+>\\)?\\(\\(?:[a-zA-Z]:\\)?[^ :(\t\n][^:(\t\n]*\\)(\\([0-9]+\\)\\(?:,\\([0-9]+\\)\\)?) ?\
 : \\(?:see declaration\\|\\(?:warnin\\(g\\)\\|[a-z ]+\\) C[0-9]+:\\)"
-     2 3 nil (4))
+     2 3 4 (5))
 
     (edg-1
      "^\\([^ \n]+\\)(\\([0-9]+\\)): \\(?:error\\|warnin\\(g\\)\\|remar\\(k\\)\\)"
diff --git a/test/lisp/progmodes/compile-tests.el b/test/lisp/progmodes/compile-tests.el
index cd736497e6..509db3000a 100644
--- a/test/lisp/progmodes/compile-tests.el
+++ b/test/lisp/progmodes/compile-tests.el
@@ -267,6 +267,8 @@ compile-tests--test-regexps-data
      3 nil 29 "test_main.cpp")
     ("1>test_main.cpp(29): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int"
      3 nil 29 "test_main.cpp")
+    ("C:\\tmp\\test.cpp(101,11): error C4101: 'bias0123': unreferenced local variable [C:\\tmp\\project.vcxproj]"
+     1 11 101 "C:\\tmp\\test.cpp")
     ;; watcom
     ("..\\src\\ctrl\\lister.c(109): Error! E1009: Expecting ';' but found '{'"
      1 nil 109 "..\\src\\ctrl\\lister.c")
@@ -434,7 +436,7 @@ compile-test-error-regexps
           (compilation-num-warnings-found 0)
           (compilation-num-infos-found 0))
       (mapc #'compile--test-error-line compile-tests--test-regexps-data)
-      (should (eq compilation-num-errors-found 94))
+      (should (eq compilation-num-errors-found 95))
       (should (eq compilation-num-warnings-found 37))
       (should (eq compilation-num-infos-found 26)))))
 
-- 
2.25.0


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

* Re: [PATCH] Add support for parsing column numbers in Visual Studio messages
  2020-07-26 15:22 ` [PATCH] Add support for parsing column numbers in Visual Studio messages Daniel Martín
@ 2020-07-26 15:52   ` Mattias Engdegård
  2020-07-26 20:57     ` Daniel Martín
  0 siblings, 1 reply; 5+ messages in thread
From: Mattias Engdegård @ 2020-07-26 15:52 UTC (permalink / raw)
  To: Daniel Martín; +Cc: emacs-devel

26 juli 2020 kl. 17.22 skrev Daniel Martín <mardani29@yahoo.es>:

> The problem seems to happen because the regular expression for MSVC in compile.el doesn't take into account column numbers. Attached is a proposed patch to implement support for it.

Thank you! This looks all right. Can you confirm that the column numbering works like in GCC -- ie, the leftmost column is 1, not 0?




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

* Re: [PATCH] Add support for parsing column numbers in Visual Studio messages
  2020-07-26 15:52   ` Mattias Engdegård
@ 2020-07-26 20:57     ` Daniel Martín
  2020-07-26 21:07       ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Martín @ 2020-07-26 20:57 UTC (permalink / raw)
  To: Mattias Engdegård; +Cc: emacs-devel

Mattias Engdegård <mattiase@acm.org> writes:

> 26 juli 2020 kl. 17.22 skrev Daniel Martín <mardani29@yahoo.es>:
>
>> The problem seems to happen because the regular expression for MSVC in compile.el doesn't take into account column numbers. Attached is a proposed patch to implement support for it.
>
> Thank you! This looks all right. Can you confirm that the column numbering works like in GCC -- ie, the leftmost column is 1, not 0?

Yes, it works like in GCC, so I don't think it needs further adjustment.

BTW, could you send me the FSF copyright assignment form? I may
contribute some substantial work to Emacs in the future. Thanks.

--
Daniel Martín



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

* Re: [PATCH] Add support for parsing column numbers in Visual Studio messages
  2020-07-26 20:57     ` Daniel Martín
@ 2020-07-26 21:07       ` Stefan Monnier
  2020-08-28 18:14         ` Daniel Martín
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2020-07-26 21:07 UTC (permalink / raw)
  To: Daniel Martín; +Cc: Mattias Engdegård, emacs-devel

> BTW, could you send me the FSF copyright assignment form? I may
> contribute some substantial work to Emacs in the future.  Thanks.

Por supuesto.  Fill the form below and send it as instructed to the FSF
so they can send you the relevant paperwork to sign.
Thanks,


        Stefan


Please email the following information to assign@gnu.org, and we
will send you the assignment form for your past and future changes.

Please use your full legal name (in ASCII characters) as the subject
line of the message.
----------------------------------------------------------------------
REQUEST: SEND FORM FOR PAST AND FUTURE CHANGES

[What is the name of the program or package you're contributing to?]


[Did you copy any files or text written by someone else in these changes?
Even if that material is free software, we need to know about it.]


[Do you have an employer who might have a basis to claim to own
your changes?  Do you attend a school which might make such a claim?]


[For the copyright registration, what country are you a citizen of?]


[What year were you born?]


[Please write your email address here.]


[Please write your postal address here.]





[Which files have you changed so far, and which new files have you written
so far?]




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

* Re: [PATCH] Add support for parsing column numbers in Visual Studio messages
  2020-07-26 21:07       ` Stefan Monnier
@ 2020-08-28 18:14         ` Daniel Martín
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Martín @ 2020-08-28 18:14 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Mattias Engdegård, emacs-devel

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

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

> Por supuesto.  Fill the form below and send it as instructed to the FSF
> so they can send you the relevant paperwork to sign.
> Thanks,

Hello again.

I've just received confirmation that my signed paperwork has been
processed by the FSF staff.

I've attached a new version of the patch that applies to today's master
branch.

Thanks.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-support-for-parsing-column-numbers-in-Visual-Stu.patch --]
[-- Type: text/x-patch, Size: 4031 bytes --]

From 7a4b7724abeee9bcda393b2ec6df2bcf7c15806e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Mart=C3=ADn?= <mardani29@yahoo.es>
Date: Sun, 26 Jul 2020 15:24:59 +0200
Subject: [PATCH] Add support for parsing column numbers in Visual Studio
 messages

* lisp/progmodes/compile.el (compilation-error-regexp-alist-alist):
Extend regular expression to match optional column numbers.
*
test/lisp/progmodes/compile-tests.el (compile-tests--test-regexps-data):
Add a test.
* test/lisp/progmodes/compile-tests.el (compile-test-error-regexps):
Update the total number of compilation errors in a test.
* etc/compilation.txt: Update compilation.txt with the newly supported
message format.
* etc/NEWS: Advertise the feature.
---
 etc/NEWS                             | 3 +++
 etc/compilation.txt                  | 1 +
 lisp/progmodes/compile.el            | 4 ++--
 test/lisp/progmodes/compile-tests.el | 4 +++-
 4 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 964b626d7b..84aebecf7e 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -557,6 +557,9 @@ case-insensitive matching of messages when the old behavior is
 required, but the recommended solution is to use a correctly matching
 regexp instead.
 
+---
+*** Messages from Visual Studio that mention column numbers are now recognized.
+
 ** Hi Lock mode
 
 ---
diff --git a/etc/compilation.txt b/etc/compilation.txt
index 8f7e290678..11aefc6bc6 100644
--- a/etc/compilation.txt
+++ b/etc/compilation.txt
@@ -381,6 +381,7 @@ made it more strict about the error message that follows.
 keyboard handler.c(537) : warning C4005: 'min' : macro redefinition
 d:\tmp\test.c(23) : error C2143: syntax error : missing ';' before 'if'
 d:\tmp\test.c(1145) : see declaration of 'nsRefPtr'
+c:\tmp\test.cpp(101,11): error C4101: 'bias0123': unreferenced local variable [c:\tmp\project.vcxproj]
 1>test_main.cpp(29): error C2144: syntax error : 'int' should be preceded by ';'
 1>test_main.cpp(29): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
 1>
diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index a043bbcfa3..731db0fd6d 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -221,9 +221,9 @@ compilation-error-regexp-alist-alist
      ;; considered before EDG.
      ;; The message may be a "warning", "error", or "fatal error" with
      ;; an error code, or "see declaration of" without an error code.
-     "^ *\\([0-9]+>\\)?\\(\\(?:[a-zA-Z]:\\)?[^ :(\t\n][^:(\t\n]*\\)(\\([0-9]+\\)) ?\
+     "^ *\\([0-9]+>\\)?\\(\\(?:[a-zA-Z]:\\)?[^ :(\t\n][^:(\t\n]*\\)(\\([0-9]+\\)\\(?:,\\([0-9]+\\)\\)?) ?\
 : \\(?:see declaration\\|\\(?:warnin\\(g\\)\\|[a-z ]+\\) C[0-9]+:\\)"
-     2 3 nil (4))
+     2 3 4 (5))
 
     (edg-1
      "^\\([^ \n]+\\)(\\([0-9]+\\)): \\(?:error\\|warnin\\(g\\)\\|remar\\(k\\)\\)"
diff --git a/test/lisp/progmodes/compile-tests.el b/test/lisp/progmodes/compile-tests.el
index d566e7dd86..819f2e78c2 100644
--- a/test/lisp/progmodes/compile-tests.el
+++ b/test/lisp/progmodes/compile-tests.el
@@ -267,6 +267,8 @@ compile-tests--test-regexps-data
      3 nil 29 "test_main.cpp")
     ("1>test_main.cpp(29): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int"
      3 nil 29 "test_main.cpp")
+    ("C:\\tmp\\test.cpp(101,11): error C4101: 'bias0123': unreferenced local variable [C:\\tmp\\project.vcxproj]"
+     1 11 101 "C:\\tmp\\test.cpp")
     ;; watcom
     ("..\\src\\ctrl\\lister.c(109): Error! E1009: Expecting ';' but found '{'"
      1 nil 109 "..\\src\\ctrl\\lister.c")
@@ -434,7 +436,7 @@ compile-test-error-regexps
           (compilation-num-warnings-found 0)
           (compilation-num-infos-found 0))
       (mapc #'compile--test-error-line compile-tests--test-regexps-data)
-      (should (eq compilation-num-errors-found 94))
+      (should (eq compilation-num-errors-found 95))
       (should (eq compilation-num-warnings-found 35))
       (should (eq compilation-num-infos-found 28)))))
 
-- 
2.28.0


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

end of thread, other threads:[~2020-08-28 18:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <b6edc68b-11b1-3567-d908-875d8134cfc3.ref@yahoo.es>
2020-07-26 15:22 ` [PATCH] Add support for parsing column numbers in Visual Studio messages Daniel Martín
2020-07-26 15:52   ` Mattias Engdegård
2020-07-26 20:57     ` Daniel Martín
2020-07-26 21:07       ` Stefan Monnier
2020-08-28 18:14         ` Daniel Martín

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