Re: Snippet names

From: Robert <ro....at.web.de>
Date: Tue, 2 Mar 2010 11:49:58 -0800 (PST)

Hi

> Sorry for the late reply.

Thanks for the 2.1 update!

>
> > 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?

Robert
Received on Tue 02 Mar 2010 - 14:49:58 EST

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