[plt-scheme] Parentheses and color

From: Eli Barzilay (eli at barzilay.org)
Date: Tue Jul 3 23:01:00 EDT 2007

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)

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.

On Jul  4, Jean-Pierre Lozi wrote:
> > Mmh... I'm not so sure. It's like saying some users are really
> > quick with vim+latex, so IDEs are useless.
> I meant, so WYSIWIG programs are useless.

WYSIWYG is a fine approach to editing visual forms -- programming is a
symbolic process.  (In other words -- those users who are quick with
vim/emacs+latex have a good reason to stick with that and not switch
to, say, Word.)

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!

Posted on the users mailing list.