diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2020-04-12 09:30:56 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2020-04-12 09:30:56 +0200 |
commit | 8bdd540df72c3a609e9d51a5c52cf2d65f96d79b (patch) | |
tree | f448d1bcda0cdb4769dd87abaa42c5cf06407ced /src | |
parent | c9329f6fb1805da4c18cdcb1d4da3077bd434ed9 (diff) | |
download | weechat-8bdd540df72c3a609e9d51a5c52cf2d65f96d79b.zip |
trigger: evaluate arguments of command when the trigger is created (closes #1472)
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/trigger/trigger-command.c | 3 | ||||
-rw-r--r-- | src/plugins/trigger/trigger.c | 25 |
2 files changed, 23 insertions, 5 deletions
diff --git a/src/plugins/trigger/trigger-command.c b/src/plugins/trigger/trigger-command.c index 2d2793c0d..112417c90 100644 --- a/src/plugins/trigger/trigger-command.c +++ b/src/plugins/trigger/trigger-command.c @@ -1170,7 +1170,8 @@ trigger_command_init () "list of buffer masks, tags\n" " print: buffer, tags, message, strip colors\n" " command: command (required), description, arguments, " - "description of arguments, completion\n" + "description of arguments, completion (all arguments except command " + "are evaluated, see /help eval)\n" " command_run: command(s) (required)\n" " timer: interval (required), align on second, max calls\n" " config: name(s) of option (required)\n" diff --git a/src/plugins/trigger/trigger.c b/src/plugins/trigger/trigger.c index b1364c294..7a6efb381 100644 --- a/src/plugins/trigger/trigger.c +++ b/src/plugins/trigger/trigger.c @@ -265,6 +265,7 @@ trigger_hook (struct t_trigger *trigger) { char **argv, **argv_eol, *buffer_type, *buffer_name, *tags, *message; char *error1, *error2, *error3; + char *eval_desc, *eval_args, *eval_desc_args, *eval_completion; int i, argc, strip_colors; long interval, align_second, max_calls; @@ -400,14 +401,30 @@ trigger_hook (struct t_trigger *trigger) if (trigger->hooks) { trigger->hooks_count = 1; + eval_desc = (argc > 1) ? weechat_string_eval_expression ( + argv[1], NULL, NULL, NULL) : NULL; + eval_args = (argc > 2) ? weechat_string_eval_expression ( + argv[2], NULL, NULL, NULL) : NULL; + eval_desc_args = (argc > 3) ? weechat_string_eval_expression ( + argv[3], NULL, NULL, NULL) : NULL; + eval_completion = (argc > 4) ? weechat_string_eval_expression ( + argv[4], NULL, NULL, NULL) : NULL; trigger->hooks[0] = weechat_hook_command ( argv[0], /* command */ - (argc > 1) ? argv[1] : "", /* description */ - (argc > 2) ? argv[2] : "", /* arguments */ - (argc > 3) ? argv[3] : "", /* description of args */ - (argc > 4) ? argv[4] : "", /* completion */ + (eval_desc) ? eval_desc : "", + (eval_args) ? eval_args : "", + (eval_desc_args) ? eval_desc_args : "", + (eval_completion) ? eval_completion : "", &trigger_callback_command_cb, trigger, NULL); + if (eval_desc) + free (eval_desc); + if (eval_args) + free (eval_args); + if (eval_desc_args) + free (eval_desc_args); + if (eval_completion) + free (eval_completion); } } break; |