[plt-scheme] DrScheme now rewrites opening square brackets, too

From: Robby Findler (robby at cs.uchicago.edu)
Date: Tue Apr 11 19:35:35 EDT 2006

After reading Neil's web page and seeing mention of smart open parens
for the second or third time recently, I was inspired to extend
DrScheme's paren remapping to handle open square brackets (this is not
what quack does; quack was just the inspiration).

An excerpt from the (new) manual is below, explaining the particulars.

Please do let me know if you find a case where DrScheme is being too
agressive about changing the parens. Otherwise, do try to get used to
typing only (the hopefully unshifted on your keyboard too) [] from now
on.

Robby

  ... DrScheme also rewrites open square brackets, usually to an open
  parenthesis. There are four cases where opening square brackets are
  not changed to parentheses:

  - if the square bracket is after the cond keyword, 

  - if the square bracket is after a parenthesis that is after a let,
    let*, letrec (or similar) keyword, 

  - if the square bracket is in a sequence and the s-expression before
    in the sequence is a compound expression, DrScheme uses the same
    kind parenthesis, brace, or bracket as before, or

  - if the square bracket is in the middle of string, comment, or symbol.

  For example, when typing this:

   (define (length l)
     (cond
       [(empty? l) 0]
       [else (+ 1 (length (rest l)))]))

  If you always type ``['' and ``]'' where any of the square brackets
  or parentheses appear, DrScheme will change the square brackets to
  match the code above.

  The upshot of DrScheme's trickery: always use the (presumably
  unshifted) square brackets on your keyboard to type parenthesis. Of
  course, these features can be disabled in the preferences dialog (see
  section~\ref{prefs-explanation}).



Posted on the users mailing list.