Skip to content

Commit

Permalink
Handle cider-clojure-compilation-error-phases values that have been…
Browse files Browse the repository at this point in the history
… customized to `t`

Fixes #3582
  • Loading branch information
vemv committed Nov 14, 2023
1 parent 57d1dc1 commit 5261886
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- CIDER [Inspector](https://docs.cider.mx/cider/debugging/inspector.html): retain [`truncate-lines`](https://www.gnu.org/software/emacs/manual/html_node/emacs/Line-Truncation.html) values across screens.
- [#3580](https://github.com/clojure-emacs/cider/issues/3580): `cider-test`: make test vars in [test results reports](https://docs.cider.mx/cider/testing/test_reports.html) clickable.
- As defined in the newly introduced `cider-test-var-keymap` var.
- [#3582](https://github.com/clojure-emacs/cider/issues/3582): Handle `cider-clojure-compilation-error-phases` values that have been customized to `t`.
- [#3581](https://github.com/clojure-emacs/cider/issues/3581): Bump the injected `enrich-classpath` to [1.18.5](https://github.com/clojure-emacs/enrich-classpath/compare/v1.18.4...v1.18.5).
- Handles Clojure CLI `:paths` directly defined as `:aliases`.

Expand Down
33 changes: 21 additions & 12 deletions cider-eval.el
Original file line number Diff line number Diff line change
Expand Up @@ -486,15 +486,18 @@ op/situation that originated this error."
(let ((error-buffer (cider-new-error-buffer #'cider-stacktrace-mode error-types)))
(cider-stacktrace-render error-buffer (reverse causes) error-types))))

(defcustom cider-clojure-compilation-error-phases '("read-source"
"macro-syntax-check"
"macroexpansion"
"compile-syntax-check"
"compilation"
;; "execution" is certainly not to be included here.
;; "read-eval-result" and "print-eval-result" are not to be included here,
;; because they mean that the code has been successfully executed.
)
(defconst cider-clojure-compilation-error-phases-default-value
'("read-source"
"macro-syntax-check"
"macroexpansion"
"compile-syntax-check"
"compilation"
;; "execution" is certainly not to be included here.
;; "read-eval-result" and "print-eval-result" are not to be included here,
;; because they mean that the code has been successfully executed.
))

(defcustom cider-clojure-compilation-error-phases cider-clojure-compilation-error-phases-default-value
"Error phases which will not cause the `*cider-error*' buffer to pop up.
The default value results in no stacktrace being shown for compile-time errors.
Expand All @@ -511,6 +514,12 @@ https://clojure.org/reference/repl_and_main#_at_repl"
:group 'cider
:package-version '(cider . "0.18.0"))

(defun cider-clojure-compilation-error-phases ()
"Get the normalized value of the `cider-clojure-compilation-error-phases' var."
(if (equal t cider-clojure-compilation-error-phases)
cider-clojure-compilation-error-phases-default-value
cider-clojure-compilation-error-phases))

(defun cider--handle-stacktrace-response (response causes ex-phase)
"Handle stacktrace RESPONSE, aggregate the result into CAUSES, honor EX-PHASE.
If RESPONSE contains a cause, cons it onto CAUSES and return that. If
Expand All @@ -521,7 +530,7 @@ into a new error buffer."
(nrepl-notify msg type))
(class (cons response causes))
(status
(unless (member ex-phase cider-clojure-compilation-error-phases)
(unless (member ex-phase (cider-clojure-compilation-error-phases))
(cider--render-stacktrace-causes causes))))))

(defun cider-default-err-op-handler ()
Expand Down Expand Up @@ -832,7 +841,7 @@ REPL buffer. This is controlled via

(defun cider--error-phase-of-last-exception (buffer)
"Returns the :phase of the latest exception associated to BUFFER, if any."
(when cider-clojure-compilation-error-phases
(when (cider-clojure-compilation-error-phases)
(when-let ((conn (with-current-buffer buffer
(cider-current-repl))))
(when (cider-nrepl-op-supported-p "analyze-last-stacktrace" conn)
Expand Down Expand Up @@ -872,7 +881,7 @@ depending on the PHASE."
(not (cider-connection-has-capability-p 'jvm-compilation-errors))
;; if we won't show *cider-error*, because of an ignored phase, the overlay is adequate:
(and cider-show-error-buffer
(member phase cider-clojure-compilation-error-phases)))
(member phase (cider-clojure-compilation-error-phases))))
;; Display errors as temporary overlays
(let ((cider-result-use-clojure-font-lock nil)
(trimmed-err (funcall cider-inline-error-message-function err)))
Expand Down

0 comments on commit 5261886

Please sign in to comment.