summaryrefslogtreecommitdiff
path: root/src/plugins/scripts/script.c
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2009-06-11 16:51:50 +0200
committerSebastien Helleu <flashcode@flashtux.org>2009-06-11 16:51:50 +0200
commitec5c3aa3cc1970240f5d3afa05f50bcccc584744 (patch)
tree3d3aac92702fe0ccd20c9dc353780ae568dd5289 /src/plugins/scripts/script.c
parent652a97cc7af805e5cbbd2671d5a98998188ab041 (diff)
downloadweechat-ec5c3aa3cc1970240f5d3afa05f50bcccc584744.zip
Improve completion for script plugins commands
Diffstat (limited to 'src/plugins/scripts/script.c')
-rw-r--r--src/plugins/scripts/script.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/plugins/scripts/script.c b/src/plugins/scripts/script.c
index b7a2c124c..24f23c3d3 100644
--- a/src/plugins/scripts/script.c
+++ b/src/plugins/scripts/script.c
@@ -207,7 +207,7 @@ script_init (struct t_weechat_plugin *weechat_plugin,
int (*callback_buffer_close) (void *data,
struct t_gui_buffer *buffer))
{
- char *string, *completion = "list|listfull|load|autoload|reload|unload %(filename)";
+ char *string, *completion;
char infolist_description[512], signal_name[128];
int length, i, upgrading;
@@ -237,12 +237,21 @@ script_init (struct t_weechat_plugin *weechat_plugin,
}
/* add command */
- length = strlen (completion) + strlen (weechat_plugin->name) + 16;
+ completion = NULL;
+ length = strlen (weechat_plugin->name) + 16;
string = malloc (length);
if (string)
{
- snprintf (string, length, "%s|%%(%s_script)",
- completion, weechat_plugin->name);
+ snprintf (string, length, "%%(%s_script)",
+ weechat_plugin->name);
+ completion = weechat_string_replace ("list %s"
+ " || listfull %s"
+ " || load %(filename)"
+ " || autoload"
+ " || reload"
+ " || unload %s",
+ "%s",
+ string);
}
weechat_hook_command (weechat_plugin->name,
N_("list/load/unload scripts"),
@@ -253,10 +262,12 @@ script_init (struct t_weechat_plugin *weechat_plugin,
"name: a script name\n\n"
"Without argument, this command "
"lists all loaded scripts."),
- (string) ? string : completion,
+ completion,
callback_command, NULL);
if (string)
free (string);
+ if (completion)
+ free (completion);
/* add completion and infolist */
length = strlen (weechat_plugin->name) + 16;