[plt-scheme] Parentheses and color

From: hendrik at topoi.pooq.com (hendrik at topoi.pooq.com)
Date: Wed Jul 4 10:00:10 EDT 2007

On Tue, Jul 03, 2007 at 11:01:00PM -0400, Eli Barzilay wrote:
> On Jul  4, Jean-Pierre Lozi wrote:
> > 
> > Indentation is useful when you write code. But sometimes, you have
> > to rewrite something within some code you already wrote (say, add a
> > let or a call/cc somewhere), and you don't want to reindent
> > everything just to close the right parenthesis (because you wouldn't
> > even want to re-read the code). You'd rather modify the code
> > quickly, and then reindent it automatically.
> 
> Say that you have this:
> 
>   (define (foo x y)
>     (bar (blah x)
>          y))
> 
> and you want to put the body in a parameterize.  IIUC, you'll stick
> the "(parameterize ([my-param 1])" line, then the closing paren (which
> you'll look for using colors (which will be confusing, because you
> added a new paren so the colors don't match)), and then reindent.
> 
> Here's what I'll do:
> 
> * Put the cursor right before the "(bar ..." line
> * `M-S-right'        (`M' is usually the `alt' key)
> * `M-('              (that is, alt+shift+9 on a us keyboard)
> * type "parameterize "
> * `M-('
> * `M-['
> * type "my-param 1"
> * `right' `right'    (to go to where the line should break)
> * `enter'
> * `M-S-right' `tab'  (to reindent the body)
> 
> If you follow this editing sequence, you'll see for yourself that
> paren counting is never part of the game.  And much more better:
> parens are there mostly to guide the editor -- in this editing
> sequence you don't have to even look at them, you only use them to be
> able to select the body in one key.

When I did this, I got

(define (foo x y)
    S(bar (blah x)
         y)(parameterize([mu-param 1])
             S))

Is that was was desired?

-- hendrik


Posted on the users mailing list.