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:
Robby Findler 2007-02-05 19:25:25 +00:00
parent bc3ee684bc
commit 9d1a810f9b

View File

@ -539,14 +539,18 @@
;; So far, the S-exp containing "pos" was all on
;; one line (possibly not counting the opening paren),
;; 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)])
(if id-end
(- id-end contains)
0))])
(if (second-sexp-is-ellipsis? contains)
(do-indent (visual-offset contains))
(do-indent (+ (visual-offset contains)
name-length
(indent-first-arg (+ contains
name-length)))))]
name-length))))))]
[else
;; No particular special case, so indent to match first
;; S-expr that start on the previous line
@ -558,6 +562,22 @@
(loop next-to-last next-to-last-para)
(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
(opt-lambda ([start-pos (get-start-position)]
[end-pos (get-end-position)])