diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2014-02-14 15:15:21 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2014-02-14 15:15:21 +0100 |
commit | f52770137f066fccbffe1fd833e2bf7ed2432800 (patch) | |
tree | ca6d3819cd302bbbcae13d292d1814299a3c90fd /src/plugins | |
parent | e782020b140f2aa5a5e33dffcdff0a05a713d35d (diff) | |
download | weechat-f52770137f066fccbffe1fd833e2bf7ed2432800.zip |
trigger: add option "recreate" in command /trigger
The "recreate" option is the same as "input" but the trigger is first
deleted. So this lets you recreate the same trigger and edit some things
if needed.
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/trigger/trigger-command.c | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/src/plugins/trigger/trigger-command.c b/src/plugins/trigger/trigger-command.c index b951e3f13..6addfbcfb 100644 --- a/src/plugins/trigger/trigger-command.c +++ b/src/plugins/trigger/trigger-command.c @@ -532,9 +532,15 @@ trigger_command_trigger (void *data, struct t_gui_buffer *buffer, int argc, goto end; } - /* get command to create a trigger (in input or send it to buffer) */ + /* + * get command to create a trigger, and according to option: + * - input: put the command in input + * - output: send the command to the buffer + * - recreate: same as input, but the trigger is first deleted + */ if ((weechat_strcasecmp (argv[1], "input") == 0) - || (weechat_strcasecmp (argv[1], "output") == 0)) + || (weechat_strcasecmp (argv[1], "output") == 0) + || (weechat_strcasecmp (argv[1], "recreate") == 0)) { if (argc < 3) { @@ -561,17 +567,23 @@ trigger_command_trigger (void *data, struct t_gui_buffer *buffer, int argc, weechat_config_string (ptr_trigger->options[TRIGGER_OPTION_REGEX]), weechat_config_string (ptr_trigger->options[TRIGGER_OPTION_COMMAND]), weechat_config_string (ptr_trigger->options[TRIGGER_OPTION_RETURN_CODE])); - if (weechat_strcasecmp (argv[1], "input") == 0) + if (weechat_strcasecmp (argv[1], "recreate") == 0) + { + trigger_free (ptr_trigger); + weechat_printf_tags (NULL, "no_trigger", + _("Trigger \"%s\" removed"), argv[2]); + } + if (weechat_strcasecmp (argv[1], "output") == 0) + { + weechat_command (buffer, input); + } + else { weechat_buffer_set (buffer, "input", input + 1); snprintf (str_pos, sizeof (str_pos), "%d", weechat_utf8_strlen (input + 1)); weechat_buffer_set (buffer, "input_pos", str_pos); } - else - { - weechat_command (buffer, input); - } goto end; } @@ -860,7 +872,7 @@ trigger_command_init () " || add <name> <hook> [\"<arguments>\" [\"<conditions>\" " "[\"<regex>\" [\"<command>\" [\"<return_code>\"]]]]]" " || addinput [<hook>]" - " || input|output <name>" + " || input|output|recreate <name>" " || set <name> <option> <value>" " || rename|copy <name> <new_name>" " || enable|disable|toggle|restart <name>|-all [<name>...]" @@ -897,6 +909,7 @@ trigger_command_init () " addinput: set input with default arguments to create a trigger\n" " input: set input with the command used to create the trigger\n" " output: send the command to create the trigger on the buffer\n" + " recreate: same as input, but the trigger is first deleted\n" " set: set an option in a trigger\n" " option: name of option: name, hook, arguments, conditions, " "regex, command, return_code\n" @@ -949,7 +962,7 @@ trigger_command_init () "%(trigger_hook_conditions) %(trigger_hook_regex) " "%(trigger_hook_command) %(trigger_hook_rc)" " || addinput %(trigger_hooks)" - " || input|output %(trigger_names)" + " || input|output|recreate %(trigger_names)" " || set %(trigger_names) %(trigger_options)|name %(trigger_option_value)" " || rename|copy %(trigger_names) %(trigger_names)" " || enable|disable|toggle|restart|del %(trigger_names)|-all " |