Skip to content

Commit 08a9adf

Browse files
committed
Expand cider-clojure-compilation-regexp
Fixes #3521
1 parent 93da20e commit 08a9adf

File tree

4 files changed

+42
-22
lines changed

4 files changed

+42
-22
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## master (unreleased)
44

5+
### Changes
6+
7+
- [#3521](https://github.com/clojure-emacs/cider/issues/3521): Expand `cider-clojure-compilation-regexp` to also match e.g. `Unexpected error (ExceptionInfo) macroexpanding defmulti at (src/ns.clj:1:1).`.
8+
59
## 1.8.2 (2023-10-15)
610

711
### Changes

cider-eval.el

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -558,19 +558,31 @@ It delegates the actual error content to the eval or op handler."
558558
;; old and the new format, by utilizing a combination of two different regular
559559
;; expressions.
560560

561-
(defconst cider-clojure-1.10-error `(sequence
562-
"Syntax error "
563-
(minimal-match (zero-or-more anything))
564-
(or "compiling "
565-
"macroexpanding "
566-
"reading source ")
567-
(minimal-match (zero-or-more anything))
568-
"at ("
569-
(group-n 2 (minimal-match (zero-or-more anything)))
570-
":"
571-
(group-n 3 (one-or-more digit))
572-
(optional ":" (group-n 4 (one-or-more digit)))
573-
")."))
561+
(defconst cider-clojure-1.10--location `("at ("
562+
(group-n 2 (minimal-match (zero-or-more anything)))
563+
":"
564+
(group-n 3 (one-or-more digit))
565+
(optional ":" (group-n 4 (one-or-more digit)))
566+
")."))
567+
568+
(defconst cider-clojure-1.10-error (append `(sequence
569+
"Syntax error "
570+
(minimal-match (zero-or-more anything))
571+
(or "compiling "
572+
"macroexpanding "
573+
"reading source ")
574+
(minimal-match (zero-or-more anything)))
575+
cider-clojure-1.10--location))
576+
577+
(defconst cider-clojure-unexpected-error (append `(sequence
578+
"Unexpected error ("
579+
(minimal-match (one-or-more anything))
580+
") "
581+
(or "compiling "
582+
"macroexpanding "
583+
"reading source ")
584+
(minimal-match (one-or-more anything)))
585+
cider-clojure-1.10--location))
574586

575587
(defconst cider-clojure-1.9-error `(sequence
576588
(zero-or-more anything)
@@ -591,23 +603,19 @@ It delegates the actual error content to the eval or op handler."
591603
(optional ":" (group-n 4 (one-or-more digit)))
592604
" - "))
593605

594-
595606
(defconst cider-clojure-compilation-regexp
596607
(eval
597608
`(rx bol (or ,cider-clojure-1.9-error
598609
,cider-clojure-warning
599-
,cider-clojure-1.10-error))
610+
,cider-clojure-1.10-error
611+
,cider-clojure-unexpected-error))
600612
t)
601613
"A few example values that will match:
602614
\"Reflection warning, /tmp/foo/src/foo/core.clj:14:1 - \"
603615
\"CompilerException java.lang.RuntimeException: Unable to resolve symbol: \\
604616
lol in this context, compiling:(/foo/core.clj:10:1)\"
605-
\"Syntax error compiling at (src/workspace_service.clj:227:3).\"")
606-
607-
(replace-regexp-in-string cider-clojure-compilation-regexp
608-
""
609-
"Reflection warning, /tmp/foo/src/foo/core.clj:14:1 - call to java.lang.Integer ctor can't be resolved.")
610-
617+
\"Syntax error compiling at (src/workspace_service.clj:227:3).\"
618+
\"Unexpected error (ClassCastException) macroexpanding defmulti at (src/haystack/parser.cljc:21:1).\"")
611619

612620
(defvar cider-compilation-regexp
613621
(list cider-clojure-compilation-regexp 2 3 4 '(1))

doc/modules/ROOT/pages/usage/dealing_with_errors.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ temporary overlay or in the echo area:
2323
(setq cider-show-error-buffer nil)
2424
----
2525

26+
NOTE: you will only see the overlay if `cider-use-overlays` is non-nil.
27+
2628
Starting from CIDER 1.8.0, only runtime exceptions (and not compilation errors)
2729
will cause a stacktrace buffer to be shown. This better follows Clojure 1.10's
2830
https://clojure.org/reference/repl_and_main#_at_repl[intended semantics].

test/cider-error-parsing-tests.el

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,10 @@
135135
(expect clojure-1.10-compiler-error :to-match cider-clojure-compilation-regexp)
136136
(expect (progn (string-match cider-clojure-compilation-regexp clojure-1.10-compiler-error)
137137
(match-string 2 clojure-1.10-compiler-error))
138-
:to-equal "src/ardoq/service/workspace_service.clj"))))
138+
:to-equal "src/ardoq/service/workspace_service.clj")))
139+
(it "Recognizes a clojure 'Unexpected error' message"
140+
(let ((clojure-1.10-compiler-error "Unexpected error (ClassCastException) macroexpanding defmulti at (src/haystack/parser.cljc:21:1)."))
141+
(expect clojure-1.10-compiler-error :to-match cider-clojure-compilation-regexp)
142+
(expect (progn (string-match cider-clojure-compilation-regexp clojure-1.10-compiler-error)
143+
(match-string 2 clojure-1.10-compiler-error))
144+
:to-equal "src/haystack/parser.cljc"))))

0 commit comments

Comments
 (0)