emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/d-mode aba7187 117/346: Merge pull request #69 from CyberS


From: ELPA Syncer
Subject: [nongnu] elpa/d-mode aba7187 117/346: Merge pull request #69 from CyberShadow/pull-20160611-224824
Date: Sun, 29 Aug 2021 11:00:14 -0400 (EDT)

branch: elpa/d-mode
commit aba7187b1f8e51f3e97b7e30b55e09322e835941
Merge: a564656 e9278a9
Author: Vladimir Panteleev <github.private@thecybershadow.net>
Commit: GitHub <noreply@github.com>

    Merge pull request #69 from CyberShadow/pull-20160611-224824
    
    Reimplement compilation-mode error message detection for DMD
---
 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]