[squeak-dev] How do I convince a Workspace to stop "helping" me?

Frank Shearar frank.shearar at gmail.com
Thu Apr 10 15:48:06 UTC 2014


On 10 April 2014 16:11, Chris Muller <asqueaker at gmail.com> wrote:
> Frank wrote:
>
>> What would make
>> auto-enclose much more paredit like is automating the manipulation of
>> parens.  Not just adding a ) every time you type a ( but letting e you
>> "slurp" expressions into the enclosing paren (whether [], {} or ()
>> parens) or "burp" them out, deleting empty pairs of parens, and so on.
>
> Hey, did you happen to know about Command+', Command+Shift+",
> Command+(, Command+[, and Command+Shift+{ ?   :-)   They let you do
> exactly what I think you're saying.
>
> 1) Select an expression by either click+drag, double-clicking just
> inside any of ', ", (, [, {, }, ], or ), or, if you're at the
> keyboard, Command+Space when the text-cursor is positioned there.
> Note, the selection does not include the bracket/paren characters
> themselves, but up-to just inside them.
>
> 2) Press one of the above-mentioned Command key sequences.  If you
> press the same one that you're already in, it will toggle between
> adding/removing that expression ("slurp").  If you press one of those
> Command-key sequences that is different than the expression, it will
> add that surrounding bracket around the expression, toggling it on and
> off ("burp").

Right, so that's part of it. By "slurp" I mean moving the inner
brackets in (+ 1 (+ 2 3) 4) to (+ 1 (+ 2 3 4)). Moving from (+ 1 (+ 2
3 4)) to (+ 1 (+ 2 3) 4) would be to "burp" the 4 out of the inner
expression.

In Smalltalk, I could see something like this happening. Ignore for
the moment the fact that the code's clearly ridiculously
side-effectful. You start with

    self foo.
    self bar.
    self baz.

But you realise you should only send #bar under certain conditions. So
you move your cursor before "self bar". You hit (, and your code
changes to

    self foo.
    (|) self bar.
    self baz.

where | indicates the cursor position. You type in the condition and
right-arrow to move outside the parens. (Really, there needs to be a
keypress called "move one expression forward"):

    self foo.
    (self isBarrable)| self bar.
    self baz.

and you enter ifTrue: which, since it takes a block, adds a [] for you:

    self foo.
    (self isBarrable) ifTrue: [|] self bar.
    self baz.

and then you can "slurp" the expression:

    self foo.
    (self isBarrable) ifTrue: [self bar|].
    self baz.

But then you realise that you only send #baz under the same condition,
and you can slurp the next expression:

    self foo.
    (self isBarrable) ifTrue: [
        self bar.
        self baz|].

At a later time you change things so that the #baz send is
unconditional, and you "burp" out the expression by moving the cursor
inside the []s and hitting the "burp expression" command key.

    self foo.
    (self isBarrable) ifTrue: [
        self bar|].
    self baz.

(I've also illustrated the editing experience autoformatting. In Lisp
this is a no-brainer: if your code doesn't match Emacs indentation
rules, it's wrong, end of discussion. (In Go, it's a _compiler error_
to deviate from One True Brace Style.))

I hope that explains what I wouldn't mind seeing in a Smalltalk text editor.

frank

>  - Chris
>
>> Paredit takes a bit of getting used to - precisely because you're
>> leaning on the IDE more to manipulate expressions rather than
>> adding/deleting characters but once you get used to it, it's
>> awesome.
>
>
>
>>
>> frank
>>
>


More information about the Squeak-dev mailing list