summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog.adoc1
-rw-r--r--src/plugins/trigger/trigger-command.c5
-rw-r--r--src/plugins/trigger/trigger-completion.c76
3 files changed, 78 insertions, 4 deletions
diff --git a/ChangeLog.adoc b/ChangeLog.adoc
index bf1b8e04b..5c54698b9 100644
--- a/ChangeLog.adoc
+++ b/ChangeLog.adoc
@@ -35,6 +35,7 @@ Bug fixes::
* irc: fix add of channel to autojoin option when joining a channel with a buffer still opened
* relay: fix save of channels in autojoin option when JOIN and PART commands are received from an IRC relay client (issue #1771)
* trigger: add `${buffer.notify} > 0` in conditions of default trigger "beep"
+ * trigger: fix completion of command `/trigger add` when there are spaces in the following arguments
* trigger: fix memory leak in command `/trigger addinput`
[[v3.5]]
diff --git a/src/plugins/trigger/trigger-command.c b/src/plugins/trigger/trigger-command.c
index 7c83d58b4..5c6fac3b4 100644
--- a/src/plugins/trigger/trigger-command.c
+++ b/src/plugins/trigger/trigger-command.c
@@ -1271,10 +1271,7 @@ trigger_command_init ()
"name starts with \"resize\":\n"
" /trigger monitor @modifier,resize*"),
"list|listfull|listdefault"
- " || add|addoff|addreplace %(trigger_names) %(trigger_hooks) "
- "%(trigger_hook_arguments) %(trigger_hook_conditions) "
- "%(trigger_hook_regex) %(trigger_hook_command) %(trigger_hook_rc) "
- "%(trigger_post_action)"
+ " || add|addoff|addreplace %(trigger_add_arguments)|%*"
" || addinput %(trigger_hooks)"
" || input|output|recreate %(trigger_names)"
" || set %(trigger_names) %(trigger_options)|name %(trigger_option_value)"
diff --git a/src/plugins/trigger/trigger-completion.c b/src/plugins/trigger/trigger-completion.c
index f85542064..17ab2284f 100644
--- a/src/plugins/trigger/trigger-completion.c
+++ b/src/plugins/trigger/trigger-completion.c
@@ -471,6 +471,76 @@ trigger_completion_post_action_cb (const void *pointer, void *data,
return WEECHAT_RC_OK;
}
+/*
+ * Adds arguments for commands that add a trigger.
+ */
+
+int
+trigger_completion_add_arguments_cb (const void *pointer, void *data,
+ const char *completion_item,
+ struct t_gui_buffer *buffer,
+ struct t_gui_completion *completion)
+{
+ const char *args, *base_word;
+ char **sargv;
+ int sargc, arg_complete;
+
+ args = weechat_completion_get_string (completion, "args");
+ if (!args)
+ return WEECHAT_RC_OK;
+
+ base_word = weechat_completion_get_string (completion, "base_word");
+
+ sargv = weechat_string_split_shell (args, &sargc);
+ if (!sargv)
+ return WEECHAT_RC_OK;
+
+ arg_complete = sargc;
+ if (base_word && base_word[0])
+ arg_complete--;
+
+ switch (arg_complete)
+ {
+ case 1:
+ trigger_completion_triggers_cb (pointer, data, completion_item,
+ buffer, completion);
+ break;
+ case 2:
+ trigger_completion_hooks_cb (pointer, data, completion_item,
+ buffer, completion);
+ break;
+ case 3:
+ trigger_completion_hook_arguments_cb (pointer, data,
+ completion_item, buffer,
+ completion);
+ break;
+ case 4:
+ trigger_completion_hook_conditions_cb (pointer, data,
+ completion_item, buffer,
+ completion);
+ break;
+ case 5:
+ trigger_completion_hook_regex_cb (pointer, data, completion_item,
+ buffer, completion);
+ break;
+ case 6:
+ trigger_completion_hook_command_cb (pointer, data, completion_item,
+ buffer, completion);
+ break;
+ case 7:
+ trigger_completion_hook_rc_cb (pointer, data, completion_item,
+ buffer, completion);
+ break;
+ case 8:
+ trigger_completion_post_action_cb (pointer, data, completion_item,
+ buffer, completion);
+ break;
+ }
+
+ weechat_string_free_split (sargv);
+
+ return WEECHAT_RC_OK;
+}
/*
* Hooks completions.
@@ -515,4 +585,10 @@ trigger_completion_init ()
weechat_hook_completion ("trigger_post_action",
N_("trigger post actions"),
&trigger_completion_post_action_cb, NULL, NULL);
+ weechat_hook_completion ("trigger_add_arguments",
+ N_("arguments for command that adds a trigger: "
+ "trigger name, hooks, hook arguments, "
+ "hook conditions, hook regex, hook command, "
+ "hook return code, post actions"),
+ &trigger_completion_add_arguments_cb, NULL, NULL);
}