Function: cider--format-reindent

cider--format-reindent is a byte-compiled function defined in cider-format.el.

Signature

(cider--format-reindent FORMATTED START)

Documentation

Reindent FORMATTED to align with the buffer column of position START.

Each continuation line is shifted right by START's column, except newlines inside string or regex literals, whose contents are left untouched.

Source Code

;; Defined in ~/.emacs.d/elpa/cider-20261106.1225/cider-format.el
;; Format

(defun cider--format-reindent (formatted start)
  "Reindent FORMATTED to align with the buffer column of position START.
Each continuation line is shifted right by START's column, except newlines
inside string or regex literals, whose contents are left untouched."
  (let ((start-column (save-excursion (goto-char start) (current-column))))
    (if (zerop start-column)
        formatted
      (with-temp-buffer
        (set-syntax-table clojure-mode-syntax-table)
        (insert formatted)
        (let ((pad (make-string start-column ?\s))
              (positions nil))
          ;; Collect the continuation lines that don't start inside a string,
          ;; in a read-only pass so `syntax-ppss' stays accurate.
          (goto-char (point-min))
          (while (zerop (forward-line 1))
            (unless (or (eobp) (nth 3 (syntax-ppss (point))))
              (push (point) positions)))
          ;; Insert bottom-up so earlier positions stay valid.
          (dolist (pos positions)
            (goto-char pos)
            (insert pad)))
        (buffer-string)))))