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
|
@ -539,14 +539,18 @@
|
||||||
;; 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))])
|
||||||
|
(if (second-sexp-is-ellipsis? contains)
|
||||||
|
(do-indent (visual-offset contains))
|
||||||
(do-indent (+ (visual-offset contains)
|
(do-indent (+ (visual-offset contains)
|
||||||
name-length
|
name-length
|
||||||
(indent-first-arg (+ contains
|
(indent-first-arg (+ contains
|
||||||
name-length)))))]
|
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
|
||||||
|
@ -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