Skip to content

Fix the conversion of modern indent specs - #4226

Merged
bbatsov merged 1 commit into
masterfrom
fix-indent-spec-to-legacy
Nov 1, 2026
Merged

bbatsov merged 1 commit into
masterfrom
fix-indent-spec-to-legacy

Conversation

@bbatsov

@bbatsov bbatsov commented Nov 1, 2026

Copy link
Copy Markdown
Member

cider--indent-spec-to-legacy put an :inner rule with a position in the wrong place when there's no :block rule, so :style/indent [[:inner 1 0]] broke indentation in both clojure-mode and clojure-ts-mode, and [:inner 0] next to a :block rule applied to the arguments, unlike in cljfmt. clojure-mode's copy of the conversion gets the same fix in clojure-emacs/clojure-mode#709.

cider--indent-spec-to-legacy turns the modern :style/indent specs from
cider-nrepl into the legacy format, which both clojure-mode and
clojure-ts-mode accept.  It got a few things wrong:

- An :inner rule with a position went to that position in the list
  when there was no :block rule, but position 0 is the form itself, so
  [[:inner 1 0]] became ((:defn) nil).  clojure-mode signaled an error
  indenting such a form, and clojure-ts-mode found no rules in it.
- An (:inner 0) rule went at the end, where it applied to the
  arguments, so [[:block 1] [:inner 0]] indented them like [:inner 1]
  would.  cljfmt ignores [:inner 0] next to a :block rule.
- Several :inner rules without a position each took a position of
  their own, and only the last applied to the arguments after them.

Reserve position 0 for the :block rule or (:inner 0), put the rules
with a position after it, and end with the shallowest rule without
one.  clojure-mode's own copy of this conversion gets the same fix in
clojure-emacs/clojure-mode#709.
@bbatsov
bbatsov force-pushed the fix-indent-spec-to-legacy branch from 3972460 to 09083f2 Compare November 1, 2026 09:35
@bbatsov
bbatsov merged commit 1f0a1d1 into master Nov 1, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant