Re: Snippet names

From: mitchell <mforal.n....at.gmail.com>
Date: Tue, 2 Mar 2010 12:04:44 -0800 (PST)

Robert,

> > > I was trying to have snippet names like
> > > my-snippet, my:snippet
> > > This does not work, because the function insert in modules/textadept/
> > > lsnippets.lua
> > > uses word_left_extend() to select the snippet name. This function
> > > stops at ':', '-' etc.
>
> > > As I workaround I inserted the following (around line 314)
> > > buffer.word_chars = "" --remove chars that mark word endings
> > > buffer:word_left_extend()
> > > buffer:set_chars_default() --restore default
>
> > > Is there an easier/better way to do this? Is there any reason why
> > > snippets name like this shuldn't be allowed? If not, I think it would
> > > be nice If this could be included in 2.1.
> > > Of course, the snippet names have to be declared as follows
> > > snippets.html = {
> > >   ['a:test'] = "a test snippet",
> > >   -- because the Lua short cut notation is not possible
> > >   test = '...'
>
> > > }
>
> > Rather than having a default of '' for word_chars, maybe it should be
> > configurable? I was thinking of adding a SNIPPET_WORD_CHARS =
> > 'abcdef..._:-' option to the top of lsnippets.lua, but that seems
> > clunky. Any better ideas? Also, buffer:set_chars_default() might not
> > be what chars may be set in a user's theme. You would have to restore
> > the current set of word chars (though it appears to be '' when I try
> > and textadept.print() it from the command entry rather than
> > 'abcdef...'. Maybe I'm doing something wrong).
>
> Maybe the simplest solution would be to have a space (or line
> beginning) as the delimiter?

I don't mean to be a pain, but some snippets like Ruby's "each" occurs
after a '.', eg:

  collection.each<tab>

expands to

  collection.each { |<tab stop>| <tab stop> }

It's not a bad idea though. Maybe this is one of a tiny number of
cases. I'm not sure.

Mitchell

>
> Robert
Received on Tue 02 Mar 2010 - 15:04:44 EST

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 11:39:33 EST