change indentation strategy for sequences whose head is a keyword

assume that these are part of some internal structure of something
that, in general looks like

  (#:x 1 #:y 2 #:z 3)

and so prefer to indent like this:

  (#:x 1
   #:y 2
   #:z 3)

instead of like this:

  (#:x 1
       #:y 2
       #:z 3)
This commit is contained in:
Robby Findler 2016-02-25 10:35:47 -06:00
parent be30bf721d
commit ab063326fe
2 changed files with 13 additions and 0 deletions

View File

@ -702,6 +702,8 @@
(- id-end contains)
0))
(cond
[(first-sexp-is-keyword? contains)
(visual-offset contains)]
[(second-sexp-is-ellipsis? contains)
(visual-offset contains)]
[(not (find-up-sexp pos))
@ -738,6 +740,13 @@
(and (or (not thrd-start)
(not (= (position-paragraph thrd-start)
(position-paragraph snd-start)))))))))))))
(define/private (first-sexp-is-keyword? contains)
(let ([fst-end (get-forward-sexp contains)])
(and fst-end
(let ([fst-start (get-backward-sexp fst-end)])
(and fst-start
(equal? (classify-position fst-start) 'hash-colon-keyword))))))
(define/public (tabify-selection [start-pos (get-start-position)]
[end-pos (get-end-position)])

View File

@ -171,6 +171,10 @@
"(r a\n b\n c\n d\n e\n f\n g")
(test-indentation "(r a b\nc d\ne f\ng h"
"(r a b\n c d\n e f\n g h")
(test-indentation "(#:x\n1)"
"(#:x\n 1)")
(test-indentation "(#:x 0\n1)"
"(#:x 0\n 1)")
(define (test-magic-square-bracket which before after)