From 70ffe0a14f286c9d258def51b2da7d1999bc9f83 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Tue, 14 Jan 2014 13:27:43 +0100 Subject: [PATCH] core: add completion "plugins_installed" --- ChangeLog | 1 + doc/de/autogen/plugin_api/completions.txt | 2 + doc/en/autogen/plugin_api/completions.txt | 2 + doc/fr/autogen/plugin_api/completions.txt | 2 + doc/it/autogen/plugin_api/completions.txt | 2 + doc/ja/autogen/plugin_api/completions.txt | 2 + doc/pl/autogen/plugin_api/completions.txt | 2 + po/cs.po | 6 +- po/de.po | 6 +- po/es.po | 6 +- po/fr.po | 7 +- po/hu.po | 6 +- po/it.po | 6 +- po/ja.po | 6 +- po/pl.po | 6 +- po/pt_BR.po | 6 +- po/ru.po | 6 +- po/tr.po | 6 +- po/weechat.pot | 5 +- src/core/wee-command.c | 2 +- src/core/wee-completion.c | 90 +++++++++++++++++++++++ 21 files changed, 163 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8569fe7c4..b29ae1b27 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,6 +11,7 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes] == Version 0.4.3 (under dev) +* core: add completion "plugins_installed" * core: fix crash in /eval when config option has a NULL value * core: fix crash with hdata_update on shared strings, add hdata type "shared_string" (bug #41104) diff --git a/doc/de/autogen/plugin_api/completions.txt b/doc/de/autogen/plugin_api/completions.txt index 86844baba..6ab458f1e 100644 --- a/doc/de/autogen/plugin_api/completions.txt +++ b/doc/de/autogen/plugin_api/completions.txt @@ -116,6 +116,8 @@ | weechat | plugins_commands | Befehle, definiert durch Erweiterungen +| weechat | plugins_installed | names of plugins installed + | weechat | plugins_names | Liste der Erweiterungen | weechat | proxies_names | Namen aller Proxys diff --git a/doc/en/autogen/plugin_api/completions.txt b/doc/en/autogen/plugin_api/completions.txt index 9a91bcb8c..88ca39815 100644 --- a/doc/en/autogen/plugin_api/completions.txt +++ b/doc/en/autogen/plugin_api/completions.txt @@ -116,6 +116,8 @@ | weechat | plugins_commands | commands defined by plugins +| weechat | plugins_installed | names of plugins installed + | weechat | plugins_names | names of plugins | weechat | proxies_names | names of proxies diff --git a/doc/fr/autogen/plugin_api/completions.txt b/doc/fr/autogen/plugin_api/completions.txt index cd5b602d0..c7bee98fa 100644 --- a/doc/fr/autogen/plugin_api/completions.txt +++ b/doc/fr/autogen/plugin_api/completions.txt @@ -116,6 +116,8 @@ | weechat | plugins_commands | commandes définies par les extensions +| weechat | plugins_installed | noms des extensions installées + | weechat | plugins_names | noms des extensions | weechat | proxies_names | noms des proxies diff --git a/doc/it/autogen/plugin_api/completions.txt b/doc/it/autogen/plugin_api/completions.txt index 59314031e..6fee632fd 100644 --- a/doc/it/autogen/plugin_api/completions.txt +++ b/doc/it/autogen/plugin_api/completions.txt @@ -116,6 +116,8 @@ | weechat | plugins_commands | comandi definiti dai plugin +| weechat | plugins_installed | names of plugins installed + | weechat | plugins_names | nomi dei plugin | weechat | proxies_names | nomi dei proxy diff --git a/doc/ja/autogen/plugin_api/completions.txt b/doc/ja/autogen/plugin_api/completions.txt index 733d766ed..d0c7a745c 100644 --- a/doc/ja/autogen/plugin_api/completions.txt +++ b/doc/ja/autogen/plugin_api/completions.txt @@ -116,6 +116,8 @@ | weechat | plugins_commands | プラグインの定義するコマンド +| weechat | plugins_installed | names of plugins installed + | weechat | plugins_names | プラグイン名 | weechat | proxies_names | プロキシの名前 diff --git a/doc/pl/autogen/plugin_api/completions.txt b/doc/pl/autogen/plugin_api/completions.txt index fde2d6740..b5b101f15 100644 --- a/doc/pl/autogen/plugin_api/completions.txt +++ b/doc/pl/autogen/plugin_api/completions.txt @@ -116,6 +116,8 @@ | weechat | plugins_commands | komendy zdefiniowane przez wtyczki +| weechat | plugins_installed | names of plugins installed + | weechat | plugins_names | nazwy wtyczek | weechat | proxies_names | nazwy proxy diff --git a/po/cs.po b/po/cs.po index 89b6b7df3..b3ce57200 100644 --- a/po/cs.po +++ b/po/cs.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-01-13 15:40+0100\n" +"POT-Creation-Date: 2014-01-14 13:17+0100\n" "PO-Revision-Date: 2014-01-06 10:16+0100\n" "Last-Translator: Jiri Golembiovsky \n" "Language-Team: weechat-dev \n" @@ -2414,6 +2414,10 @@ msgstr "konfigurační nastavení" msgid "names of plugins" msgstr "jména pluginů" +#, fuzzy +msgid "names of plugins installed" +msgstr "jména pluginů" + msgid "commands defined by plugins" msgstr "příkazy definované pluginy" diff --git a/po/de.po b/po/de.po index 0cd6498f8..30d9d17c9 100644 --- a/po/de.po +++ b/po/de.po @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.4.3-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-01-13 15:40+0100\n" +"POT-Creation-Date: 2014-01-14 13:17+0100\n" "PO-Revision-Date: 2014-01-06 10:16+0100\n" "Last-Translator: Nils Görs \n" "Language-Team: German \n" @@ -2760,6 +2760,10 @@ msgstr "Konfigurationsoptionen" msgid "names of plugins" msgstr "Liste der Erweiterungen" +#, fuzzy +msgid "names of plugins installed" +msgstr "Liste der Erweiterungen" + msgid "commands defined by plugins" msgstr "Befehle, definiert durch Erweiterungen" diff --git a/po/es.po b/po/es.po index 4d0969d51..5a6ee3a9b 100644 --- a/po/es.po +++ b/po/es.po @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-01-13 15:40+0100\n" +"POT-Creation-Date: 2014-01-14 13:17+0100\n" "PO-Revision-Date: 2014-01-06 10:16+0100\n" "Last-Translator: Elián Hanisch \n" "Language-Team: weechat-dev \n" @@ -2547,6 +2547,10 @@ msgstr "opciones de configuración" msgid "names of plugins" msgstr "nombres de plugins" +#, fuzzy +msgid "names of plugins installed" +msgstr "nombres de plugins" + msgid "commands defined by plugins" msgstr "comandos definidos por plugins" diff --git a/po/fr.po b/po/fr.po index 6b990b099..2948c26e9 100644 --- a/po/fr.po +++ b/po/fr.po @@ -21,8 +21,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-01-13 15:40+0100\n" -"PO-Revision-Date: 2014-01-13 15:41+0100\n" +"POT-Creation-Date: 2014-01-14 13:17+0100\n" +"PO-Revision-Date: 2014-01-14 13:17+0100\n" "Last-Translator: Sébastien Helleu \n" "Language-Team: weechat-dev \n" "Language: fr\n" @@ -2686,6 +2686,9 @@ msgstr "options de configuration" msgid "names of plugins" msgstr "noms des extensions" +msgid "names of plugins installed" +msgstr "noms des extensions installées" + msgid "commands defined by plugins" msgstr "commandes définies par les extensions" diff --git a/po/hu.po b/po/hu.po index 01d450c2f..87dfce084 100644 --- a/po/hu.po +++ b/po/hu.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-01-13 15:40+0100\n" +"POT-Creation-Date: 2014-01-14 13:17+0100\n" "PO-Revision-Date: 2014-01-06 10:16+0100\n" "Last-Translator: Andras Voroskoi \n" "Language-Team: weechat-dev \n" @@ -2089,6 +2089,10 @@ msgstr "Nem található az opció\n" msgid "names of plugins" msgstr "konfigurációs paraméterek beállítása" +#, fuzzy +msgid "names of plugins installed" +msgstr "konfigurációs paraméterek beállítása" + #, fuzzy msgid "commands defined by plugins" msgstr " (nem található bővítőmodul)\n" diff --git a/po/it.po b/po/it.po index 92cceb1c1..4b1b1f26a 100644 --- a/po/it.po +++ b/po/it.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-01-13 15:40+0100\n" +"POT-Creation-Date: 2014-01-14 13:17+0100\n" "PO-Revision-Date: 2014-01-06 10:16+0100\n" "Last-Translator: Esteban I. Ruiz Moreno \n" "Language-Team: weechat-dev \n" @@ -2629,6 +2629,10 @@ msgstr "opzioni di configurazione" msgid "names of plugins" msgstr "nomi dei plugin" +#, fuzzy +msgid "names of plugins installed" +msgstr "nomi dei plugin" + msgid "commands defined by plugins" msgstr "comandi definiti dai plugin" diff --git a/po/ja.po b/po/ja.po index a118b2c20..7a01b185c 100644 --- a/po/ja.po +++ b/po/ja.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-01-13 15:40+0100\n" +"POT-Creation-Date: 2014-01-14 13:17+0100\n" "PO-Revision-Date: 2014-01-13 10:55+0100\n" "Last-Translator: AYANOKOUZI, Ryuunosuke \n" "Language-Team: Japanese \n" @@ -2618,6 +2618,10 @@ msgstr "設定オプション" msgid "names of plugins" msgstr "プラグイン名" +#, fuzzy +msgid "names of plugins installed" +msgstr "プラグイン名" + msgid "commands defined by plugins" msgstr "プラグインの定義するコマンド" diff --git a/po/pl.po b/po/pl.po index 9eef45e11..19afdc1fc 100644 --- a/po/pl.po +++ b/po/pl.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-01-13 15:40+0100\n" +"POT-Creation-Date: 2014-01-14 13:17+0100\n" "PO-Revision-Date: 2014-01-06 10:17+0100\n" "Last-Translator: Krzysztof Korościk \n" "Language-Team: weechat-dev \n" @@ -2673,6 +2673,10 @@ msgstr "opcje konfiguracyjne" msgid "names of plugins" msgstr "nazwy wtyczek" +#, fuzzy +msgid "names of plugins installed" +msgstr "nazwy wtyczek" + msgid "commands defined by plugins" msgstr "komendy zdefiniowane przez wtyczki" diff --git a/po/pt_BR.po b/po/pt_BR.po index 8400807da..60a0329ac 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-01-13 15:40+0100\n" +"POT-Creation-Date: 2014-01-14 13:17+0100\n" "PO-Revision-Date: 2014-01-06 10:17+0100\n" "Last-Translator: Sergio Durigan Junior \n" "Language-Team: weechat-dev \n" @@ -2498,6 +2498,10 @@ msgstr "opções de configuração" msgid "names of plugins" msgstr "nomes de plugins" +#, fuzzy +msgid "names of plugins installed" +msgstr "nomes de plugins" + msgid "commands defined by plugins" msgstr "comandos definidos por plugins" diff --git a/po/ru.po b/po/ru.po index 6f1fdbc3c..fdb84c8c8 100644 --- a/po/ru.po +++ b/po/ru.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-01-13 15:40+0100\n" +"POT-Creation-Date: 2014-01-14 13:17+0100\n" "PO-Revision-Date: 2014-01-06 10:17+0100\n" "Last-Translator: Aleksey V Zapparov AKA ixti \n" "Language-Team: weechat-dev \n" @@ -2112,6 +2112,10 @@ msgstr "Не найден параметр\n" msgid "names of plugins" msgstr "настроить параметры конфигурации" +#, fuzzy +msgid "names of plugins installed" +msgstr "настроить параметры конфигурации" + #, fuzzy msgid "commands defined by plugins" msgstr " (нет pluginа)\n" diff --git a/po/tr.po b/po/tr.po index bb8d7a89a..5bb5e3227 100644 --- a/po/tr.po +++ b/po/tr.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-01-13 15:40+0100\n" +"POT-Creation-Date: 2014-01-14 13:17+0100\n" "PO-Revision-Date: 2014-01-06 10:17+0100\n" "Last-Translator: Hasan Kiran \n" "Language-Team: weechat-dev \n" @@ -1870,6 +1870,10 @@ msgstr "yapılandırma seçenekleri" msgid "names of plugins" msgstr "eklentilerin isimleri" +#, fuzzy +msgid "names of plugins installed" +msgstr "eklentilerin isimleri" + msgid "commands defined by plugins" msgstr "" diff --git a/po/weechat.pot b/po/weechat.pot index e7b1d068d..c81fb84d0 100644 --- a/po/weechat.pot +++ b/po/weechat.pot @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.4.1-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-01-13 15:40+0100\n" +"POT-Creation-Date: 2014-01-14 13:17+0100\n" "PO-Revision-Date: 2013-02-14 18:20+0100\n" "Last-Translator: FULL NAME \n" "Language-Team: weechat-dev \n" @@ -1873,6 +1873,9 @@ msgstr "" msgid "names of plugins" msgstr "" +msgid "names of plugins installed" +msgstr "" + msgid "commands defined by plugins" msgstr "" diff --git a/src/core/wee-command.c b/src/core/wee-command.c index 97453b877..6d963c42b 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -6921,7 +6921,7 @@ command_init () "Without argument, this command lists loaded plugins."), "list %(plugins_names)" " || listfull %(plugins_names)" - " || load %(filename)" + " || load %(plugins_installed)" " || autoload" " || reload %(plugins_names)" " || unload %(plugins_names)", diff --git a/src/core/wee-completion.c b/src/core/wee-completion.c index d394e633e..6e3066fee 100644 --- a/src/core/wee-completion.c +++ b/src/core/wee-completion.c @@ -41,6 +41,7 @@ #include "wee-proxy.h" #include "wee-secure.h" #include "wee-string.h" +#include "wee-util.h" #include "../gui/gui-completion.h" #include "../gui/gui-bar.h" #include "../gui/gui-bar-window.h" @@ -730,6 +731,92 @@ completion_list_add_plugins_cb (void *data, return WEECHAT_RC_OK; } +/* + * Adds a plugin installed to completion list. + */ + +void +completion_list_add_plugins_installed_exec_cb (void *data, const char *filename) +{ + struct t_gui_completion *completion; + const char *pos, *pos2; + char *name; + + completion = (struct t_gui_completion *)data; + + /* start after last '/' (or '\') in path */ + pos = strrchr (filename, DIR_SEPARATOR_CHAR); + if (pos) + pos++; + else + pos = filename; + + /* truncate after the last '.' in name */ + pos2 = strrchr (pos, '.'); + if (pos2) + name = string_strndup (pos, pos2 - pos); + else + name = strdup (pos); + + if (name) + { + gui_completion_list_add (completion, name, 0, WEECHAT_LIST_POS_SORT); + free (name); + } +} + +/* + * Adds plugins installed to completion list. + */ + +int +completion_list_add_plugins_installed_cb (void *data, + const char *completion_item, + struct t_gui_buffer *buffer, + struct t_gui_completion *completion) +{ + char *plugin_path, *plugin_path2, *dir_name; + int length; + + /* make C compiler happy */ + (void) data; + (void) completion_item; + (void) buffer; + + /* plugins in WeeChat home dir */ + if (CONFIG_STRING(config_plugin_path) + && CONFIG_STRING(config_plugin_path)[0]) + { + plugin_path = string_expand_home (CONFIG_STRING(config_plugin_path)); + plugin_path2 = string_replace ((plugin_path) ? + plugin_path : CONFIG_STRING(config_plugin_path), + "%h", weechat_home); + util_exec_on_files ((plugin_path2) ? + plugin_path2 : ((plugin_path) ? + plugin_path : CONFIG_STRING(config_plugin_path)), + 0, + completion, + &completion_list_add_plugins_installed_exec_cb); + if (plugin_path) + free (plugin_path); + if (plugin_path2) + free (plugin_path2); + } + + /* plugins in WeeChat global lib dir */ + length = strlen (WEECHAT_LIBDIR) + 16 + 1; + dir_name = malloc (length); + if (dir_name) + { + snprintf (dir_name, length, "%s/plugins", WEECHAT_LIBDIR); + util_exec_on_files (dir_name, 0, completion, + &completion_list_add_plugins_installed_exec_cb); + free (dir_name); + } + + return WEECHAT_RC_OK; +} + /* * Adds plugin commands to completion list. * @@ -1416,6 +1503,9 @@ completion_init () hook_completion (NULL, "plugins_names", /* formerly "%p" */ N_("names of plugins"), &completion_list_add_plugins_cb, NULL); + hook_completion (NULL, "plugins_installed", + N_("names of plugins installed"), + &completion_list_add_plugins_installed_cb, NULL); hook_completion (NULL, "plugins_commands", /* formerly "%P" */ N_("commands defined by plugins"), &completion_list_add_plugins_commands_cb, NULL);