adjusted how paren matching inside {} works for better tabbing in scribble mode
original commit: 666c55953254fee063331290c4fb3784acbd1fa8
This commit is contained in:
parent
437ba21fd5
commit
9624a40ecf
|
@ -580,6 +580,12 @@
|
|||
(let* ([proc-name (get-proc)])
|
||||
(or (eq? proc-name 'define)
|
||||
(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)))])
|
||||
(when (and is-tabbable?
|
||||
(not (char=? (get-character (sub1 end))
|
||||
|
@ -598,15 +604,31 @@
|
|||
[(not contains)
|
||||
;; Something went wrong matching. Should we get here?
|
||||
(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)
|
||||
;; We can't find a match backward from pos,
|
||||
;; but we seem to be inside an S-exp, so
|
||||
;; go "up" an S-exp, and move forward past
|
||||
;; the associated paren
|
||||
(let ([enclosing (find-up-sexp pos)])
|
||||
(do-indent (if enclosing
|
||||
(+ (visual-offset enclosing) 1)
|
||||
0)))]
|
||||
(if enclosing
|
||||
(do-indent (+ (visual-offset enclosing) 1))
|
||||
(do-indent 0)))]
|
||||
[(= contains last)
|
||||
;; There's only one S-expr in the S-expr
|
||||
;; containing "pos"
|
||||
|
|
Loading…
Reference in New Issue
Block a user