Re: [code] Feature request: snippet._insert should allow replacing the selection

From: Pedro Andres Aranda Gutierrez <paaguti.att.gmail.com>
Date: Tue, 18 Apr 2017 12:26:01 +0200

Hi Mitchell,

no worries. I do fully understand and appreciate your effort. I'm just
trying to see where the problem is from "outside the box". It has sometimes
helped me to have people looking at was actually happening and not at the
code. If this is not helpful, just tell me and I'll stop bugging.

So my take is the following:

There are two situations:
1.- I type a snippet trigger and then 'Tab' and that is working
2. I have a part of the buffer selected and then I go and select a snippet
from the menu
t is here where we have the problem. Again, from outside the box, I would
expect something like a
buffer:replace_sel(<expanded snippet>)
but I seem to be getting a
buffer:insert_text(<expanded snippet>)
Because the generated snippet is appended after the selection.

This is why I say that when we bind a snippet to a key, the function may
have to be something different than snippet._insert(), which is bound to
<Tab>. Of course, if snippet._insert() is made to replace the selection
instead of appending text after the selection, the bug would be solved...

My .0002 cents,
/PA

On 18 April 2017 at 02:53, Mitchell <m.att.foicica.com> wrote:

> Hi Pedro,
>
> On Mon, 17 Apr 2017, Pedro Andres Aranda Gutierrez wrote:
>
> Happy Easter to everybody!
>>
>> I have been giving this issue a thought and I think that we may need to
>> split treatments depending on whether it is the Tab key or not that calls
>> the function. Something like:
>>
>> When tab is pressed, we execute the following function
>>
>> get the word before the cursor and try to find a snippet
>> if found:
>> kill the word before the trigger
>> execute the snippet associated to the word
>> else:
>> insert a tab
>>
>
> Okay, the Tab key is already bound to a function that does this very thing.
>
> When we bind a key to a snippet, then we only execute the snippet
>> associated to the word we indicate in the code
>>
>
> I can bind a key to `function() snippets._insert(snippet_text) end` and it
> works as I expected (except for some cases of selected text as pointed out
> earlier in this thread).
>
> I'm having trouble understanding where Textadept is falling short in your
> opinion (other than the bug that I have not had the time to look into yet,
> sorry).
>
> Would that kill recursive snippets?
>>
>
> I'm not sure what you mean be recursive. Perhaps nested? If so, no that
> would not kill nested snippets -- it would just add another one to the
> stack.
>
>
> 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.
>
>

-- 
Fragen sind nicht da um beantwortet zu werden,
Fragen sind da um gestellet zu werden
Georg Kreisler
-- 
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 Tue 18 Apr 2017 - 06:26:01 EDT

This archive was generated by hypermail 2.2.0 : Tue 18 Apr 2017 - 06:52:29 EDT