[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/d-mode e9278a9 114/346: Reimplement compilation-mode error
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/d-mode e9278a9 114/346: Reimplement compilation-mode error message detection for DMD |
Date: |
Sun, 29 Aug 2021 11:00:13 -0400 (EDT) |
branch: elpa/d-mode
commit e9278a992332e7e48465d71b294ff5856b1b54ee
Author: Vladimir Panteleev <git@thecybershadow.net>
Commit: Vladimir Panteleev <git@thecybershadow.net>
Reimplement compilation-mode error message detection for DMD
This addresses the following issues:
- Column numbers were not recognized in DMD error message when -vcolumns
is used. Error messages are now correctly detected with and without
column numbers.
- Continuation lines, such as when indicating the instantiation point of
a failed template instantiation, were not detected. They are now
detected as "information" level messages.
- The previous implementation was impossible to maintain, as it was
implemented as a single 235-character-long hand-optimized regular
expression. The new implementation uses the rx package to specify the
regular expression declaratively as lisp sexps.
- The previous implementation was not accompanied by any tests. A test
file has been added.
---
d-mode.el | 44 ++++++++++++++++++++++++++++++++------------
tests/I0069.txt | 7 +++++++
2 files changed, 39 insertions(+), 12 deletions(-)
diff --git a/d-mode.el b/d-mode.el
index 6958637..4af9cec 100644
--- a/d-mode.el
+++ b/d-mode.el
@@ -75,6 +75,9 @@
;; The set-difference function is used from the Common Lisp extensions.
(require 'cl)
+;; Used to specify regular expressions in a sane way.
+(require 'rx)
+
;; These are only required at compile time to get the sources for the
;; language constants. (The cc-fonts require and the font-lock
;; related constants could additionally be put inside an
@@ -184,18 +187,35 @@ operators."
;;; Patterns to recognize the compiler generated messages
-;; The following regexp recognizes messages generated by the LDC and DMD
-;; compilers. Subexpression 1 is the filename, 2 is the line number, nil is
the
-;; column, because it's not present in the LDC error messages, and the
-;; subexpressions 3 and 4 are the message type -- error, warning, or info.
-
-;; GDC messages are recognized by gnu symbol already listed in
-;; compilation-error-regexp-alist.
-(add-to-list 'compilation-error-regexp-alist-alist
- '(ldc
- "^\\([^: \n]+\\)(\\([0-9]+\\)): \\(?:
*\\(?3:\\(?:W\\(?::\\|arning\\)\\|warning\\)\\)\\|
*\\(?4:[Ii]nfo\\(?:\\>\\|rmationa?l?\\)\\|I:\\|\\[ skipping \\.+
]\\|instantiated from\\|required from\\|[Nn]ote\\)\\| *\\(?:[Ee]rror\\)\\|
*Deprecation\\)"
- 1 2 nil (3 . 4)))
-(add-to-list 'compilation-error-regexp-alist 'ldc)
+(defun d-mode-add-dmd-message-pattern (expr level symbol)
+ "Register DMD `compile' pattern for an error level.
+
+EXPR is the `rx' message sub-expression indicating the error level LEVEL.
+The expression is added to `compilation-error-regexp-alist' and
+`compilation-error-regexp-alist-alist' as SYMBOL."
+ (add-to-list
+ 'compilation-error-regexp-alist-alist
+ `(,symbol
+ ,(rx-form
+ `(and
+ line-start
+ (group-n 1 (one-or-more any)) ; File name
+ "("
+ (group-n 2 (one-or-more digit)) ; Line number
+ (zero-or-one
+ ","
+ (group-n 3 (one-or-more digit))) ; Column number
+ "): "
+ ,expr
+ (group-n 4 (one-or-more nonl)) ; Message
+ line-end))
+ 1 2 3 ,level 4))
+ (add-to-list 'compilation-error-regexp-alist symbol))
+
+(d-mode-add-dmd-message-pattern "Error: " 2 'dmd-error )
+(d-mode-add-dmd-message-pattern "Warning: " 1 'dmd-warning )
+(d-mode-add-dmd-message-pattern "Deprecation: " 1 'dmd-deprecation )
+(d-mode-add-dmd-message-pattern '(one-or-more " ") 0 'dmd-continuation)
;; The following regexp recognizes messages generated by the D runtime for
;; unhandled exceptions (e.g. assert failures).
diff --git a/tests/I0069.txt b/tests/I0069.txt
new file mode 100644
index 0000000..39cee45
--- /dev/null
+++ b/tests/I0069.txt
@@ -0,0 +1,7 @@
+-*-compilation-*-
+
+foo.d(1): Error: Test error
+foo.d(1,1): Error: Column number test
+baz.d(3,4): instantiated from here: Continuation test
+bar.d(2,1): Warning: Test warning
+quux.d(3): Deprecation: Test deprecation
- [nongnu] elpa/d-mode 951ca5c 212/346: Remove code incompatible with older Emacs versions, (continued)
- [nongnu] elpa/d-mode 951ca5c 212/346: Remove code incompatible with older Emacs versions, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 4dce323 229/346: README.md: Add note about compatibility, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode b1d752a 233/346: Fix buffer modification when invoking imenu, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 441761c 237/346: Delete old keyword lists for imenu, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode f7ac740 235/346: Fix imenu classification of some variables, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 29940d7 226/346: Makefile: Add some utility commands, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode d14a001 239/346: Fix imenu false positive for static imports, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 8606775 240/346: Fix imenu jump position for new-style aliases, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 1908f59 236/346: Speed up imenu a bit, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 627a6f8 273/346: Move c-forward-decl-or-cast-1 into d-mode.el, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode e9278a9 114/346: Reimplement compilation-mode error message detection for DMD,
ELPA Syncer <=
- [nongnu] elpa/d-mode aff84c6 115/346: update support for Emacs 25, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode a564656 116/346: Merge pull request #71 from brdjns/patch-1, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 23a3661 119/346: Merge pull request #72 from nordlow/fix-d-exceptions-regexp, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode e5d21be 121/346: README: Update shield images and links to use official project repository, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 576dd29 123/346: tests: Actually test compilation-mode error list correctness, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 7817dbc 122/346: d-mode-test: Announce mismatched values of inline tests, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 8ccad32 136/346: Simplify cascaded call indentation setup, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 0b8ed61 152/346: Fix highlighting of const variable declarations, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 593e3f5 155/346: Fix extern(C) functions omitted from imenu, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 93a62b3 158/346: Fix imenu for functions returning types containing parens, ELPA Syncer, 2021/08/29