Revision: 4852 http://geany.svn.sourceforge.net/geany/?rev=4852&view=rev Author: ntrel Date: 2010-04-22 13:01:45 +0000 (Thu, 22 Apr 2010)
Log Message: ----------- Support {pc} wildcard in snippets to escape percent char.
Modified Paths: -------------- trunk/ChangeLog trunk/doc/geany.html trunk/doc/geany.txt trunk/src/editor.c trunk/src/templates.c trunk/src/templates.h
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-04-22 12:25:20 UTC (rev 4851) +++ trunk/ChangeLog 2010-04-22 13:01:45 UTC (rev 4852) @@ -6,6 +6,9 @@ * src/keybindings.c, src/keybindings.h, src/plugindata.h: Constify some more string pointers in the API (patch by Colomban Wendling, thanks). + * src/templates.c, src/templates.h, src/editor.c, doc/geany.txt, + doc/geany.html: + Support {pc} wildcard in snippets to escape percent char.
2010-04-21 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
Modified: trunk/doc/geany.html =================================================================== --- trunk/doc/geany.html 2010-04-22 12:25:20 UTC (rev 4851) +++ trunk/doc/geany.html 2010-04-22 13:01:45 UTC (rev 4852) @@ -4887,14 +4887,19 @@ </thead> <tbody valign="top"> <tr><td>ob</td> -<td>Opening Brace (used to prevent other +<td>{ Opening Brace (used to prevent other wildcards being expanded).</td> <td>file templates, file header, snippets.</td> </tr> <tr><td>cb</td> -<td>Closing Brace.</td> +<td>} Closing Brace.</td> <td>file templates, file header, snippets.</td> </tr> +<tr><td>pc</td> +<td>% Percent (used to escape e.g. %block% in +snippets).</td> +<td>snippets.</td> +</tr> <tr><td>developer</td> <td>The name of the developer.</td> <td>file templates, file header, @@ -5996,7 +6001,7 @@ <div class="footer"> <hr class="footer" /> <a class="reference" href="geany.txt">View document source</a>. -Generated on: 2010-04-21 17:17 UTC. +Generated on: 2010-04-22 12:45 UTC. Generated by <a class="reference" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
</div>
Modified: trunk/doc/geany.txt =================================================================== --- trunk/doc/geany.txt 2010-04-22 12:25:20 UTC (rev 4851) +++ trunk/doc/geany.txt 2010-04-22 13:01:45 UTC (rev 4852) @@ -4230,9 +4230,11 @@ ============== ============================================= ======================================= Wildcard Description Available in ============== ============================================= ======================================= -ob Opening Brace (used to prevent other file templates, file header, snippets. +ob { Opening Brace (used to prevent other file templates, file header, snippets. wildcards being expanded). -cb Closing Brace. file templates, file header, snippets. +cb } Closing Brace. file templates, file header, snippets. +pc % Percent (used to escape e.g. %block% in + snippets). snippets.
developer The name of the developer. file templates, file header, function description, ChangeLog entry,
Modified: trunk/src/editor.c =================================================================== --- trunk/src/editor.c 2010-04-22 12:25:20 UTC (rev 4851) +++ trunk/src/editor.c 2010-04-22 13:01:45 UTC (rev 4852) @@ -2275,7 +2275,7 @@ g_hash_table_foreach(specials, snippets_replace_specials, NULL); }
- /* replace any %template% wildcards */ + /* replace any template {foo} wildcards */ templates_replace_common(pattern, editor->document->file_name, editor->document->file_type, NULL);
/* transform other wildcards */ @@ -2336,6 +2336,10 @@ utils_string_replace_all(pattern, "%ws%", whitespace); g_free(whitespace);
+ /* escape % last */ + /* Bug: {ob}pc{cb} will be replaced by % too */ + templates_replace_valist(pattern, "{pc}", "%", NULL); + /* We put the cursor positions for the most recent * parsed snippet first, followed by any remaining positions */ i = 0;
Modified: trunk/src/templates.c =================================================================== --- trunk/src/templates.c 2010-04-22 12:25:20 UTC (rev 4851) +++ trunk/src/templates.c 2010-04-22 13:01:45 UTC (rev 4852) @@ -128,9 +128,9 @@
static void replace_static_values(GString *text); static gchar *get_template_fileheader(GeanyFiletype *ft); + +/* called by templates_replace_common */ static void templates_replace_default_dates(GString *text); -static void templates_replace_valist(GString *text, - const gchar *first_wildcard, ...) G_GNUC_NULL_TERMINATED; static void templates_replace_command(GString *text, const gchar *file_name, const gchar *file_type, const gchar *func_name);
@@ -723,7 +723,7 @@ * "{another_wildcard}", "another value", NULL); * * The argument list must be terminated with NULL. */ -static void templates_replace_valist(GString *text, const gchar *first_wildcard, ...) +void templates_replace_valist(GString *text, const gchar *first_wildcard, ...) { va_list args; const gchar *key, *value;
Modified: trunk/src/templates.h =================================================================== --- trunk/src/templates.h 2010-04-22 12:25:20 UTC (rev 4851) +++ trunk/src/templates.h 2010-04-22 13:01:45 UTC (rev 4852) @@ -73,8 +73,11 @@ gchar *templates_get_template_licence(GeanyDocument *doc, gint licence_type);
void templates_replace_common(GString *template, const gchar *fname, - GeanyFiletype *ft, const gchar *func_name); + GeanyFiletype *ft, const gchar *func_name);
+void templates_replace_valist(GString *text, + const gchar *first_wildcard, ...) G_GNUC_NULL_TERMINATED; + void templates_free_templates(void);
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.