@@ -70,7 +70,15 @@ not to be automatically shown.
7070
7171Irrespective of the value of this variable, the `cider-error-buffer'  is 
7272always generated in the background.  Use `cider-selector'  to 
73- navigate to this buffer."  
73+ navigate to this buffer. 
74+ 
75+ Please note, if the error phase belongs to 
76+ one of the `cider-clojure-compilation-error-phases' , 
77+ then no stacktrace showing will happen. 
78+ That defcustom takes precedence over this one. 
79+ 
80+ See its doc for understanding its rationale.  You can also customize it to nil 
81+ in order to void its effect."  
7482  :type  '(choice (const :tag  " always" t )
7583                 (const except-in-repl)
7684                 (const only-in-repl)
@@ -478,32 +486,62 @@ op/situation that originated this error."
478486    (let  ((error-buffer (cider-new-error-buffer #'cider-stacktrace-mode   error-types)))
479487      (cider-stacktrace-render error-buffer (reverse  causes) error-types))))
480488
481- (defun  cider--handle-stacktrace-response  (response  causes )
482-   " Handle stacktrace op RESPONSE, aggregating the result into CAUSES.
489+ (defcustom  cider-clojure-compilation-error-phases  '(" read-source" 
490+                                                     " macro-syntax-check" 
491+                                                     " macroexpansion" 
492+                                                     " compile-syntax-check" 
493+                                                     " compilation" 
494+                                                     ; ; "execution" is certainly not to be included here.
495+                                                     ; ; "read-eval-result" and "print-eval-result" are not to be included here,
496+                                                     ; ; because they mean that the code has been successfully executed.
497+                                                     )
498+   " Error phases which will not cause the `*cider-error*'  buffer to pop up.
499+ 
500+ The default value results in no stacktrace being shown for compile-time errors. 
501+ 
502+ Note that `*cider-error*'  pop behavior is otherwise controlled 
503+ by the `cider-show-error-buffer'  defcustom. 
504+ 
505+ `cider-clojure-compilation-error-phases'  takes precedence.
506+ If you wish phases to be ignored, set this variable to nil instead. 
507+ 
508+ You can learn more about Clojure's error phases at: 
509+ https://clojure.org/reference/repl_and_main#_at_repl"  
510+   :type  'list 
511+   :group  'cider 
512+   :package-version  '(cider .  " 0.18.0" 
513+ 
514+ (defun  cider--handle-stacktrace-response  (response  causes  ex-phase )
515+   " Handle stacktrace RESPONSE, aggregate the result into CAUSES, honor EX-PHASE.
483516If RESPONSE contains a cause, cons it onto CAUSES and return that.  If 
484517RESPONSE is the final message (i.e. it contains a status), render CAUSES 
485518into a new error buffer."  
486519  (nrepl-dbind-response response (class msg status type)
487520    (cond  ((and  (member  " notification" 
488521           (nrepl-notify msg type))
489522          (class (cons  response causes))
490-           (status (cider--render-stacktrace-causes causes)))))
523+           (status
524+            (unless  (member  ex-phase cider-clojure-compilation-error-phases)
525+              (cider--render-stacktrace-causes causes))))))
491526
492527(defun  cider-default-err-op-handler  ()
493528  " Display the last exception, with middleware support." 
494529  ; ; Causes are returned as a series of messages, which we aggregate in `causes' 
495-   (let  (causes)
530+   (let  (causes ex-phase )
496531    (cider-nrepl-send-request
497532     (thread-last 
498533       (map-merge  'list 
499534                  '((" op" " analyze-last-stacktrace" 
500535                  (cider--nrepl-print-request-map fill-column))
501536       (seq-mapcat  #'identity  ))
502537     (lambda  (response )
538+        (nrepl-dbind-response response (phase)
539+          (when  phase
540+            (setq  ex-phase phase)))
503541       ; ; While the return value of `cider--handle-stacktrace-response'  is not
504542       ; ; meaningful for the last message, we do not need the value of `causes' 
505543       ; ; after it has been handled, so it's fine to set it unconditionally here
506-        (setq  causes (cider--handle-stacktrace-response response causes))))))
544+        (setq  causes (cider--handle-stacktrace-response response causes ex-phase ))))))
507545
508546(defun  cider-default-err-handler  ()
509547  " This function determines how the error buffer is shown.
0 commit comments