1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-30 23:06:38 +02:00

Added completion hook, to let plugins add custom completions for commands

This commit is contained in:
Sebastien Helleu
2007-12-07 15:01:37 +01:00
parent 495e6bd5df
commit 72a694ed4c
9 changed files with 230 additions and 23 deletions
+28 -1
View File
@@ -43,6 +43,7 @@ struct t_alias *last_alias = NULL;
struct t_hook *alias_command = NULL;
struct t_hook *unalias_command = NULL;
struct t_hook *config_reload = NULL;
struct t_hook *completion = NULL;
/*
@@ -690,6 +691,28 @@ unalias_command_cb (void *data, void *buffer, int argc, char **argv,
return 0;
}
/*
* alias_completion_cb: callback for completion
*/
int
alias_completion_cb (void *data, char *completion, void *list)
{
struct t_alias *ptr_alias;
/* make C compiler happy */
(void) data;
(void) completion;
for (ptr_alias = alias_list; ptr_alias;
ptr_alias = ptr_alias->next_alias)
{
weechat_list_add (list, ptr_alias->name, "sort");
}
return PLUGIN_RC_SUCCESS;
}
/*
* weechat_plugin_init: initialize alias plugin
*/
@@ -734,12 +757,15 @@ weechat_plugin_init (struct t_weechat_plugin *plugin)
N_("alias_name"),
N_("alias_name: name of alias to "
"remove"),
"%h",
"%(alias)",
unalias_command_cb, NULL);
config_reload = weechat_hook_event ("config_reload",
alias_config_reload_event_cb, NULL);
completion = weechat_hook_completion ("alias",
alias_completion_cb, NULL);
return PLUGIN_RC_SUCCESS;
}
@@ -756,6 +782,7 @@ weechat_plugin_end ()
weechat_unhook (alias_command);
weechat_unhook (unalias_command);
weechat_unhook (config_reload);
weechat_unhook (completion);
return PLUGIN_RC_SUCCESS;
}