diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2009-05-08 10:31:15 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2009-05-08 10:31:15 +0200 |
commit | 2783b512015e0a42b528042a218d0e3a8843b7e5 (patch) | |
tree | 9d5e89652388f3615e7383ea0c913946cf85d1c6 /src/plugins/alias | |
parent | d3976c2afe608d70724e2d3d59093b6fbb3d230a (diff) | |
download | weechat-2783b512015e0a42b528042a218d0e3a8843b7e5.zip |
Improve completion: allow a command to use completion of another command (used by alias plugin)
Diffstat (limited to 'src/plugins/alias')
-rw-r--r-- | src/plugins/alias/alias.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/plugins/alias/alias.c b/src/plugins/alias/alias.c index ab0dcdc40..0b51c9bdd 100644 --- a/src/plugins/alias/alias.c +++ b/src/plugins/alias/alias.c @@ -378,6 +378,8 @@ alias_new (const char *name, const char *command) { struct t_alias *new_alias, *ptr_alias, *pos_alias; struct t_hook *new_hook; + char *str_completion; + int length; if (!name || !name[0] || !command || !command[0]) return NULL; @@ -399,8 +401,18 @@ alias_new (const char *name, const char *command) new_alias = malloc (sizeof (*new_alias)); if (new_alias) { - new_hook = weechat_hook_command (name, "[alias]", NULL, NULL, NULL, + length = 2 + strlen (command) + 1; + str_completion = malloc (length); + if (str_completion) + { + snprintf (str_completion, length, "%%%%%s", + (command[0] == '/') ? command + 1 : command); + } + new_hook = weechat_hook_command (name, "[alias]", NULL, NULL, + (str_completion) ? str_completion : NULL, alias_cb, new_alias); + if (str_completion) + free (str_completion); if (!new_hook) { free (new_alias); |