Re: Snippet names

From: mitchell <>
Date: Mon, 1 Mar 2010 09:32:29 -0800 (PST)


Sorry for the late reply.

> 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).


> Thanks!
> Robert
Received on Mon 01 Mar 2010 - 12:32:29 EST

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