added option to disable magic open parens separately from magic close ones

svn: r2833

original commit: 1072ac68aa5e753a3e18cd674e1df26199759251
This commit is contained in:
Robby Findler 2006-04-28 08:57:05 +00:00
parent cf2a67cc6a
commit e3cb1de717
4 changed files with 21 additions and 12 deletions

View File

@ -148,6 +148,7 @@
(preferences:set-default 'framework:highlight-parens #t boolean?) (preferences:set-default 'framework:highlight-parens #t boolean?)
(preferences:set-default 'framework:fixup-parens #t boolean?) (preferences:set-default 'framework:fixup-parens #t boolean?)
(preferences:set-default 'framework:fixup-open-parens #t boolean?)
(preferences:set-default 'framework:paren-match #t boolean?) (preferences:set-default 'framework:paren-match #t boolean?)
(let ([hash-table (make-hash-table)]) (let ([hash-table (make-hash-table)])
(for-each (λ (x) (for-each (λ (x)

View File

@ -656,7 +656,11 @@ for the last one, need a global "no more initialization can happen" flag.
values values) values values)
(make-check scheme-panel (make-check scheme-panel
'framework:fixup-parens 'framework:fixup-parens
(string-constant fixup-parens) (string-constant fixup-close-parens)
values values)
(make-check scheme-panel
'framework:fixup-open-parens
(string-constant fixup-open-parens)
values values) values values)
(make-check scheme-panel (make-check scheme-panel
'framework:paren-match 'framework:paren-match

View File

@ -975,7 +975,7 @@
(inherit is-frozen? is-stopped?) (inherit is-frozen? is-stopped?)
(define/public (rewrite-square-paren) (define/public (rewrite-square-paren)
(cond (cond
[(or (not (preferences:get 'framework:fixup-parens)) [(or (not (preferences:get 'framework:fixup-open-parens))
(is-frozen?) (is-frozen?)
(is-stopped?)) (is-stopped?))
(insert #\[ (insert #\[
@ -1248,10 +1248,10 @@
;; we found a new expression, two steps back, so we don't use the sibling ;; we found a new expression, two steps back, so we don't use the sibling
;; check here -- we just go with square brackets. ;; check here -- we just go with square brackets.
[(and backward-match2 [(and backward-match2
(text-between-equal? "new" (ormap
text (λ (x)
backward-match2 (text-between-equal? x text backward-match2 before-whitespace-pos2))
before-whitespace-pos2)) '("new" "case")))
(void)] (void)]
[(member b-m-char '(#\( #\[ #\{)) [(member b-m-char '(#\( #\[ #\{))
;; found a "sibling" parenthesized sequence. use the parens it uses. ;; found a "sibling" parenthesized sequence. use the parens it uses.
@ -1305,11 +1305,13 @@
0)]) 0)])
(cond (cond
[(and second-backwards-match2 [(and second-backwards-match2
(text-between-equal? "let" (ormap (λ (x)
text (text-between-equal? x
second-backwards-match2 text
second-before-whitespace-pos2)) second-backwards-match2
;; found the `(let loop (' so we keep the [ second-before-whitespace-pos2))
'("let")))
;; found the `(let loop (' or `case' so we keep the [
(void)] (void)]
[else [else
;; otherwise, round. ;; otherwise, round.

View File

@ -139,7 +139,9 @@
(build-open-bracket-spec "ab" 1 #\() (build-open-bracket-spec "ab" 1 #\()
(build-open-bracket-spec "|ab|" 2 #\[) (build-open-bracket-spec "|ab|" 2 #\[)
(build-open-bracket-spec "(let loop " 10 #\() (build-open-bracket-spec "(let loop " 10 #\()
(build-open-bracket-spec "(let loop (" 11 #\[))) (build-open-bracket-spec "(let loop (" 11 #\[)
(build-open-bracket-spec "(case x " 8 #\[)
(build-open-bracket-spec "(case x [" 9 #\()))
(send-sexp-to-mred `(send (make-object frame:basic% "dummy to trick frame group") show #t)) (send-sexp-to-mred `(send (make-object frame:basic% "dummy to trick frame group") show #t))