mirror of
https://github.com/weechat/weechat.git
synced 2026-06-30 14:56:39 +02:00
alias: add option rename in command /alias (issue #1872)
This commit is contained in:
@@ -80,8 +80,8 @@ alias_command_cb (const void *pointer, void *data,
|
||||
struct t_gui_buffer *buffer, int argc,
|
||||
char **argv, char **argv_eol)
|
||||
{
|
||||
char *ptr_alias_name;
|
||||
struct t_alias *ptr_alias;
|
||||
char *ptr_alias_name, *ptr_alias_name2;
|
||||
struct t_alias *ptr_alias, *ptr_alias2;
|
||||
struct t_config_option *ptr_option;
|
||||
int alias_found, i;
|
||||
|
||||
@@ -235,6 +235,48 @@ alias_command_cb (const void *pointer, void *data,
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
if (weechat_strcmp (argv[1], "rename") == 0)
|
||||
{
|
||||
WEECHAT_COMMAND_MIN_ARGS(4, "rename");
|
||||
|
||||
ptr_alias_name = (weechat_string_is_command_char (argv[2])) ?
|
||||
(char *)weechat_utf8_next_char (argv[2]) : argv[2];
|
||||
ptr_alias_name2 = (weechat_string_is_command_char (argv[3])) ?
|
||||
(char *)weechat_utf8_next_char (argv[3]) : argv[3];
|
||||
|
||||
ptr_alias = alias_search (ptr_alias_name);
|
||||
if (!ptr_alias)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
_("%sAlias \"%s\" not found"),
|
||||
weechat_prefix ("error"),
|
||||
ptr_alias_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* check if target name already exists */
|
||||
ptr_alias2 = alias_search (ptr_alias_name2);
|
||||
if (ptr_alias2)
|
||||
{
|
||||
weechat_printf (NULL, _("%sAlias \"%s\" already exists"),
|
||||
weechat_prefix ("error"), ptr_alias_name2);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* rename alias */
|
||||
if (alias_rename (ptr_alias, ptr_alias_name2))
|
||||
{
|
||||
weechat_printf (
|
||||
NULL,
|
||||
_("Alias \"%s\" has been renamed to \"%s\""),
|
||||
ptr_alias_name,
|
||||
ptr_alias_name2);
|
||||
}
|
||||
}
|
||||
}
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
WEECHAT_COMMAND_ERROR;
|
||||
}
|
||||
|
||||
@@ -251,13 +293,15 @@ alias_command_init ()
|
||||
N_("list [<alias>]"
|
||||
" || add <alias> [<command>[;<command>...]]"
|
||||
" || addcompletion <completion> <alias> [<command>[;<command>...]]"
|
||||
" || del <alias> [<alias>...]"),
|
||||
" || del <alias> [<alias>...]"
|
||||
" || rename <alias> <new_alias>"),
|
||||
/* xgettext:no-c-format */
|
||||
N_(" list: list aliases (without argument, this list is "
|
||||
"displayed)\n"
|
||||
" add: add an alias\n"
|
||||
"addcompletion: add an alias with a custom completion\n"
|
||||
" del: delete an alias\n"
|
||||
" rename: rename an alias\n"
|
||||
" completion: completion for alias: by default completion is "
|
||||
"done with target command\n"
|
||||
" note: you can use %%command to use completion of "
|
||||
@@ -283,12 +327,15 @@ alias_command_init ()
|
||||
" alias /hello to say \"hello\" on all channels but not on "
|
||||
"#weechat:\n"
|
||||
" /alias add hello /allchan -exclude=#weechat hello\n"
|
||||
" rename alias \"hello\" to \"Hello\":\n"
|
||||
" /alias rename hello Hello\n"
|
||||
" alias /forcejoin to send IRC command \"forcejoin\" with "
|
||||
"completion of /sajoin:\n"
|
||||
" /alias addcompletion %%sajoin forcejoin /quote forcejoin"),
|
||||
"list %(alias)"
|
||||
" || add %(alias) %(commands:/)|%(alias_value)"
|
||||
" || addcompletion %- %(alias) %(commands:/)|%(alias_value)"
|
||||
" || del %(alias)|%*",
|
||||
" || del %(alias)|%*"
|
||||
" || rename %(alias) %(alias)",
|
||||
&alias_command_cb, NULL, NULL);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user