[racket] [racket-dev] Survey for DrRacket users related to automatic parentheses behavior

From: Eli Barzilay (eli at barzilay.org)
Date: Sat Nov 24 16:52:08 EST 2012

7 hours ago, Robby Findler wrote:
> On Sat, Nov 24, 2012 at 8:53 AM, Laurent <laurent.orseau at gmail.com> wrote:
> >
> > I think it would already be good enough to only consider the case
> > where the user types the paren and wants to remove them
> > immediately (e.g., he placed them in the wrong place, or wanted
> > square brackets instead, or just changed his mind).  In the case
> > of meanwhile edits, I don't think the user would bother deleting
> > the closing paren himself.
> 
> I think that hidden state like this can lead to confusing behavior.
> Probably you want to have deleting a paren do the same thing,
> regardless of what the character most recently typed was.

+1 for avoiding such hidden state.  IIUC the xcode thing that was
mentioned tries to improve it by having a visible indication for the
stae, but I still think that the paredit behavr is better here -- when
you press backspace, this is what happens:

  * If the preceding character is not a paren, it's removed as usual
  * If it's a close paren, the cursor just goes to its left
  * If it's an open parn then
    - if the corresponding closing paren is on the right of the
      cursor, delete both
    - otherwise do nothing

The delete key works similarly in the other direction.

To demonstrate it, after I type "(define(foo x)(+ x 1", I get this:

  (define (foo x) (+ x 1)|)

and hitting backspace now goes as follows:

  (define (foo x) (+ x 1)|)
  (define (foo x) (+ x 1|))
  (define (foo x) (+ x |))
  (define (foo x) (+ x|))
  (define (foo x) (+ |))
  (define (foo x) (+|))
  (define (foo x) (|))
  (define (foo x) |)
  (define (foo x)|)
  (define (foo x|))
  (define (foo |))
  (define (foo|))
  (define (fo|))
  (define (f|))
  (define (|))
  (define |)
  (define|)
  (defin|)
  (defi|)
  (def|)
  (de|)
  (d|)
  (|)
          ; and finally nothing

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

Posted on the users mailing list.