Function: cider-handle-compilation-errors

cider-handle-compilation-errors is a byte-compiled function defined in cider-eval.el.

Signature

(cider-handle-compilation-errors MESSAGE EVAL-BUFFER &optional NO-JUMP)

Documentation

Parse a possible compiler error MESSAGE and highlight it in EVAL-BUFFER.

If MESSAGE is an error or warning from the compiler, parse the location data from the message and put an overlay on the given location in the code buffer. If cider-auto-jump-to-error is enabled and not NO-JUMP, jump to the parsed location.

Source Code

;; Defined in ~/.emacs.d/elpa/cider-20260414.1619/cider-eval.el
(defun cider-handle-compilation-errors (message eval-buffer &optional no-jump)
  "Parse a possible compiler error MESSAGE and highlight it in EVAL-BUFFER.
If MESSAGE is an error or warning from the compiler, parse the location
data from the message and put an overlay on the given location in the code
buffer.
If `cider-auto-jump-to-error' is enabled and not NO-JUMP, jump to the
parsed location."
  (when-let* ((info (cider-extract-error-info cider-compilation-regexp message))
              (loc (cider--find-last-error-location info))
              (overlay (make-overlay (nth 0 loc) (nth 1 loc) (nth 2 loc))))
    (let* ((face (nth 3 info))
           (note (nth 4 info))
           (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)
      (overlay-put overlay 'help-echo note)
      (overlay-put overlay 'modification-hooks
                   (list (lambda (o &rest _args) (delete-overlay o))))
      (when auto-jump
        (with-current-buffer eval-buffer
          (push-mark)
          ;; At this stage selected window commonly is *cider-error* and we need to
          ;; re-select the original user window. If eval-buffer is not
          ;; visible it was probably covered as a result of a small screen or user
          ;; configuration (https://github.com/clojure-emacs/cider/issues/847). In
          ;; that case we don't jump at all in order to avoid covering *cider-error*
          ;; buffer.
          (when-let* ((win (get-buffer-window eval-buffer)))
            (with-selected-window win
              (cider-jump-to (nth 2 loc) (car loc)))))))))