diff --git a/src/plugins/trigger/trigger-command.c b/src/plugins/trigger/trigger-command.c index eaa16d1de..33f3dc5aa 100644 --- a/src/plugins/trigger/trigger-command.c +++ b/src/plugins/trigger/trigger-command.c @@ -21,6 +21,7 @@ #include #include +#include #include "../weechat-plugin.h" #include "trigger.h" @@ -38,6 +39,7 @@ trigger_command_trigger (void *data, struct t_gui_buffer *buffer, int argc, { struct t_trigger *ptr_trigger; const char *option; + char *name; int i, type, count, index_option, enabled; /* make C compiler happy */ @@ -176,7 +178,7 @@ trigger_command_trigger (void *data, struct t_gui_buffer *buffer, int argc, } if (weechat_strcasecmp (argv[3], "name") == 0) { - if (!trigger_rename (ptr_trigger, argv_eol[4])) + if (!trigger_rename (ptr_trigger, argv[4])) return WEECHAT_RC_OK; } else @@ -197,6 +199,39 @@ trigger_command_trigger (void *data, struct t_gui_buffer *buffer, int argc, return WEECHAT_RC_OK; } + /* rename a trigger */ + if (weechat_strcasecmp (argv[1], "rename") == 0) + { + if (argc < 4) + { + weechat_printf_tags (NULL, "no_trigger", + _("%sError: missing arguments for \"%s\" " + "command"), + weechat_prefix ("error"), "trigger"); + return WEECHAT_RC_OK; + } + ptr_trigger = trigger_search (argv[2]); + if (!ptr_trigger) + { + weechat_printf_tags (NULL, "no_trigger", + _("%sTrigger \"%s\" not found"), + weechat_prefix ("error"), argv[2]); + return WEECHAT_RC_OK; + } + name = strdup (ptr_trigger->name); + if (name) + { + if (trigger_rename (ptr_trigger, argv[3])) + { + weechat_printf_tags (NULL, "no_trigger", + _("Trigger \"%s\" renamed to \"%s\""), + name, ptr_trigger->name); + } + free (name); + } + return WEECHAT_RC_OK; + } + /* delete a trigger */ if (weechat_strcasecmp (argv[1], "del") == 0) { @@ -301,6 +336,7 @@ trigger_command_init () N_("list" " || add []" " || set