tabber: an ellipsis as the second thing on a line now tabs as if the ellipsis wasn't there; good for plt redex
svn: r5553 original commit: bdc4f19985503f80164abd2d485dab9c46af71f8
This commit is contained in:
parent
bc3ee684bc
commit
9d1a810f9b
|
@ -518,7 +518,7 @@
|
||||||
;; Something went wrong matching. Should we get here?
|
;; Something went wrong matching. Should we get here?
|
||||||
(do-indent 0)]
|
(do-indent 0)]
|
||||||
[(not last)
|
[(not last)
|
||||||
;; We can't find a match backward from pos,
|
;; We can't find a match backward from pos,
|
||||||
;; but we seem to be inside an S-exp, so
|
;; but we seem to be inside an S-exp, so
|
||||||
;; go "up" an S-exp, and move forward past
|
;; go "up" an S-exp, and move forward past
|
||||||
;; the associated paren
|
;; the associated paren
|
||||||
|
@ -527,28 +527,32 @@
|
||||||
(+ (visual-offset enclosing) 1)
|
(+ (visual-offset enclosing) 1)
|
||||||
0)))]
|
0)))]
|
||||||
[(= contains last)
|
[(= contains last)
|
||||||
;; There's only one S-expr in the S-expr
|
;; There's only one S-expr in the S-expr
|
||||||
;; containing "pos"
|
;; containing "pos"
|
||||||
(do-indent (+ (visual-offset contains)
|
(do-indent (+ (visual-offset contains)
|
||||||
(procedure-indent)))]
|
(procedure-indent)))]
|
||||||
[(special-check)
|
[(special-check)
|
||||||
;; In case of "define", etc., ignore the position of last
|
;; In case of "define", etc., ignore the position of last
|
||||||
;; and just indent under the "define"
|
;; and just indent under the "define"
|
||||||
(do-indent (add1 (visual-offset contains)))]
|
(do-indent (add1 (visual-offset contains)))]
|
||||||
[(= contain-para last-para)
|
[(= contain-para last-para)
|
||||||
;; So far, the S-exp containing "pos" was all on
|
;; So far, the S-exp containing "pos" was all on
|
||||||
;; one line (possibly not counting the opening paren),
|
;; one line (possibly not counting the opening paren),
|
||||||
;; so indent to follow the first S-exp's end
|
;; so indent to follow the first S-exp's end
|
||||||
|
;; unless there are just two sexps and the second is an ellipsis.
|
||||||
|
;; in that case, we just ignore the ellipsis
|
||||||
(let ([name-length (let ([id-end (get-forward-sexp contains)])
|
(let ([name-length (let ([id-end (get-forward-sexp contains)])
|
||||||
(if id-end
|
(if id-end
|
||||||
(- id-end contains)
|
(- id-end contains)
|
||||||
0))])
|
0))])
|
||||||
(do-indent (+ (visual-offset contains)
|
(if (second-sexp-is-ellipsis? contains)
|
||||||
name-length
|
(do-indent (visual-offset contains))
|
||||||
(indent-first-arg (+ contains
|
(do-indent (+ (visual-offset contains)
|
||||||
name-length)))))]
|
name-length
|
||||||
|
(indent-first-arg (+ contains
|
||||||
|
name-length))))))]
|
||||||
[else
|
[else
|
||||||
;; No particular special case, so indent to match first
|
;; No particular special case, so indent to match first
|
||||||
;; S-expr that start on the previous line
|
;; S-expr that start on the previous line
|
||||||
(let loop ([last last][last-para last-para])
|
(let loop ([last last][last-para last-para])
|
||||||
(let* ([next-to-last (backward-match last limit)]
|
(let* ([next-to-last (backward-match last limit)]
|
||||||
|
@ -558,6 +562,22 @@
|
||||||
(loop next-to-last next-to-last-para)
|
(loop next-to-last next-to-last-para)
|
||||||
(do-indent (visual-offset last)))))])))))
|
(do-indent (visual-offset last)))))])))))
|
||||||
|
|
||||||
|
;; returns #t if `contains' is at a position on a line with an sexp, an ellipsis and nothing else.
|
||||||
|
;; otherwise, returns #f
|
||||||
|
(define/private (second-sexp-is-ellipsis? contains)
|
||||||
|
(let ([fst-end (get-forward-sexp contains)])
|
||||||
|
(and fst-end
|
||||||
|
(let ([snd-end (get-forward-sexp fst-end)])
|
||||||
|
(and snd-end
|
||||||
|
(let ([snd-start (get-backward-sexp snd-end)])
|
||||||
|
(and snd-start
|
||||||
|
(equal? (get-text snd-start snd-end)
|
||||||
|
"...")
|
||||||
|
(let ([thrd-start (get-forward-sexp snd-end)])
|
||||||
|
(and (or (not thrd-start)
|
||||||
|
(not (= (position-paragraph thrd-start)
|
||||||
|
(position-paragraph snd-start)))))))))))))
|
||||||
|
|
||||||
(define/public tabify-selection
|
(define/public tabify-selection
|
||||||
(opt-lambda ([start-pos (get-start-position)]
|
(opt-lambda ([start-pos (get-start-position)]
|
||||||
[end-pos (get-end-position)])
|
[end-pos (get-end-position)])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user