Skip to content

Commit 645013b

Browse files
committed
Fix incorrect README docs on :block rules
1 parent 5a1c5ea commit 645013b

File tree

1 file changed

+25
-27
lines changed

1 file changed

+25
-27
lines changed

README.md

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -401,42 +401,31 @@ Because `(e...)` is the 4th (index `3`) at form depth `1`.
401401

402402
#### Block rules
403403

404-
The `:block` rule supports indenting to the first form argument. It
405-
has a single rule type argument:
404+
The `:block` rule works like the `:inner` rule under some
405+
circumstances, and like a normal list form under others. It takes one
406+
argument:
406407

407-
* `line-arg-count-threshold` -
408-
when there are more than this many form arguments on the same line
409-
as the form symbol, eligible form arguments on subsequent lines are
410-
indented to align with the first form argument. Otherwise, two space
411-
inner indentation is applied.
408+
* `line-threshold-index` -
409+
if the argument at this index starts a new line, all following lines
410+
will be indented by a constant 2 spaces. Any other lines are
411+
indented normally.
412412

413-
For indent rule:
413+
For example:
414414

415415
```clojure
416416
{foo [[:block 0]]}
417417
```
418418

419-
The single argument `bar` on the same line as `foo` breaks the
420-
threshold of `0` and indents eligible form arguments on subsequent
421-
lines to `bar`:
422-
419+
If the argument at index 0 (the first argument) does not start a new
420+
line, the form is indented as normal:
423421

424422
```clojure
425423
(foo bar (foo bar
426424
baz == formats to => baz
427425
bang) bang)
428426
```
429427

430-
The two arguments `bar baz` on the same line as `foo` also breaks the
431-
threshold of `0` and invokes indentation to the first argument:
432-
433-
```clojure
434-
(foo bar baz == formats to => (foo bar baz
435-
bang) bang)
436-
```
437-
438-
No arguments on the same line as `foo` does not break the threshold of
439-
`0`, so 2 space inner indentation is applied:
428+
If it does, the lines are indented with a constant 2 spaces:
440429

441430
```clojure
442431
(foo (foo
@@ -445,29 +434,38 @@ baz baz
445434
bang) bang)
446435
```
447436

448-
For indent rule:
437+
To give another example
449438

450439
```clojure
451440
{foo [[:block 1]]}
452441
```
453442

454-
The single arg `bar` on the same line as `foo` does not break the
455-
threshold of `1` so we get inner indentation:
443+
This time we're looking at the argument at index 1 (the second
444+
argument). If it starts a new line, the indent is constant:
456445

457446
```clojure
458447
(foo bar (foo bar
459448
baz == formats to => baz
460449
bang) bang)
461450
```
462451

463-
Two args `bar baz` on the same line as `foo` breaks the threshold of
464-
`1` so we get first argument aligned indentation:
452+
But if it does not, start a new line, normal indentation rules are
453+
used instead:
465454

466455
```clojure
467456
(foo bar baz == formats to => (foo bar baz
468457
bang) bang)
469458
```
470459

460+
Any lines before the threshold are always indented normally:
461+
462+
```clojure
463+
(foo (foo
464+
bar bar
465+
baz == formats to => baz
466+
bang) bang)
467+
```
468+
471469
#### Multiple rules
472470

473471
Multiple rules can be specified. Picking up from our previous `letfn`

0 commit comments

Comments
 (0)