1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-03 16:23:14 +02:00

alias: add default alias "msgbuf" (send text to a buffer)

This commit is contained in:
Sébastien Helleu
2014-05-13 23:01:11 +02:00
parent d38d961394
commit 75247edfb3
2 changed files with 72 additions and 38 deletions
+1
View File
@@ -100,6 +100,7 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
* api: add functions "hashtable_dup", "string_replace_regex",
"string_split_shell", "string_convert_escaped_chars"
* api: add integer return code for functions hook_{signal|hsignal}_send
* alias: add default alias "msgbuf" (send text to a buffer)
* alias: change default command for alias /beep to "/print -beep"
* exec: add exec plugin: new command /exec and file exec.conf
* guile: fix module used after unload of a script
+71 -38
View File
@@ -31,42 +31,47 @@ struct t_config_file *alias_config_file = NULL;
struct t_config_section *alias_config_section_cmd = NULL;
struct t_config_section *alias_config_section_completion = NULL;
char *alias_default_list[][2] =
{ { "AAWAY", "allserv /away" },
{ "AME", "allchan /me" },
{ "AMSG", "allchan /msg *" },
{ "ANICK", "allserv /nick" },
{ "BEEP", "print -beep" },
{ "BYE", "quit" },
{ "C", "buffer clear" },
{ "CL", "buffer clear" },
{ "CLOSE", "buffer close" },
{ "CHAT", "dcc chat" },
{ "EXIT", "quit" },
{ "IG", "ignore" },
{ "J", "join" },
{ "K", "kick" },
{ "KB", "kickban" },
{ "LEAVE", "part" },
{ "M", "msg" },
{ "MUB", "unban *" },
{ "N", "names" },
{ "Q", "query" },
{ "REDRAW", "window refresh" },
{ "SAY", "msg *" },
{ "SIGNOFF", "quit" },
{ "T", "topic" },
{ "UB", "unban" },
{ "UMODE", "mode $nick" },
{ "V", "command core version" },
{ "W", "who" },
{ "WC", "window merge" },
{ "WI", "whois" },
{ "WII", "whois $1 $1" },
{ "WW", "whowas" },
{ NULL, NULL },
char *alias_default_cmd[][2] =
{ { "AAWAY", "allserv /away" },
{ "AME", "allchan /me" },
{ "AMSG", "allchan /msg *" },
{ "ANICK", "allserv /nick" },
{ "BEEP", "print -beep" },
{ "BYE", "quit" },
{ "C", "buffer clear" },
{ "CL", "buffer clear" },
{ "CLOSE", "buffer close" },
{ "CHAT", "dcc chat" },
{ "EXIT", "quit" },
{ "IG", "ignore" },
{ "J", "join" },
{ "K", "kick" },
{ "KB", "kickban" },
{ "LEAVE", "part" },
{ "M", "msg" },
{ "MUB", "unban *" },
{ "MSGBUF", "command -buffer $1 * /input send $2-" },
{ "N", "names" },
{ "Q", "query" },
{ "REDRAW", "window refresh" },
{ "SAY", "msg *" },
{ "SIGNOFF", "quit" },
{ "T", "topic" },
{ "UB", "unban" },
{ "UMODE", "mode $nick" },
{ "V", "command core version" },
{ "W", "who" },
{ "WC", "window merge" },
{ "WI", "whois" },
{ "WII", "whois $1 $1" },
{ "WW", "whowas" },
{ NULL, NULL },
};
char *alias_default_completion[][2] =
{ { "MSGBUF", "%(buffers_plugins_names)" },
{ NULL, NULL },
};
/*
* Callback for changes on options in section "cmd" (command).
@@ -188,11 +193,11 @@ alias_config_cmd_write_default_cb (void *data,
if (!weechat_config_write_line (config_file, section_name, NULL))
return WEECHAT_CONFIG_WRITE_ERROR;
for (i = 0; alias_default_list[i][0]; i++)
for (i = 0; alias_default_cmd[i][0]; i++)
{
if (!weechat_config_write_line (config_file,
alias_default_list[i][0],
"\"%s\"", alias_default_list[i][1]))
alias_default_cmd[i][0],
"\"%s\"", alias_default_cmd[i][1]))
return WEECHAT_CONFIG_WRITE_ERROR;
}
@@ -256,6 +261,34 @@ alias_config_cmd_create_option_cb (void *data,
return rc;
}
/*
* Writes default completions in configuration file in section "completion".
*/
int
alias_config_completion_write_default_cb (void *data,
struct t_config_file *config_file,
const char *section_name)
{
int i;
/* make C compiler happy */
(void) data;
if (!weechat_config_write_line (config_file, section_name, NULL))
return WEECHAT_CONFIG_WRITE_ERROR;
for (i = 0; alias_default_completion[i][0]; i++)
{
if (!weechat_config_write_line (config_file,
alias_default_completion[i][0],
"\"%s\"", alias_default_completion[i][1]))
return WEECHAT_CONFIG_WRITE_ERROR;
}
return WEECHAT_CONFIG_WRITE_OK;
}
/*
* Creates a new option in section "completion".
*/
@@ -348,7 +381,7 @@ alias_config_init ()
1, 1,
NULL, NULL,
NULL, NULL,
NULL, NULL,
&alias_config_completion_write_default_cb, NULL,
&alias_config_completion_create_option_cb, NULL,
NULL, NULL);
if (!ptr_section)