From 8c586eb49a226007f18c7fde200531bdedf73ddb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sat, 23 Aug 2014 12:13:11 +0200 Subject: [PATCH] core: allow incomplete commands if unambiguous (task #5419) --- ChangeLog.asciidoc | 1 + po/cs.po | 20 +++++-- po/de.po | 22 ++++++-- po/es.po | 20 +++++-- po/fr.po | 26 +++++++-- po/hu.po | 20 +++++-- po/it.po | 20 +++++-- po/ja.po | 21 +++++-- po/pl.po | 20 +++++-- po/pt_BR.po | 16 +++++- po/ru.po | 20 +++++-- po/tr.po | 16 +++++- po/weechat.pot | 16 +++++- src/core/wee-config.c | 7 +++ src/core/wee-config.h | 1 + src/core/wee-hook.c | 115 ++++++++++++++++++++++++--------------- src/core/wee-hook.h | 8 +++ src/core/wee-input.c | 63 +++++++++++++-------- src/gui/gui-completion.c | 36 +++++++++--- 19 files changed, 338 insertions(+), 130 deletions(-) diff --git a/ChangeLog.asciidoc b/ChangeLog.asciidoc index a7a8aa65c..97cc36115 100644 --- a/ChangeLog.asciidoc +++ b/ChangeLog.asciidoc @@ -17,6 +17,7 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes] === New features +* core: allow incomplete commands if unambiguous (task #5419) * trigger: add option "restore" in command /trigger === Bugs fixed diff --git a/po/cs.po b/po/cs.po index 6144e3b2d..ed990fcda 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-08-22 22:25+0200\n" +"POT-Creation-Date: 2014-08-23 11:34+0200\n" "PO-Revision-Date: 2014-08-16 11:46+0200\n" "Last-Translator: Jiri Golembiovsky \n" "Language-Team: weechat-dev \n" @@ -2869,6 +2869,11 @@ msgstr "" "musí začínat jedním z těchto znaků; lomítko (\"/\") je vždy považováno za " "předponu příkazu (napříkald: \".$\")" +msgid "" +"if set, incomplete and unambigous commands are allowed, for example /he for /" +"help" +msgstr "" + msgid "" "if set, /quit command must be confirmed with extra argument \"-yes\" (see /" "help quit)" @@ -3772,6 +3777,10 @@ msgstr "%sDo tohoto bufferu nemůžete zapisovat text" msgid "%sError with command \"%s\" (help on command: /help %s)" msgstr "%sChyba s příkazem \"%s\" (zkuste /help %s)" +#, c-format +msgid "%sError: unknown command \"%s\" (type /help for help)" +msgstr "%sChyba: neznámý příkaz \"%s\" (napište /help pro nápovědu)" + #, fuzzy, c-format msgid "" "%sError: ambiguous command \"%s\": it exists in many plugins and not in \"%s" @@ -3780,14 +3789,15 @@ msgstr "" "%sChyba: nejednoznačný příkaz \"%s\": již existuje v mnoha pluginech a ne v " "pluginu \"%s\"" +#, fuzzy, c-format +msgid "" +"%sError: incomplete command \"%s\" and many commands start with this name" +msgstr "%sChyba s příkazem \"%s\" (zkuste /help %s)" + #, c-format msgid "%sError: too much calls to command \"%s\" (looping)" msgstr "%sChyba: příliš mnoho volání příkazu \"%s\" (cyklení)" -#, c-format -msgid "%sError: unknown command \"%s\" (type /help for help)" -msgstr "%sChyba: neznámý příkaz \"%s\" (napište /help pro nápovědu)" - msgid "" "Error: unable to create/append to log file (weechat.log)\n" "If another WeeChat process is using this file, try to run WeeChat\n" diff --git a/po/de.po b/po/de.po index 735a219fd..276065161 100644 --- a/po/de.po +++ b/po/de.po @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-08-22 22:25+0200\n" +"POT-Creation-Date: 2014-08-23 11:34+0200\n" "PO-Revision-Date: 2014-08-23 10:49+0100\n" "Last-Translator: Nils Görs \n" "Language-Team: German \n" @@ -3351,6 +3351,11 @@ msgstr "" "ausführen kann. Zum Beispiel mittels \".$\". Der Schrägstrich (slash: \"/\") " "ist ein reserviertes Zeichen und wird immer genutzt" +msgid "" +"if set, incomplete and unambigous commands are allowed, for example /he for /" +"help" +msgstr "" + msgid "" "if set, /quit command must be confirmed with extra argument \"-yes\" (see /" "help quit)" @@ -4409,6 +4414,11 @@ msgstr "%sIn diesen Buffer kann nicht geschrieben werden" msgid "%sError with command \"%s\" (help on command: /help %s)" msgstr "%sFehler mit dem Befehl \"%s\" aufgetreten (nutze: /help %s)" +#, c-format +msgid "%sError: unknown command \"%s\" (type /help for help)" +msgstr "" +"%sFehler: Der Befehl \"%s\" ist nicht bekannt. Für eine Hilfe nutze /help" + #, c-format msgid "" "%sError: ambiguous command \"%s\": it exists in many plugins and not in \"%s" @@ -4417,15 +4427,15 @@ msgstr "" "%sFehler: Der Befehl \"%s\" ist nicht eindeutig: Er existiert für mehrere " "Erweiterungen, aber nicht für die Erweiterung \"%s\"" +#, fuzzy, c-format +msgid "" +"%sError: incomplete command \"%s\" and many commands start with this name" +msgstr "%sFehler mit dem Befehl \"%s\" aufgetreten (nutze: /help %s)" + #, c-format msgid "%sError: too much calls to command \"%s\" (looping)" msgstr "%sFehler: zu viele Aufrufe des Programms \"%s\" (Wiederholungen)" -#, c-format -msgid "%sError: unknown command \"%s\" (type /help for help)" -msgstr "" -"%sFehler: Der Befehl \"%s\" ist nicht bekannt. Für eine Hilfe nutze /help" - msgid "" "Error: unable to create/append to log file (weechat.log)\n" "If another WeeChat process is using this file, try to run WeeChat\n" diff --git a/po/es.po b/po/es.po index 8efbceb10..710419557 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-08-22 22:25+0200\n" +"POT-Creation-Date: 2014-08-23 11:34+0200\n" "PO-Revision-Date: 2014-08-16 11:46+0200\n" "Last-Translator: Elián Hanisch \n" "Language-Team: weechat-dev \n" @@ -3023,6 +3023,11 @@ msgstr "" "no: el comando debe empezar con uno de estos caracteres; la barra (\"/\") es " "siempre considerado como prefijo de comando (ejemplo: \".$\")" +msgid "" +"if set, incomplete and unambigous commands are allowed, for example /he for /" +"help" +msgstr "" + msgid "" "if set, /quit command must be confirmed with extra argument \"-yes\" (see /" "help quit)" @@ -3981,6 +3986,10 @@ msgstr "%sNo es posible escribir texto en este buffer" msgid "%sError with command \"%s\" (help on command: /help %s)" msgstr "%sError con el comando \"%s\" (trata con /help %s)" +#, c-format +msgid "%sError: unknown command \"%s\" (type /help for help)" +msgstr "%sError: comando \"%s\" desconocido (use /help para ver la ayuda)" + #, c-format msgid "" "%sError: ambiguous command \"%s\": it exists in many plugins and not in \"%s" @@ -3989,14 +3998,15 @@ msgstr "" "%sError: el comando \"%s\" es ambiguo: existe en varios plugins y no en el " "plugin \"%s\"" +#, fuzzy, c-format +msgid "" +"%sError: incomplete command \"%s\" and many commands start with this name" +msgstr "%sError con el comando \"%s\" (trata con /help %s)" + #, c-format msgid "%sError: too much calls to command \"%s\" (looping)" msgstr "%sError: demasiadas llamadas al comando \"%s\" (bucle)" -#, c-format -msgid "%sError: unknown command \"%s\" (type /help for help)" -msgstr "%sError: comando \"%s\" desconocido (use /help para ver la ayuda)" - msgid "" "Error: unable to create/append to log file (weechat.log)\n" "If another WeeChat process is using this file, try to run WeeChat\n" diff --git a/po/fr.po b/po/fr.po index 04c15d965..e4fab5c40 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-08-22 22:25+0200\n" -"PO-Revision-Date: 2014-08-22 22:25+0200\n" +"POT-Creation-Date: 2014-08-23 11:34+0200\n" +"PO-Revision-Date: 2014-08-23 11:39+0200\n" "Last-Translator: Sébastien Helleu \n" "Language-Team: weechat-dev \n" "Language: fr\n" @@ -3268,6 +3268,13 @@ msgstr "" "(\"/\") est toujours considérée comme un préfixe de commande (exemple : \".$" "\")" +msgid "" +"if set, incomplete and unambigous commands are allowed, for example /he for /" +"help" +msgstr "" +"si activé, les commandes incomplètes et non ambiguës sont autorisées, par " +"exemple /he pour /help" + msgid "" "if set, /quit command must be confirmed with extra argument \"-yes\" (see /" "help quit)" @@ -4308,6 +4315,10 @@ msgstr "%sVous ne pouvez pas écrire de texte dans ce tampon" msgid "%sError with command \"%s\" (help on command: /help %s)" msgstr "%sErreur avec la commande \"%s\" (aide sur la commande : /help %s)" +#, c-format +msgid "%sError: unknown command \"%s\" (type /help for help)" +msgstr "%sErreur : commande \"%s\" inconnue (tapez /help pour l'aide)" + #, c-format msgid "" "%sError: ambiguous command \"%s\": it exists in many plugins and not in \"%s" @@ -4317,12 +4328,15 @@ msgstr "" "et pas dans l'extension \"%s\"" #, c-format -msgid "%sError: too much calls to command \"%s\" (looping)" -msgstr "%sErreur : trop d'appels à la commande \"%s\" (boucle)" +msgid "" +"%sError: incomplete command \"%s\" and many commands start with this name" +msgstr "" +"%sErreur : commande \"%s\" incomplète et plusieurs commandes commencent par " +"ce nom" #, c-format -msgid "%sError: unknown command \"%s\" (type /help for help)" -msgstr "%sErreur : commande \"%s\" inconnue (tapez /help pour l'aide)" +msgid "%sError: too much calls to command \"%s\" (looping)" +msgstr "%sErreur : trop d'appels à la commande \"%s\" (boucle)" msgid "" "Error: unable to create/append to log file (weechat.log)\n" diff --git a/po/hu.po b/po/hu.po index 83b8fa79b..b12192e65 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-08-22 22:25+0200\n" +"POT-Creation-Date: 2014-08-23 11:34+0200\n" "PO-Revision-Date: 2014-08-16 11:46+0200\n" "Last-Translator: Andras Voroskoi \n" "Language-Team: weechat-dev \n" @@ -2518,6 +2518,11 @@ msgid "" "command prefix (example: \".$\")" msgstr "" +msgid "" +"if set, incomplete and unambigous commands are allowed, for example /he for /" +"help" +msgstr "" + msgid "" "if set, /quit command must be confirmed with extra argument \"-yes\" (see /" "help quit)" @@ -3394,6 +3399,10 @@ msgstr "%s az utolsó puffert nem lehet bezárni\n" msgid "%sError with command \"%s\" (help on command: /help %s)" msgstr "%s a \"%s\" aliasz vagy parancs nem található\n" +#, fuzzy, c-format +msgid "%sError: unknown command \"%s\" (type /help for help)" +msgstr "%s a \"%s\" aliasz vagy parancs nem található\n" + #, fuzzy, c-format msgid "" "%sError: ambiguous command \"%s\": it exists in many plugins and not in \"%s" @@ -3401,12 +3410,13 @@ msgid "" msgstr "%s az ignore már létezik\n" #, fuzzy, c-format -msgid "%sError: too much calls to command \"%s\" (looping)" -msgstr "%s helytelen érték a \"%s\" paraméternek\n" +msgid "" +"%sError: incomplete command \"%s\" and many commands start with this name" +msgstr "%s a \"%s\" aliasz vagy parancs nem található\n" #, fuzzy, c-format -msgid "%sError: unknown command \"%s\" (type /help for help)" -msgstr "%s a \"%s\" aliasz vagy parancs nem található\n" +msgid "%sError: too much calls to command \"%s\" (looping)" +msgstr "%s helytelen érték a \"%s\" paraméternek\n" #, fuzzy msgid "" diff --git a/po/it.po b/po/it.po index e59dbe1c2..f74862bbe 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-08-22 22:25+0200\n" +"POT-Creation-Date: 2014-08-23 11:34+0200\n" "PO-Revision-Date: 2014-08-16 11:46+0200\n" "Last-Translator: Esteban I. Ruiz Moreno \n" "Language-Team: weechat-dev \n" @@ -3116,6 +3116,11 @@ msgstr "" "no: l'input deve iniziare con uno di questi caratteri: la barra (\"/\") è " "sempre considerata come prefisso per comando (esempio: \".$\")" +msgid "" +"if set, incomplete and unambigous commands are allowed, for example /he for /" +"help" +msgstr "" + msgid "" "if set, /quit command must be confirmed with extra argument \"-yes\" (see /" "help quit)" @@ -4092,6 +4097,10 @@ msgstr "%sNon è possibile scrivere del testo in questo buffer" msgid "%sError with command \"%s\" (help on command: /help %s)" msgstr "%sErrore con il comando \"%s\" (digita /help %s)" +#, c-format +msgid "%sError: unknown command \"%s\" (type /help for help)" +msgstr "%sErrore: comando \"%s\" sconosciuto (digita /help per l'aiuto)" + #, c-format msgid "" "%sError: ambiguous command \"%s\": it exists in many plugins and not in \"%s" @@ -4100,14 +4109,15 @@ msgstr "" "%sErrore: comando ambiguo \"%s\": esiste in più plugin e non nel plugin \"%s" "\"" +#, fuzzy, c-format +msgid "" +"%sError: incomplete command \"%s\" and many commands start with this name" +msgstr "%sErrore con il comando \"%s\" (digita /help %s)" + #, c-format msgid "%sError: too much calls to command \"%s\" (looping)" msgstr "%sErrore: troppe chiamate al comando \"%s\" (loop)" -#, c-format -msgid "%sError: unknown command \"%s\" (type /help for help)" -msgstr "%sErrore: comando \"%s\" sconosciuto (digita /help per l'aiuto)" - msgid "" "Error: unable to create/append to log file (weechat.log)\n" "If another WeeChat process is using this file, try to run WeeChat\n" diff --git a/po/ja.po b/po/ja.po index c70e0c192..5c7723eb6 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-08-22 22:25+0200\n" +"POT-Creation-Date: 2014-08-23 11:34+0200\n" "PO-Revision-Date: 2014-08-16 23:57+0900\n" "Last-Translator: AYANOKOUZI, Ryuunosuke \n" "Language-Team: Japanese \n" @@ -3174,6 +3174,11 @@ msgstr "" "ら始まらなければいけない; スラッシュ (\"/\") は常にコマンドプレフィックスとし" "て扱われる (例: \".$\")" +msgid "" +"if set, incomplete and unambigous commands are allowed, for example /he for /" +"help" +msgstr "" + msgid "" "if set, /quit command must be confirmed with extra argument \"-yes\" (see /" "help quit)" @@ -4133,6 +4138,10 @@ msgid "%sError with command \"%s\" (help on command: /help %s)" msgstr "" "%sコマンド \"%s\" にエラーがあります (コマンドに関するヘルプ: /help %s)" +#, c-format +msgid "%sError: unknown command \"%s\" (type /help for help)" +msgstr "%sエラー: 未定義のコマンド \"%s\" (ヘルプを見るには /help)" + #, c-format msgid "" "%sError: ambiguous command \"%s\": it exists in many plugins and not in \"%s" @@ -4141,15 +4150,17 @@ msgstr "" "%sエラー: あいまいなコマンド \"%s\": 多くのプラグインで定義されており、\"%s" "\" プラグインでは定義されていません" +#, fuzzy, c-format +msgid "" +"%sError: incomplete command \"%s\" and many commands start with this name" +msgstr "" +"%sコマンド \"%s\" にエラーがあります (コマンドに関するヘルプ: /help %s)" + #, c-format msgid "%sError: too much calls to command \"%s\" (looping)" msgstr "" "%sエラー: コマンド \"%s\" の呼び出し回数が多すぎます (ループしています)" -#, c-format -msgid "%sError: unknown command \"%s\" (type /help for help)" -msgstr "%sエラー: 未定義のコマンド \"%s\" (ヘルプを見るには /help)" - msgid "" "Error: unable to create/append to log file (weechat.log)\n" "If another WeeChat process is using this file, try to run WeeChat\n" diff --git a/po/pl.po b/po/pl.po index 842100f7d..1f1c1c21e 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-08-22 22:25+0200\n" +"POT-Creation-Date: 2014-08-23 11:34+0200\n" "PO-Revision-Date: 2014-08-16 11:46+0200\n" "Last-Translator: Krzysztof Korościk \n" "Language-Team: weechat-dev \n" @@ -3236,6 +3236,11 @@ msgstr "" "wprowadzony ciąg musi się zaczynać od jednego z tych znaków; slash (\"/\") " "jest zawsze uważany za prefiks komendy (np: \".$\")" +msgid "" +"if set, incomplete and unambigous commands are allowed, for example /he for /" +"help" +msgstr "" + msgid "" "if set, /quit command must be confirmed with extra argument \"-yes\" (see /" "help quit)" @@ -4230,6 +4235,10 @@ msgstr "%s nie możesz nic pisać w tym buforze" msgid "%sError with command \"%s\" (help on command: /help %s)" msgstr "%sBłąd komendy \"%s\" (pomoc dla komendy: /help %s)" +#, c-format +msgid "%sError: unknown command \"%s\" (type /help for help)" +msgstr "%sBłąd: nieznana komenda \"%s\" (wpisz /help , aby uzyskać pomoc)" + #, c-format msgid "" "%sError: ambiguous command \"%s\": it exists in many plugins and not in \"%s" @@ -4238,14 +4247,15 @@ msgstr "" "%sBłąd: niejasna komenda \"%s\": występuje w wielu wtyczkach, ale nie we " "wtyczce \"%s\"" +#, fuzzy, c-format +msgid "" +"%sError: incomplete command \"%s\" and many commands start with this name" +msgstr "%sBłąd komendy \"%s\" (pomoc dla komendy: /help %s)" + #, c-format msgid "%sError: too much calls to command \"%s\" (looping)" msgstr "%sBłąd: za dużo wywołań komendy \"%s\" (zapętlam)" -#, c-format -msgid "%sError: unknown command \"%s\" (type /help for help)" -msgstr "%sBłąd: nieznana komenda \"%s\" (wpisz /help , aby uzyskać pomoc)" - msgid "" "Error: unable to create/append to log file (weechat.log)\n" "If another WeeChat process is using this file, try to run WeeChat\n" diff --git a/po/pt_BR.po b/po/pt_BR.po index 9ba49a030..ce395f5d2 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-08-22 22:25+0200\n" +"POT-Creation-Date: 2014-08-23 11:34+0200\n" "PO-Revision-Date: 2014-08-16 11:46+0200\n" "Last-Translator: Sergio Durigan Junior \n" "Language-Team: weechat-dev \n" @@ -2952,6 +2952,11 @@ msgstr "" "não: a entrada deve começar com um dos seguintes caracteres; a barra (\"/\") " "é sempre considerada como prefixo de comando (exemplo: \".$\")" +msgid "" +"if set, incomplete and unambigous commands are allowed, for example /he for /" +"help" +msgstr "" + msgid "" "if set, /quit command must be confirmed with extra argument \"-yes\" (see /" "help quit)" @@ -3879,6 +3884,10 @@ msgstr "" msgid "%sError with command \"%s\" (help on command: /help %s)" msgstr "" +#, c-format +msgid "%sError: unknown command \"%s\" (type /help for help)" +msgstr "" + #, fuzzy, c-format msgid "" "%sError: ambiguous command \"%s\": it exists in many plugins and not in \"%s" @@ -3886,11 +3895,12 @@ msgid "" msgstr "%sErro: outro comando \"%s\" já existe para o plugin \"%s\"" #, c-format -msgid "%sError: too much calls to command \"%s\" (looping)" +msgid "" +"%sError: incomplete command \"%s\" and many commands start with this name" msgstr "" #, c-format -msgid "%sError: unknown command \"%s\" (type /help for help)" +msgid "%sError: too much calls to command \"%s\" (looping)" msgstr "" msgid "" diff --git a/po/ru.po b/po/ru.po index b5cf7528b..e113a65e7 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-08-22 22:25+0200\n" +"POT-Creation-Date: 2014-08-23 11:34+0200\n" "PO-Revision-Date: 2014-08-16 11:46+0200\n" "Last-Translator: Aleksey V Zapparov AKA ixti \n" "Language-Team: weechat-dev \n" @@ -2541,6 +2541,11 @@ msgid "" "command prefix (example: \".$\")" msgstr "" +msgid "" +"if set, incomplete and unambigous commands are allowed, for example /he for /" +"help" +msgstr "" + msgid "" "if set, /quit command must be confirmed with extra argument \"-yes\" (see /" "help quit)" @@ -3420,6 +3425,10 @@ msgstr "%s невозможно закрыть единственный буфе msgid "%sError with command \"%s\" (help on command: /help %s)" msgstr "%s сокращение или команда \"%s\" не найдены\n" +#, fuzzy, c-format +msgid "%sError: unknown command \"%s\" (type /help for help)" +msgstr "%s сокращение или команда \"%s\" не найдены\n" + #, fuzzy, c-format msgid "" "%sError: ambiguous command \"%s\": it exists in many plugins and not in \"%s" @@ -3427,12 +3436,13 @@ msgid "" msgstr "%s игнорирование уже существует\n" #, fuzzy, c-format -msgid "%sError: too much calls to command \"%s\" (looping)" -msgstr "%s некорректное значение параметра \"%s\"\n" +msgid "" +"%sError: incomplete command \"%s\" and many commands start with this name" +msgstr "%s сокращение или команда \"%s\" не найдены\n" #, fuzzy, c-format -msgid "%sError: unknown command \"%s\" (type /help for help)" -msgstr "%s сокращение или команда \"%s\" не найдены\n" +msgid "%sError: too much calls to command \"%s\" (looping)" +msgstr "%s некорректное значение параметра \"%s\"\n" #, fuzzy msgid "" diff --git a/po/tr.po b/po/tr.po index 588eadabe..51e658b6c 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-08-22 22:25+0200\n" +"POT-Creation-Date: 2014-08-23 11:34+0200\n" "PO-Revision-Date: 2014-07-25 07:50+0200\n" "Last-Translator: Hasan Kiran \n" "Language-Team: weechat-dev \n" @@ -2272,6 +2272,11 @@ msgid "" "command prefix (example: \".$\")" msgstr "" +msgid "" +"if set, incomplete and unambigous commands are allowed, for example /he for /" +"help" +msgstr "" + msgid "" "if set, /quit command must be confirmed with extra argument \"-yes\" (see /" "help quit)" @@ -3041,6 +3046,10 @@ msgstr "" msgid "%sError with command \"%s\" (help on command: /help %s)" msgstr "" +#, c-format +msgid "%sError: unknown command \"%s\" (type /help for help)" +msgstr "" + #, c-format msgid "" "%sError: ambiguous command \"%s\": it exists in many plugins and not in \"%s" @@ -3048,11 +3057,12 @@ msgid "" msgstr "" #, c-format -msgid "%sError: too much calls to command \"%s\" (looping)" +msgid "" +"%sError: incomplete command \"%s\" and many commands start with this name" msgstr "" #, c-format -msgid "%sError: unknown command \"%s\" (type /help for help)" +msgid "%sError: too much calls to command \"%s\" (looping)" msgstr "" msgid "" diff --git a/po/weechat.pot b/po/weechat.pot index 8cb82857a..f5f66c1d2 100644 --- a/po/weechat.pot +++ b/po/weechat.pot @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-08-22 22:25+0200\n" +"POT-Creation-Date: 2014-08-23 11:34+0200\n" "PO-Revision-Date: 2014-08-16 10:27+0200\n" "Last-Translator: Sébastien Helleu \n" "Language-Team: weechat-dev \n" @@ -2271,6 +2271,11 @@ msgid "" "command prefix (example: \".$\")" msgstr "" +msgid "" +"if set, incomplete and unambigous commands are allowed, for example /he for /" +"help" +msgstr "" + msgid "" "if set, /quit command must be confirmed with extra argument \"-yes\" (see /" "help quit)" @@ -3039,6 +3044,10 @@ msgstr "" msgid "%sError with command \"%s\" (help on command: /help %s)" msgstr "" +#, c-format +msgid "%sError: unknown command \"%s\" (type /help for help)" +msgstr "" + #, c-format msgid "" "%sError: ambiguous command \"%s\": it exists in many plugins and not in \"%s" @@ -3046,11 +3055,12 @@ msgid "" msgstr "" #, c-format -msgid "%sError: too much calls to command \"%s\" (looping)" +msgid "" +"%sError: incomplete command \"%s\" and many commands start with this name" msgstr "" #, c-format -msgid "%sError: unknown command \"%s\" (type /help for help)" +msgid "%sError: too much calls to command \"%s\" (looping)" msgstr "" msgid "" diff --git a/src/core/wee-config.c b/src/core/wee-config.c index eb02347bb..d415fb7bd 100644 --- a/src/core/wee-config.c +++ b/src/core/wee-config.c @@ -103,6 +103,7 @@ struct t_config_option *config_look_color_nick_offline; struct t_config_option *config_look_color_pairs_auto_reset; struct t_config_option *config_look_color_real_white; struct t_config_option *config_look_command_chars; +struct t_config_option *config_look_command_incomplete; struct t_config_option *config_look_confirm_quit; struct t_config_option *config_look_day_change; struct t_config_option *config_look_day_change_message_1date; @@ -2219,6 +2220,12 @@ config_weechat_init_options () "input must start with one of these chars; the slash (\"/\") is " "always considered as command prefix (example: \".$\")"), NULL, 0, 0, "", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + config_look_command_incomplete = config_file_new_option ( + weechat_config_file, ptr_section, + "command_incomplete", "boolean", + N_("if set, incomplete and unambigous commands are allowed, for " + "example /he for /help"), + NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); config_look_confirm_quit = config_file_new_option ( weechat_config_file, ptr_section, "confirm_quit", "boolean", diff --git a/src/core/wee-config.h b/src/core/wee-config.h index 3ec2b72b1..5d1128bf1 100644 --- a/src/core/wee-config.h +++ b/src/core/wee-config.h @@ -141,6 +141,7 @@ extern struct t_config_option *config_look_color_nick_offline; extern struct t_config_option *config_look_color_pairs_auto_reset; extern struct t_config_option *config_look_color_real_white; extern struct t_config_option *config_look_command_chars; +extern struct t_config_option *config_look_command_incomplete; extern struct t_config_option *config_look_confirm_quit; extern struct t_config_option *config_look_day_change; extern struct t_config_option *config_look_day_change_message_1date; diff --git a/src/core/wee-hook.c b/src/core/wee-hook.c index 60d212e0e..fd437f844 100644 --- a/src/core/wee-hook.c +++ b/src/core/wee-hook.c @@ -38,6 +38,7 @@ #include "weechat.h" #include "wee-hook.h" +#include "wee-config.h" #include "wee-hashtable.h" #include "wee-hdata.h" #include "wee-infolist.h" @@ -654,12 +655,12 @@ hook_command (struct t_weechat_plugin *plugin, const char *command, * Executes a command hook. * * Returns: - * 0: command executed and failed - * 1: command executed successfully - * -1: command not found - * -2: command is ambiguous (same command exists for another plugin, and we - * don't know which one to run) - * -3: command is already running + * HOOK_COMMAND_EXEC_OK: command executed successfully + * HOOK_COMMAND_EXEC_ERROR: command executed and failed + * HOOK_COMMAND_EXEC_NOT_FOUND: command not found + * HOOK_COMMAND_EXEC_AMBIGUOUS: command is ambiguous (same command exists for + * another plugin, and we don't know which one to run) + * HOOK_COMMAND_EXEC_RUNNING: command is already running */ int @@ -668,62 +669,79 @@ hook_command_exec (struct t_gui_buffer *buffer, int any_plugin, { struct t_hook *ptr_hook, *next_hook; struct t_hook *hook_plugin, *hook_other_plugin, *hook_other_plugin2; + struct t_hook *hook_incomplete_command; char **argv, **argv_eol, *ptr_command_name; - int argc, rc, count_other_plugin; + int argc, rc, length_command_name, allow_incomplete_commands; + int count_other_plugin, count_incomplete_commands; if (!buffer || !string || !string[0]) - return -1; + return HOOK_COMMAND_EXEC_NOT_FOUND; if (hook_command_run_exec (buffer, string) == WEECHAT_RC_OK_EAT) - return 1; + return HOOK_COMMAND_EXEC_OK; argv = string_split (string, " ", 0, 0, &argc); if (argc == 0) { string_free_split (argv); - return -1; + return HOOK_COMMAND_EXEC_NOT_FOUND; } argv_eol = string_split (string, " ", 1, 0, NULL); ptr_command_name = utf8_next_char (argv[0]); + length_command_name = strlen (ptr_command_name); hook_exec_start (); hook_plugin = NULL; hook_other_plugin = NULL; hook_other_plugin2 = NULL; + hook_incomplete_command = NULL; count_other_plugin = 0; + allow_incomplete_commands = CONFIG_BOOLEAN(config_look_command_incomplete); + count_incomplete_commands = 0; ptr_hook = weechat_hooks[HOOK_TYPE_COMMAND]; while (ptr_hook) { next_hook = ptr_hook->next_hook; - if (!ptr_hook->deleted - && (string_strcasecmp (ptr_command_name, - HOOK_COMMAND(ptr_hook, command)) == 0)) + if (!ptr_hook->deleted) { - if (ptr_hook->plugin == plugin) + if (string_strcasecmp (ptr_command_name, + HOOK_COMMAND(ptr_hook, command)) == 0) { - if (!hook_plugin) - hook_plugin = ptr_hook; - } - else - { - if (any_plugin) + if (ptr_hook->plugin == plugin) { - if (!hook_other_plugin) - hook_other_plugin = ptr_hook; - else if (!hook_other_plugin2) - hook_other_plugin2 = ptr_hook; - count_other_plugin++; + if (!hook_plugin) + hook_plugin = ptr_hook; } + else + { + if (any_plugin) + { + if (!hook_other_plugin) + hook_other_plugin = ptr_hook; + else if (!hook_other_plugin2) + hook_other_plugin2 = ptr_hook; + count_other_plugin++; + } + } + } + else if (allow_incomplete_commands + && (string_strncasecmp (ptr_command_name, + HOOK_COMMAND(ptr_hook, command), + length_command_name) == 0)) + { + hook_incomplete_command = ptr_hook; + count_incomplete_commands++; } } ptr_hook = next_hook; } - rc = -1; + rc = HOOK_COMMAND_EXEC_NOT_FOUND; + ptr_hook = NULL; if (hook_plugin || hook_other_plugin) { @@ -735,7 +753,7 @@ hook_command_exec (struct t_gui_buffer *buffer, int any_plugin, * command was found for other plugins with the same priority * => we don't know which one to run! */ - rc = -2; + rc = HOOK_COMMAND_EXEC_AMBIGUOUS_PLUGINS; } else { @@ -758,24 +776,35 @@ hook_command_exec (struct t_gui_buffer *buffer, int any_plugin, */ ptr_hook = (hook_plugin) ? hook_plugin : hook_other_plugin; } + } + } + else if (hook_incomplete_command) + { + if (count_incomplete_commands == 1) + ptr_hook = hook_incomplete_command; + else + rc = HOOK_COMMAND_EXEC_AMBIGUOUS_INCOMPLETE; + } - if (ptr_hook->running >= HOOK_COMMAND_MAX_CALLS) - { - /* loop in execution of command => do NOT execute again */ - rc = -3; - } + /* execute the command for the hook found */ + if (ptr_hook) + { + if (ptr_hook->running >= HOOK_COMMAND_MAX_CALLS) + { + /* loop in execution of command => do NOT execute again */ + rc = HOOK_COMMAND_EXEC_RUNNING; + } + else + { + /* execute the command! */ + ptr_hook->running++; + rc = (int) (HOOK_COMMAND(ptr_hook, callback)) + (ptr_hook->callback_data, buffer, argc, argv, argv_eol); + ptr_hook->running--; + if (rc == WEECHAT_RC_ERROR) + rc = HOOK_COMMAND_EXEC_ERROR; else - { - /* execute the command! */ - ptr_hook->running++; - rc = (int) (HOOK_COMMAND(ptr_hook, callback)) - (ptr_hook->callback_data, buffer, argc, argv, argv_eol); - ptr_hook->running--; - if (rc == WEECHAT_RC_ERROR) - rc = 0; - else - rc = 1; - } + rc = HOOK_COMMAND_EXEC_OK; } } diff --git a/src/core/wee-hook.h b/src/core/wee-hook.h index e033b6639..0e1778ad2 100644 --- a/src/core/wee-hook.h +++ b/src/core/wee-hook.h @@ -82,6 +82,14 @@ enum t_hook_type /* max calls that can be done for a command (recursive calls) */ #define HOOK_COMMAND_MAX_CALLS 5 +/* return code when a command is executed */ +#define HOOK_COMMAND_EXEC_OK 1 +#define HOOK_COMMAND_EXEC_ERROR 0 +#define HOOK_COMMAND_EXEC_NOT_FOUND -1 +#define HOOK_COMMAND_EXEC_AMBIGUOUS_PLUGINS -2 +#define HOOK_COMMAND_EXEC_AMBIGUOUS_INCOMPLETE -3 +#define HOOK_COMMAND_EXEC_RUNNING -4 + /* flags for fd hooks */ #define HOOK_FD_FLAG_READ 1 #define HOOK_FD_FLAG_WRITE 2 diff --git a/src/core/wee-input.c b/src/core/wee-input.c index ad4eb08b6..6469a1916 100644 --- a/src/core/wee-input.c +++ b/src/core/wee-input.c @@ -100,35 +100,22 @@ input_exec_command (struct t_gui_buffer *buffer, /* execute command */ switch (hook_command_exec (buffer, any_plugin, plugin, command)) { - case 0: /* command hooked, KO */ + case HOOK_COMMAND_EXEC_OK: + /* command hooked, OK (executed) */ + break; + case HOOK_COMMAND_EXEC_ERROR: + /* command hooked, error */ gui_chat_printf_date_tags (NULL, 0, GUI_FILTER_TAG_NO_FILTER, _("%sError with command \"%s\" (help on " "command: /help %s)"), gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], command, command_name + 1); break; - case 1: /* command hooked, OK (executed) */ - break; - case -2: /* command is ambiguous (exists for other plugins) */ - gui_chat_printf_date_tags (NULL, 0, GUI_FILTER_TAG_NO_FILTER, - _("%sError: ambiguous command \"%s\": " - "it exists in many plugins and not in " - "\"%s\" plugin"), - gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], - command_name, - plugin_get_name (plugin)); - break; - case -3: /* command is running */ - gui_chat_printf_date_tags (NULL, 0, GUI_FILTER_TAG_NO_FILTER, - _("%sError: too much calls to command " - "\"%s\" (looping)"), - gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], - command_name); - break; - default: /* no command hooked */ + case HOOK_COMMAND_EXEC_NOT_FOUND: /* - * if unknown commands are accepted by this buffer, just send - * input text as data to buffer, otherwise display error + * command not found: if unknown commands are accepted by this + * buffer, just send input text as data to buffer, + * otherwise display error */ if (buffer->input_get_unknown_commands) { @@ -143,6 +130,38 @@ input_exec_command (struct t_gui_buffer *buffer, command_name); } break; + case HOOK_COMMAND_EXEC_AMBIGUOUS_PLUGINS: + /* command is ambiguous (exists for other plugins) */ + gui_chat_printf_date_tags (NULL, 0, GUI_FILTER_TAG_NO_FILTER, + _("%sError: ambiguous command \"%s\": " + "it exists in many plugins and not in " + "\"%s\" plugin"), + gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], + command_name, + plugin_get_name (plugin)); + break; + case HOOK_COMMAND_EXEC_AMBIGUOUS_INCOMPLETE: + /* + * command is ambiguous (incomplete command and many commands + * start with this name) + */ + gui_chat_printf_date_tags (NULL, 0, GUI_FILTER_TAG_NO_FILTER, + _("%sError: incomplete command \"%s\" " + "and many commands start with this " + "name"), + gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], + command_name); + break; + case HOOK_COMMAND_EXEC_RUNNING: + /* command is running */ + gui_chat_printf_date_tags (NULL, 0, GUI_FILTER_TAG_NO_FILTER, + _("%sError: too much calls to command " + "\"%s\" (looping)"), + gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], + command_name); + break; + default: + break; } free (command); free (command_name); diff --git a/src/gui/gui-completion.c b/src/gui/gui-completion.c index c97192ed1..eee784bca 100644 --- a/src/gui/gui-completion.c +++ b/src/gui/gui-completion.c @@ -224,27 +224,45 @@ struct t_hook * gui_completion_search_command (struct t_weechat_plugin *plugin, const char *command) { - struct t_hook *ptr_hook, *hook_for_other_plugin; + struct t_hook *ptr_hook, *hook_for_other_plugin, *hook_incomplete_command; + int length_command, allow_incomplete_commands, count_incomplete_commands; hook_for_other_plugin = NULL; + hook_incomplete_command = NULL; + length_command = strlen (command); + count_incomplete_commands = 0; + allow_incomplete_commands = CONFIG_BOOLEAN(config_look_command_incomplete); for (ptr_hook = weechat_hooks[HOOK_TYPE_COMMAND]; ptr_hook; ptr_hook = ptr_hook->next_hook) { if (!ptr_hook->deleted && HOOK_COMMAND(ptr_hook, command) - && HOOK_COMMAND(ptr_hook, command)[0] - && (string_strcasecmp (HOOK_COMMAND(ptr_hook, command), - command) == 0)) + && HOOK_COMMAND(ptr_hook, command)[0]) { - if (ptr_hook->plugin == plugin) - return ptr_hook; - - hook_for_other_plugin = ptr_hook; + if (string_strcasecmp (HOOK_COMMAND(ptr_hook, command), + command) == 0) + { + if (ptr_hook->plugin == plugin) + return ptr_hook; + hook_for_other_plugin = ptr_hook; + } + else if (allow_incomplete_commands + && (string_strncasecmp (HOOK_COMMAND(ptr_hook, command), + command, + length_command) == 0)) + { + hook_incomplete_command = ptr_hook; + count_incomplete_commands++; + } } } - return hook_for_other_plugin; + if (hook_for_other_plugin) + return hook_for_other_plugin; + + return (count_incomplete_commands == 1) ? + hook_incomplete_command : NULL; } /*