Skip to content

Convert modern indent specs to legacy for backward compatibility#3868

Open
bbatsov wants to merge 5 commits intomasterfrom
convert-modern-indent-specs
Open

Convert modern indent specs to legacy for backward compatibility#3868
bbatsov wants to merge 5 commits intomasterfrom
convert-modern-indent-specs

Conversation

@bbatsov
Copy link
Copy Markdown
Member

@bbatsov bbatsov commented Mar 24, 2026

orchard's indent inference tables are being updated to emit modern tuple-format specs ([[:block 1]], [[:inner 0]]) shared with clojure-mode and clojure-ts-mode (see clojure-emacs/orchard#381).

This PR adds a conversion shim in cider--get-symbol-indent that converts modern-format specs to legacy format before passing them to clojure-mode's clojure-get-indent-function hook. This ensures compatibility with older clojure-mode versions that don't understand the modern format.

New clojure-mode versions (with clojure-emacs/clojure-mode#702) handle both formats natively, so the conversion is redundant there but harmless. clojure-ts-mode has its own converter from legacy to modern, so it also works fine.

Companion PRs:

bbatsov added 5 commits March 24, 2026 16:04
orchard's indent inference tables now emit modern tuple-format
specs (e.g., [[:block 1] [:inner 0]]) which arrive via nREPL as
the :style/indent metadata. Convert these to legacy format before
passing to clojure-mode's clojure-get-indent-function hook, so
older clojure-mode versions that don't understand the modern format
still work correctly.

New functions:
- cider--modern-indent-spec-p: detect modern tuple format
- cider--indent-spec-to-legacy: convert modern → legacy

The conversion happens in cider--get-symbol-indent after reading
and vector-to-list conversion.
Update indent_spec.adoc:
- Present modern tuple format ([:block N], [:inner D], [:inner D I])
  as the preferred format with a reference table
- Reorganize examples to show modern format first
- Add legacy format reference section with deprecation note

Update indentation.adoc:
- Use modern format in static and dynamic indentation examples
- Add notes about legacy format backward compatibility
Add clear definitions for body-style indentation, special arguments,
depth, and position — terms that were used throughout the docs but
never explicitly defined. Expand the rule type descriptions with
concrete explanations of what each depth level means.

Explicitly call out cljfmt format compatibility with a link.
…uide

Annotate all code examples with depth and position comments so
readers can see exactly how rules map to indentation. Add a detailed
explanation of why letfn needs [:inner 2 0] with a position
restriction.

Add a "Choosing the right rule" section with heuristics for when to
use :block, :inner, and combinations.

Replace the plain legacy format list with a side-by-side comparison
table mapping modern to legacy specs for all complex built-in forms.
Rewrite the Special Arguments section to reference [:block N] rule
and add depth annotations to examples. Rewrite the Internal
Indentation section to explain [:inner 1] in terms of depth rather
than legacy positional semantics.

Add a new Namespace-Qualified Symbols section documenting
clojure-mode's support for per-namespace indent overrides and the
automatic fallback to unqualified specs.
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