[Geany-devel] Default snippets

Colomban Wendling lists.ban at xxxxx
Fri Aug 26 13:36:27 UTC 2011

Le 26/08/2011 14:49, Alexander Eberspächer a écrit :
> Hey Lex, hello list,
> On Fri, 26 Aug 2011 22:04:01 +1000
> Lex Trotman <elextr at gmail.com> wrote:
>> Maybe you should preserve default behavior on the basis that someone
>> decided it to be that way, unless you know no one cares.
> I want to make my point about assumptions a bit clearer: if a user
> writes 'for' in C program and hits the completion key, one can be sure
> that this user wants a for loop. However, you cannot (and IMHO, to keep
> snippets useful for any user, must not) be sure that the user wants 'i'
> to be the counting variable.
> So, what do other people think? The patch should not break what people
> actually use. However, a *consistent* set of snippets uses either a
> default counting variable for all languages or doesn't fill in any at
> all.

I agree that the current snippets do too much assumptions on what the
user wants: I personally generally don't want the default "for"
behavior, because I don't only iterate over an "i" variable from 0 to n.

So IMHO it's a good idea to have more generic snippets, maybe for C's
"for" something like:

	for (%cursor%; %cursor%; %cursor%)%block_cursor%

or even your suggested one:

	for (%cursor%)%block_cursor%

if typing the semicolons feels more natural than moving in the snippet.

>> PPS there seem to be line breaks in some entries, (eg switch)  entries
>> must be on one line
> Can't see any line breaks.
> So I hope there will be some discussion on what the default snippets
> should do. I am happy to create a patch that does just whatever the
> discussion results in.

Just a comment on the patch, based on a cursory reading: please use
[Special] whenever possible to let the user choose her newline & co
policy.  For example, the "do" snippet:

	do=do\n{\n\t%cursor%\n} while (%cursor%)\n%cursor%

should use at least %brace_open% in place of "\n{\n\t", and probably
even %block%:

	do=do%block% while (%cursor%)\n%cursor%

BTW, it also misses the final semicolon:

	do=do%block% while (%cursor%);\n%cursor%


More information about the Devel mailing list