[code] [textadept] Snippets refactoring

From: Mitchell <m.att.foicica.com>
Date: Fri, 18 Sep 2015 21:56:25 -0400 (EDT)

Hi,

I've committed a change[1] that refactored Textadept's snippet
implementation to use indicators instead of placeholder text (all those
ugly %()<>[] symbols are now gone!).

This is a *breaking* change when it comes to *transforms ONLY* (%n<lua
code> and %n[shell code]). If you're not using those, then there's nothing
for you to worry about and your existing snippets will work just fine
without modification.

Transforms can no longer contain embedded placeholders. Therefore this
silly example will no longer work:

   snippets.add = '%1(1) + %2(2) = %3<%1 + %2>'

(It never really seemed that useful, nor did it match the functionality of
real snippet transforms in Textmate and other editors.)

Instead, this commit introduces true transforms. For example:

   snippets.attr = [[
   %1(int) %2(foo) = %3;

   %1 get%2<text:gsub('^.', function(c) return c:upper() end)>() {
           return %2;
   }
   void set%2<text:gsub('^.', function(c) return c:upper() end)>(%1 val) {
           %2 = val;
   }
   ]]

Given a 'foo' attribute, 'getFoo' and 'setFoo' methods will be created
automatically, transforming 'foo' to title-case.

This should show up in tonight's nightly. Please report any bugs and
regressions you come across.

Cheers,
Mitchell

[1]: http://foicica.com/hg/textadept/rev/d7d54be91221

-- 
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 Fri 18 Sep 2015 - 21:56:25 EDT

This archive was generated by hypermail 2.2.0 : Sat 19 Sep 2015 - 06:39:43 EDT