Borrow clojure-mode's binding alignment without inheriting its assumptions
This commit is contained in:
parent
394b656a68
commit
f2d80ce8c0
25
DISCUSS.md
25
DISCUSS.md
@ -284,6 +284,25 @@ it is the first binding's **name** — never a body form — so the check fails
|
||||
**What it is built on:** Emacs's built-in `lisp-indent-function`, with that one override. Not `clojure-mode`, which is
|
||||
where the missing piece lives — `clojure-mode` special-cases binding vectors and aligns them as pairs.
|
||||
|
||||
The fix is a binding-vector case in `flan-indent-function`: when the enclosing open is `[` and the form containing it is
|
||||
a binding form, align to the column of the first binding. Worth checking the other bracket users at the same time —
|
||||
`defn` parameter lists and `restart-case` clause parameters have the same shape.
|
||||
**The fix, agreed in conversation:** add a binding-vector case to `flan-indent-function`. When the enclosing open is `[`
|
||||
and the form containing it is a binding form, align continuation lines to the column of the **first binding**, not to
|
||||
the first argument. Bindings are pairs, so the alignment that reads correctly is name-under-name. Check the other
|
||||
bracket users in the same pass — `defn` parameter lists and `restart-case` clause parameters have the same shape and
|
||||
almost certainly the same bug.
|
||||
|
||||
**Should `flan-mode` derive from `clojure-mode` instead?** Considered and declined, without much in it.
|
||||
|
||||
For: binding vectors, `#_` and a lot of tuned indentation for free, and the syntax genuinely is Clojure-shaped.
|
||||
|
||||
Against, and this is what decided it:
|
||||
|
||||
- `flan-mode` currently depends on **nothing outside stock Emacs**, and it ships inside this repo. Deriving adds an
|
||||
external package to something distributed with the compiler.
|
||||
- **The divergence is growing.** `defn` carries a return type between the parameters and the body, which Clojure has no
|
||||
concept of; field access is `(.x v)`; and the decision to move field labels from `:x` to `.x` means `{.x 1.0}` would
|
||||
read to `clojure-mode` as a map with symbol keys. Inheriting rules then means overriding them, which is usually more
|
||||
work than writing the few that are wanted.
|
||||
- That community is mid-transition to a tree-sitter mode, so the base would be a moving target.
|
||||
|
||||
**So: stay independent and copy `clojure-mode`'s binding-vector algorithm**, which is small, known-good, and the only
|
||||
piece actually missing. If a second or third gap appears later that is real evidence for deriving; one is not.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user