Function: cider-handle-compilation-errors

cider-handle-compilation-errors is a byte-compiled function defined in cider-compilation.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-20260822.1520/cider-compilation.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)))
    (pcase-let ((`(,begin ,end ,buffer) loc)
                (`(,_file ,_line ,_col ,face ,note) info))
      (let ((overlay (make-overlay begin end buffer))
            (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 buffer begin)))))))))