summaryrefslogtreecommitdiff
path: root/src/gui/gui-completion.c
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2009-05-08 10:31:15 +0200
committerSebastien Helleu <flashcode@flashtux.org>2009-05-08 10:31:15 +0200
commit2783b512015e0a42b528042a218d0e3a8843b7e5 (patch)
tree9d5e89652388f3615e7383ea0c913946cf85d1c6 /src/gui/gui-completion.c
parentd3976c2afe608d70724e2d3d59093b6fbb3d230a (diff)
downloadweechat-2783b512015e0a42b528042a218d0e3a8843b7e5.zip
Improve completion: allow a command to use completion of another command (used by alias plugin)
Diffstat (limited to 'src/gui/gui-completion.c')
-rw-r--r--src/gui/gui-completion.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/gui/gui-completion.c b/src/gui/gui-completion.c
index 50e4b5328..f41f93bf4 100644
--- a/src/gui/gui-completion.c
+++ b/src/gui/gui-completion.c
@@ -209,7 +209,7 @@ gui_completion_stop (struct t_gui_completion *completion,
*/
struct t_hook *
-gui_completion_search_command (struct t_gui_completion *completion)
+gui_completion_search_command (const char *command)
{
struct t_hook *ptr_hook;
@@ -220,7 +220,7 @@ gui_completion_search_command (struct t_gui_completion *completion)
&& HOOK_COMMAND(ptr_hook, command)
&& HOOK_COMMAND(ptr_hook, command)[0]
&& (string_strcasecmp (HOOK_COMMAND(ptr_hook, command),
- completion->base_command) == 0))
+ command) == 0))
return ptr_hook;
}
@@ -1397,7 +1397,22 @@ gui_completion_get_template_for_args (struct t_gui_completion *completion,
struct t_hook *hook_command)
{
int matching_template;
-
+
+ /* if template refers to another command, search this command and use its
+ template */
+ if ((HOOK_COMMAND(hook_command, cplt_templates)[0][0] == '%')
+ && (HOOK_COMMAND(hook_command, cplt_templates)[0][1] == '%')
+ && (HOOK_COMMAND(hook_command, cplt_templates)[0][1]))
+ {
+ hook_command = gui_completion_search_command (HOOK_COMMAND(hook_command, cplt_templates)[0] + 2);
+ if (!hook_command
+ || ((HOOK_COMMAND(hook_command, cplt_templates)[0][0] == '%')
+ && (HOOK_COMMAND(hook_command, cplt_templates)[0][1] == '%')))
+ {
+ return strdup ("");
+ }
+ }
+
/* if only one template available, then use it */
if (HOOK_COMMAND(hook_command, cplt_num_templates) == 1)
return strdup (HOOK_COMMAND(hook_command, cplt_templates)[0]);
@@ -1432,7 +1447,7 @@ gui_completion_build_list (struct t_gui_completion *completion)
repeat_last = 0;
- ptr_hook = gui_completion_search_command (completion);
+ ptr_hook = gui_completion_search_command (completion->base_command);
if (!ptr_hook || !HOOK_COMMAND(ptr_hook, completion)
|| (strcmp (HOOK_COMMAND(ptr_hook, completion), "-") == 0))
{