diff options
-rw-r--r-- | ChangeLog.adoc | 1 | ||||
-rw-r--r-- | doc/de/autogen/plugin_api/infolists.adoc | 2 | ||||
-rw-r--r-- | doc/en/autogen/plugin_api/infolists.adoc | 2 | ||||
-rw-r--r-- | doc/fr/autogen/plugin_api/infolists.adoc | 2 | ||||
-rw-r--r-- | doc/it/autogen/plugin_api/infolists.adoc | 2 | ||||
-rw-r--r-- | doc/ja/autogen/plugin_api/infolists.adoc | 2 | ||||
-rw-r--r-- | doc/pl/autogen/plugin_api/infolists.adoc | 2 | ||||
-rw-r--r-- | src/plugins/alias/alias-config.c | 95 | ||||
-rw-r--r-- | src/plugins/alias/alias-config.h | 2 | ||||
-rw-r--r-- | src/plugins/alias/alias-info.c | 59 |
10 files changed, 120 insertions, 49 deletions
diff --git a/ChangeLog.adoc b/ChangeLog.adoc index dadedaa4b..c2e1c211e 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -21,6 +21,7 @@ https://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes] New features:: * core: support loading of plugins from path in environment variable "WEECHAT_EXTRA_LIBDIR" (issue #971, issue #979) + * alias: add infolist "alias_default" (list of default aliases) * buflist: add option buflist.look.add_newline (issue #1027) * fset: new plugin "fset" (fast set of WeeChat and plugins options) diff --git a/doc/de/autogen/plugin_api/infolists.adoc b/doc/de/autogen/plugin_api/infolists.adoc index c73ba4efc..d6601e111 100644 --- a/doc/de/autogen/plugin_api/infolists.adoc +++ b/doc/de/autogen/plugin_api/infolists.adoc @@ -8,6 +8,8 @@ | alias | alias | Liste der Alias | Alias Pointer (optional) | Name des Alias (Platzhalter "*" kann verwendet werden) (optional) +| alias | alias_default | list of default aliases | - | - + | fset | fset_option | Auflistung der fset Optionen | fset Option-Pointer (optional) | Name einer Einstellung (Platzhalter "*" kann verwendet werden) (optional) | guile | guile_script | Liste der Skripten | Skript Pointer (optional) | Name des Skriptes (Platzhalter "*" kann verwendet werden) (optional) diff --git a/doc/en/autogen/plugin_api/infolists.adoc b/doc/en/autogen/plugin_api/infolists.adoc index 972063964..f9810b2bd 100644 --- a/doc/en/autogen/plugin_api/infolists.adoc +++ b/doc/en/autogen/plugin_api/infolists.adoc @@ -8,6 +8,8 @@ | alias | alias | list of aliases | alias pointer (optional) | alias name (wildcard "*" is allowed) (optional) +| alias | alias_default | list of default aliases | - | - + | fset | fset_option | list of fset options | fset option pointer (optional) | option name (wildcard "*" is allowed) (optional) | guile | guile_script | list of scripts | script pointer (optional) | script name (wildcard "*" is allowed) (optional) diff --git a/doc/fr/autogen/plugin_api/infolists.adoc b/doc/fr/autogen/plugin_api/infolists.adoc index 11e040fd7..bb88aaad1 100644 --- a/doc/fr/autogen/plugin_api/infolists.adoc +++ b/doc/fr/autogen/plugin_api/infolists.adoc @@ -8,6 +8,8 @@ | alias | alias | liste des alias | pointeur vers l'alias (optionnel) | nom d'alias (le caractère joker "*" est autorisé) (optionnel) +| alias | alias_default | liste des alias par défaut | - | - + | fset | fset_option | liste des options fset | pointeur vers l'option fset (optionnel) | nom d'option (le caractère joker "*" est autorisé) (optionnel) | guile | guile_script | liste des scripts | pointeur vers le script (optionnel) | nom de script (le caractère joker "*" est autorisé) (optionnel) diff --git a/doc/it/autogen/plugin_api/infolists.adoc b/doc/it/autogen/plugin_api/infolists.adoc index 8cd5ff8b0..a3b0f3a97 100644 --- a/doc/it/autogen/plugin_api/infolists.adoc +++ b/doc/it/autogen/plugin_api/infolists.adoc @@ -8,6 +8,8 @@ | alias | alias | elenco di alias | puntatore all'alias (opzionale) | alias name (wildcard "*" is allowed) (optional) +| alias | alias_default | list of default aliases | - | - + | fset | fset_option | list of fset options | fset option pointer (optional) | option name (wildcard "*" is allowed) (optional) | guile | guile_script | elenco degli script | puntatore allo script (opzionale) | script name (wildcard "*" is allowed) (optional) diff --git a/doc/ja/autogen/plugin_api/infolists.adoc b/doc/ja/autogen/plugin_api/infolists.adoc index aec4b6409..504fd8416 100644 --- a/doc/ja/autogen/plugin_api/infolists.adoc +++ b/doc/ja/autogen/plugin_api/infolists.adoc @@ -8,6 +8,8 @@ | alias | alias | 別名のリスト | 別名のポインタ (任意) | 別名の名前 (ワイルドカード "*" を使うことができます) (任意) +| alias | alias_default | list of default aliases | - | - + | fset | fset_option | fset オプションのリスト | fset オプションポインタ (任意) | オプション名 (ワイルドカード "*" を使うことができます) (任意) | guile | guile_script | スクリプトのリスト | スクリプトポインタ (任意) | スクリプト名 (ワイルドカード "*" を使うことができます) (任意) diff --git a/doc/pl/autogen/plugin_api/infolists.adoc b/doc/pl/autogen/plugin_api/infolists.adoc index bc2a4a218..49154501e 100644 --- a/doc/pl/autogen/plugin_api/infolists.adoc +++ b/doc/pl/autogen/plugin_api/infolists.adoc @@ -8,6 +8,8 @@ | alias | alias | lista aliasów | wskaźnik aliasu (opcjonalny) | nazwa aliasu (wildcard "*" jest dozwolony) (opcjonalne) +| alias | alias_default | list of default aliases | - | - + | fset | fset_option | list of fset options | fset option pointer (optional) | nazwa opcji (wildcard "*" jest dozwolony) (opcjonalne) | guile | guile_script | lista skryptów | wskaźnik skryptu (opcjonalne) | nazwa skryptu (wildcard "*" jest dozwolony) (opcjonalne) diff --git a/src/plugins/alias/alias-config.c b/src/plugins/alias/alias-config.c index b0f963d23..c5ba01c5b 100644 --- a/src/plugins/alias/alias-config.c +++ b/src/plugins/alias/alias-config.c @@ -31,46 +31,42 @@ 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_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 }, +char *alias_default[][3] = +{ { "AAWAY", "allserv /away", NULL }, + { "AME", "allchan /me", NULL }, + { "AMSG", "allchan /msg *", NULL }, + { "ANICK", "allserv /nick", NULL }, + { "BEEP", "print -beep", NULL }, + { "BYE", "quit", NULL }, + { "C", "buffer clear", NULL }, + { "CL", "buffer clear", NULL }, + { "CLOSE", "buffer close", NULL }, + { "CHAT", "dcc chat", NULL }, + { "EXIT", "quit", NULL }, + { "IG", "ignore", NULL }, + { "J", "join", NULL }, + { "K", "kick", NULL }, + { "KB", "kickban", NULL }, + { "LEAVE", "part", NULL }, + { "M", "msg", NULL }, + { "MUB", "unban *", NULL }, + { "MSGBUF", "command -buffer $1 * /input send $2-", + "%(buffers_plugins_names)" }, + { "N", "names", NULL }, + { "Q", "query", NULL }, + { "REDRAW", "window refresh", NULL }, + { "SAY", "msg *", NULL }, + { "SIGNOFF", "quit", NULL }, + { "T", "topic", NULL }, + { "UB", "unban", NULL }, + { "UMODE", "mode $nick", NULL }, + { "V", "command core version", NULL }, + { "W", "who", NULL }, + { "WC", "window merge", NULL }, + { "WI", "whois", NULL }, + { "WII", "whois $1 $1", NULL }, + { "WW", "whowas", NULL }, + { NULL, NULL, NULL }, }; /* @@ -204,11 +200,11 @@ alias_config_cmd_write_default_cb (const void *pointer, void *data, if (!weechat_config_write_line (config_file, section_name, NULL)) return WEECHAT_CONFIG_WRITE_ERROR; - for (i = 0; alias_default_cmd[i][0]; i++) + for (i = 0; alias_default[i][0]; i++) { if (!weechat_config_write_line (config_file, - alias_default_cmd[i][0], - "\"%s\"", alias_default_cmd[i][1])) + alias_default[i][0], + "\"%s\"", alias_default[i][1])) return WEECHAT_CONFIG_WRITE_ERROR; } @@ -291,12 +287,15 @@ alias_config_completion_write_default_cb (const void *pointer, 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++) + for (i = 0; alias_default[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; + if (alias_default[i][2]) + { + if (!weechat_config_write_line (config_file, + alias_default[i][0], + "\"%s\"", alias_default[i][2])) + return WEECHAT_CONFIG_WRITE_ERROR; + } } return WEECHAT_CONFIG_WRITE_OK; diff --git a/src/plugins/alias/alias-config.h b/src/plugins/alias/alias-config.h index a609a65ea..411680f6a 100644 --- a/src/plugins/alias/alias-config.h +++ b/src/plugins/alias/alias-config.h @@ -24,6 +24,8 @@ extern struct t_config_file *alias_config_file; extern struct t_config_section *alias_config_section_cmd; extern struct t_config_section *alias_config_section_completion; +extern char *alias_default[][3]; + extern void alias_config_cmd_new_option (const char *name, const char *command); extern void alias_config_completion_new_option (const char *name, diff --git a/src/plugins/alias/alias-info.c b/src/plugins/alias/alias-info.c index 45b7a52dc..dca1c9822 100644 --- a/src/plugins/alias/alias-info.c +++ b/src/plugins/alias/alias-info.c @@ -23,10 +23,11 @@ #include "../weechat-plugin.h" #include "alias.h" +#include "alias-config.h" /* - * Returns alias infolist "alias". + * Returns infolist "alias". */ struct t_infolist * @@ -82,6 +83,58 @@ alias_info_infolist_alias_cb (const void *pointer, void *data, } /* + * Returns infolist "alias_default". + */ + +struct t_infolist * +alias_info_infolist_alias_default_cb (const void *pointer, void *data, + const char *infolist_name, + void *obj_pointer, const char *arguments) +{ + struct t_infolist *ptr_infolist; + struct t_infolist_item *ptr_item; + int i; + + /* make C compiler happy */ + (void) pointer; + (void) data; + (void) infolist_name; + (void) obj_pointer; + (void) arguments; + + ptr_infolist = weechat_infolist_new (); + if (!ptr_infolist) + return NULL; + + for (i = 0; alias_default[i][0]; i++) + { + ptr_item = weechat_infolist_new_item (ptr_infolist); + if (!ptr_item) + { + weechat_infolist_free (ptr_infolist); + return NULL; + } + if (!weechat_infolist_new_var_string (ptr_item, "name", alias_default[i][0])) + { + weechat_infolist_free (ptr_infolist); + return NULL; + } + if (!weechat_infolist_new_var_string (ptr_item, "command", alias_default[i][1])) + { + weechat_infolist_free (ptr_infolist); + return NULL; + } + if (!weechat_infolist_new_var_string (ptr_item, "completion", alias_default[i][2])) + { + weechat_infolist_free (ptr_infolist); + return NULL; + } + } + + return ptr_infolist; +} + +/* * Hooks infolist for alias plugin. */ @@ -93,4 +146,8 @@ alias_info_init () N_("alias pointer (optional)"), N_("alias name (wildcard \"*\" is allowed) (optional)"), &alias_info_infolist_alias_cb, NULL, NULL); + weechat_hook_infolist ( + "alias_default", N_("list of default aliases"), + NULL, NULL, + &alias_info_infolist_alias_default_cb, NULL, NULL); } |