Re: [code] Auto-pairing feature request

From: Mitchell <m.att.foicica.com>
Date: Wed, 30 Jan 2013 10:41:57 -0500 (Eastern Standard Time)

Hi Ryan,

On Wed, 30 Jan 2013, Ryan Pusztai wrote:

> On Wed, Jan 30, 2013 at 8:19 AM, Michael Richter <ttmrichter.att.gmail.com>wrote:
>
>> I like the auto-pairing of symbols like ", ', (, et al but for one tiny
>> annoyance: breaking OUT of the pair slows me down.
>>
>> Let's say I want to type the following line:
>>
>> turing(bb_config, busy_beaver, [], To).
>>
>> First I type this where the ^ marks my cursor location:
>>
>> turing(^)
>>
>> This is all fine and dandy. Now I keep typing.
>>
>> turing(bb_config, busy_beaver, [^])
>>
>> Again all fine and dandy. But here it breaks down. To get *out* of the
>> square brackets I have to move my hand away from the convenient places of
>> my keyboard and over to the cursor controls. This is a distraction for
>> reasons I'll get into later. So anyway, I continue typing:
>>
>> turing(bb_config, busy_beaver, [], To^)
>>
>> Now I have to move my hand away from the typing space *again* to escape
>> the parens. Finally I can finish and type the whole line.
>>
>> Many editors do the pair-matching thing. All of them that I've used (most
>> recently Sublime Text, <plug type="shameless">for which review you can read
>> here:
>> http://yfl.bahmanm.com/Members/ttmrichter/software-reviews/sublime-text-2-review</plug>)
>> have the following behaviour. Let's turn back the clock to this:
>>
>> turing(bb_config, busy_beaver, [^])
>>
>> I'm in the auto-matching mode, so when I type ], I don't insert an
>> unbalanced closing bracket, I instead just move forward past the bracket
>> like this:
>>
>> turing(bb_config, busy_beaver, []^)
>>
>> Then I continue typing to this:
>>
>> turing(bb_config, busy_beaver, [], To^)
>>
>> I hit the closing paren and get this instead:
>>
>> turing(bb_config, busy_beaver, [], To)^
>>
>> I can then easily follow up with the period. No muss, no fuss, no bother.
>>
>> Now in this line of code alone I've had to move my hands away from the
>> typing area twice. And this is simple Prolog code. Could you imagine if I
>> was doing Java or, worse, Lisp? My hands would rarely be in the typing
>> space with all the bracket-jumping I'd have to do.
>>
>> So as a feature request, would it be possible to somehow break out of the
>> matched parens without moving the hand away from the main keyboard area?
>> Ideally typing the matching closing character would be the technique, but
>> I'm open to other ideas that keep my fingers in my active zone. I really
>> like the auto-pairing feature so I'd rather not turn it off completely.
>>
>
> Oh this is a great description of the way I dream of TA to work. I would
> love this feature! Can this be implemented ASAP on my own? and then be
> added to the main releases?

Yes, you can probably do it on your own. In an events.CHAR_ADDED event you
can check for ')', ']', '}' and see if buffer.char_at[buffer.current_pos]
is the char and if buffer:brace_match(buffer.current_pos) ~= -1, call
buffer:char_right().

That's my initial thought, but I'll have to first see if that works and
then iron out the rough edges.

Cheers,
Mitchell

-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Wed 30 Jan 2013 - 10:41:57 EST

This archive was generated by hypermail 2.2.0 : Thu 31 Jan 2013 - 06:37:24 EST