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

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

[nongnu] elpa/cider ef805c8bec 1/2: Restore `cider--display-interactive-


From: ELPA Syncer
Subject: [nongnu] elpa/cider ef805c8bec 1/2: Restore `cider--display-interactive-eval-result` overlays for compilation errors (#3492)
Date: Sat, 30 Sep 2023 03:59:58 -0400 (EDT)

branch: elpa/cider
commit ef805c8bec2ab06864adb6c1436e4cb3ac16ea64
Author: vemv <vemv@users.noreply.github.com>
Commit: GitHub <noreply@github.com>

    Restore `cider--display-interactive-eval-result` overlays for compilation 
errors (#3492)
    
    Fixes https://github.com/clojure-emacs/cider/issues/3487
---
 CHANGELOG.md  |  4 ++--
 cider-eval.el | 57 ++++++++++++++++++++++++++++++++++++++++++---------------
 2 files changed, 44 insertions(+), 17 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 428b9103b2..29d0ad47b8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -28,10 +28,10 @@
 - [#3331](https://github.com/clojure-emacs/cider/issues/3331): `cider-eval`: 
never jump to spurious locations, as sometimes conveyed by nREPL.  
 - [#3112](https://github.com/clojure-emacs/cider/issues/3112): Fix the CIDER 
`xref-find-references` backend to return correct filenames.
 - [#3393](https://github.com/clojure-emacs/cider/issues/3393): recompute 
namespace info on each shadow-cljs recompilation or evaluation.
-- [#3402](https://github.com/clojure-emacs/cider/issues/3402): fix 
`cider-format-connection-params` edge case for Emacs 29.
+- [#3402](https://github.com/clojure-emacs/cider/issues/3402): Fix 
`cider-format-connection-params` edge case for Emacs 29.
 - [#3393](https://github.com/clojure-emacs/cider/issues/3393): Recompute 
namespace info on each shadow-cljs recompilation or evaluation.
 - Recompute namespace info on each fighweel-main recompilation.
-- [#3250](https://github.com/clojure-emacs/cider/issues/3250): don't lose the 
CIDER session over TRAMP files. 
+- [#3250](https://github.com/clojure-emacs/cider/issues/3250): Don't lose the 
CIDER session over TRAMP files. 
 - [#3413](https://github.com/clojure-emacs/cider/issues/3413): Make 
jump-to-definition work in projects needing `cider-path-translations` (i.e. 
Dockerized projects). 
 - [#2436](https://github.com/clojure-emacs/cider/issues/2436): Prevent 
malformed `cider-repl-history-file`s from failing `cider-jack-in`.
 - [#3456](https://github.com/clojure-emacs/cider/issues/3456): restore 
xref-based jump-to-definition in Babashka (and any nREPL clients not having 
cider-nrepl).
diff --git a/cider-eval.el b/cider-eval.el
index 69f1e68fcc..8a906c3e02 100644
--- a/cider-eval.el
+++ b/cider-eval.el
@@ -678,8 +678,8 @@ If location could not be found, return nil."
                                         (point))))
                         (list begin end buffer)))))))))))))
 
-(defun cider-handle-compilation-errors (message eval-buffer)
-  "Highlight and jump to compilation error extracted from MESSAGE.
+(defun cider-handle-compilation-errors (message eval-buffer &optional no-jump)
+  "Highlight and jump to compilation error extracted from MESSAGE, honor 
NO-JUMP.
 EVAL-BUFFER is the buffer that was current during user's interactive
 evaluation command.  Honor `cider-auto-jump-to-error'."
   (when-let* ((loc (cider--find-last-error-location message))
@@ -687,10 +687,11 @@ evaluation command.  Honor `cider-auto-jump-to-error'."
               (info (cider-extract-error-info cider-compilation-regexp 
message)))
     (let* ((face (nth 3 info))
            (note (nth 4 info))
-           (auto-jump (if (eq cider-auto-jump-to-error 'errors-only)
-                          (not (or (eq face 'cider-warning-highlight-face)
-                                   (string-match-p "warning" note)))
-                        cider-auto-jump-to-error)))
+           (auto-jump (unless no-jump
+                        (if (eq cider-auto-jump-to-error 'errors-only)
+                            (not (or (eq face 'cider-warning-highlight-face)
+                                     (string-match-p "warning" note)))
+                          cider-auto-jump-to-error))))
       (overlay-put overlay 'cider-note-p t)
       (overlay-put overlay 'font-lock-face face)
       (overlay-put overlay 'cider-note note)
@@ -774,6 +775,19 @@ REPL buffer.  This is controlled via
             (cider--make-fringe-overlay (point)))
         (scan-error nil)))))
 
+(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-let ((conn (with-current-buffer buffer
+                       (cider-current-repl))))
+      (when (cider-nrepl-op-supported-p "analyze-last-stacktrace" conn)
+        (when-let* ((result (nrepl-send-sync-request (thread-last (map-merge 
'list
+                                                                             
'(("op" "analyze-last-stacktrace"))
+                                                                             
(cider--nrepl-print-request-map fill-column))
+                                                                  (seq-mapcat 
#'identity))
+                                                     conn)))
+          (nrepl-dict-get result "phase"))))))
+
 (declare-function cider-inspect-last-result "cider-inspector")
 (defun cider-interactive-eval-handler (&optional buffer place)
   "Make an interactive eval handler for BUFFER.
@@ -796,17 +810,30 @@ when `cider-auto-inspect-after-eval' is non-nil."
                                    (cider--display-interactive-eval-result res 
end))
                                  (lambda (_buffer out)
                                    (cider-emit-interactive-eval-output out))
-                                 (lambda (_buffer err)
+                                 (lambda (buffer err)
                                    (cider-emit-interactive-eval-err-output err)
 
-                                   (when (or (not cider-show-error-buffer)
-                                             (not 
(cider-connection-has-capability-p 'jvm-compilation-errors)))
-
-                                     ;; Display errors as temporary overlays
-                                     (let ((cider-result-use-clojure-font-lock 
nil))
-                                       (cider--display-interactive-eval-result
-                                        err end 'cider-error-overlay-face)))
-                                   (cider-handle-compilation-errors err 
eval-buffer))
+                                   (let ((phase 
(cider--error-phase-of-last-exception buffer)))
+                                     (when (or
+                                            ;; if we won't show *cider-error*, 
because of configuration, the overlay is adequate because it compensates for 
the lack of info in a compact manner:
+                                            (not cider-show-error-buffer)
+                                            (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)))
+                                       ;; Display errors as temporary overlays
+                                       (let 
((cider-result-use-clojure-font-lock nil))
+                                         
(cider--display-interactive-eval-result
+                                          err end 'cider-error-overlay-face)))
+
+                                     (cider-handle-compilation-errors err
+                                                                      
eval-buffer
+                                                                      ;; we 
prevent jumping behavior on compilation errors,
+                                                                      ;; 
because lines tend to be spurious (e.g. 0:0)
+                                                                      ;; and 
because on compilation errors, normally
+                                                                      ;; the 
error is 'right there' in the current line
+                                                                      ;; and 
needs no jumping:
+                                                                      phase)))
                                  (lambda (buffer)
                                    (if beg
                                        (unless fringed



reply via email to

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