adjusted how paren matching inside {} works for better tabbing in scribble mode
This commit is contained in:
parent
b823b94cda
commit
666c559532
|
@ -580,6 +580,12 @@
|
||||||
(let* ([proc-name (get-proc)])
|
(let* ([proc-name (get-proc)])
|
||||||
(or (eq? proc-name 'define)
|
(or (eq? proc-name 'define)
|
||||||
(eq? proc-name 'lambda))))]
|
(eq? proc-name 'lambda))))]
|
||||||
|
[curley-brace-sexp?
|
||||||
|
(λ ()
|
||||||
|
(define up-p (find-up-sexp pos))
|
||||||
|
(and up-p
|
||||||
|
(equal? #\{ (get-character up-p))))]
|
||||||
|
|
||||||
[indent-first-arg (λ (start) (car (find-offset start)))])
|
[indent-first-arg (λ (start) (car (find-offset start)))])
|
||||||
(when (and is-tabbable?
|
(when (and is-tabbable?
|
||||||
(not (char=? (get-character (sub1 end))
|
(not (char=? (get-character (sub1 end))
|
||||||
|
@ -598,15 +604,31 @@
|
||||||
[(not contains)
|
[(not contains)
|
||||||
;; Something went wrong matching. Should we get here?
|
;; Something went wrong matching. Should we get here?
|
||||||
(do-indent 0)]
|
(do-indent 0)]
|
||||||
|
[(curley-brace-sexp?)
|
||||||
|
;; when we are directly inside an sexp that uses {}s,
|
||||||
|
;; we indent in a more C-like fashion (to help Scribble)
|
||||||
|
(define first-curley (find-up-sexp pos))
|
||||||
|
(define containing-curleys
|
||||||
|
(let loop ([pos first-curley])
|
||||||
|
(let ([next (find-up-sexp pos)])
|
||||||
|
(if (and next
|
||||||
|
(equal? (get-character next) #\{))
|
||||||
|
(+ (loop next) 1)
|
||||||
|
1))))
|
||||||
|
(define close-first-curley (get-forward-sexp first-curley))
|
||||||
|
(define para (position-paragraph pos))
|
||||||
|
(when (<= (paragraph-start-position para) close-first-curley (paragraph-end-position para))
|
||||||
|
(set! containing-curleys (max 0 (- containing-curleys 1))))
|
||||||
|
(do-indent (* containing-curleys 2))]
|
||||||
[(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
|
||||||
(let ([enclosing (find-up-sexp pos)])
|
(let ([enclosing (find-up-sexp pos)])
|
||||||
(do-indent (if enclosing
|
(if enclosing
|
||||||
(+ (visual-offset enclosing) 1)
|
(do-indent (+ (visual-offset enclosing) 1))
|
||||||
0)))]
|
(do-indent 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"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user