diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2007-07-13 15:38:26 +0000 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2007-07-13 15:38:26 +0000 |
commit | feec343ffb74b2e317b89b0af2276320a9211b0c (patch) | |
tree | 7572b5442c8527d3e6e92159e5f6ba82dbaea287 | |
parent | ddc10d0164a83a578f8ea66dde54054c6ae93440 (diff) | |
download | weechat-feec343ffb74b2e317b89b0af2276320a9211b0c.zip |
Added "-nojoin" option for /connect and /reconnect commands (task #7074), added "%*" to completion template (repeat last completion).
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | doc/de/weechat.de.xml | 9 | ||||
-rw-r--r-- | doc/de/weechat_commands.xml | 14 | ||||
-rw-r--r-- | doc/en/weechat.en.xml | 8 | ||||
-rw-r--r-- | doc/en/weechat_commands.xml | 6 | ||||
-rw-r--r-- | doc/fr/weechat.fr.xml | 8 | ||||
-rw-r--r-- | doc/fr/weechat_commands.xml | 14 | ||||
-rw-r--r-- | src/common/command.c | 125 | ||||
-rw-r--r-- | src/common/completion.c | 37 | ||||
-rw-r--r-- | src/irc/irc-recv.c | 6 | ||||
-rw-r--r-- | src/irc/irc-server.c | 10 | ||||
-rw-r--r-- | src/irc/irc.h | 3 | ||||
-rw-r--r-- | weechat/ChangeLog | 4 | ||||
-rw-r--r-- | weechat/doc/de/weechat.de.xml | 9 | ||||
-rw-r--r-- | weechat/doc/de/weechat_commands.xml | 14 | ||||
-rw-r--r-- | weechat/doc/en/weechat.en.xml | 8 | ||||
-rw-r--r-- | weechat/doc/en/weechat_commands.xml | 6 | ||||
-rw-r--r-- | weechat/doc/fr/weechat.fr.xml | 8 | ||||
-rw-r--r-- | weechat/doc/fr/weechat_commands.xml | 14 | ||||
-rw-r--r-- | weechat/src/common/command.c | 125 | ||||
-rw-r--r-- | weechat/src/common/completion.c | 37 | ||||
-rw-r--r-- | weechat/src/irc/irc-recv.c | 6 | ||||
-rw-r--r-- | weechat/src/irc/irc-server.c | 10 | ||||
-rw-r--r-- | weechat/src/irc/irc.h | 3 |
24 files changed, 336 insertions, 152 deletions
@@ -1,10 +1,12 @@ WeeChat - Wee Enhanced Environment for Chat =========================================== -ChangeLog - 2007-07-12 +ChangeLog - 2007-07-13 Version 0.2.6 (under dev!): + * added "%*" to completion template, to repeat last completion + * added "-nojoin" option for /connect and /reconnect commands (task #7074) * fixed bugs with IRC color in messages, now color codes are inserted in command line with ^Cc,^Cb,.. instead of %C,%B,.. (bug #20222, task #7060) * fixed bug with smart nick completion (last speakers first) when a nick diff --git a/doc/de/weechat.de.xml b/doc/de/weechat.de.xml index d7c479f1b..eadfce062 100644 --- a/doc/de/weechat.de.xml +++ b/doc/de/weechat.de.xml @@ -2355,6 +2355,15 @@ msg_handler = plugin->msg_handler_add (plugin, "KICK", <entry>keine Vervollständigung für das Argument</entry> </row> <row> + <entry><literal>%*</literal></entry> + <entry> + <!-- TRANSLATION NEEDED --> + repeat last completion for all following arguments + (this code has to be at the end of completion + template, preceded by "|") + </entry> + </row> + <row> <entry><literal>%a</literal></entry> <entry>Alias</entry> </row> diff --git a/doc/de/weechat_commands.xml b/doc/de/weechat_commands.xml index c999b7533..87506cf4f 100644 --- a/doc/de/weechat_commands.xml +++ b/doc/de/weechat_commands.xml @@ -62,12 +62,13 @@ Fenster leeren Nummer: lösche den Puffer mit der angegebenen Nummer </programlisting> -<command>connect [-all | Servername [Servername ...]]</command> +<command>connect [-all [-nojoin] | [-nojoin] servername [servername ...]]</command> <programlisting> mit Server verbinden - -all: verbinde mit allen Servern -servername: Servername, mit dem verbunden werden soll + -all: connect to all servers +servername: server name to connect + -nojoin: do not join any channel (even if autojoin is enabled on server) </programlisting> <command>disconnect [-all | Servername [Servername ...]]</command> @@ -150,12 +151,13 @@ autoload: lade automatisch alle Plugins im System- oder Benutzerverzeichnis Ohne Argument, listet /plugin alle geladenen Plugins auf. </programlisting> -<command>reconnect [-all | Servername [Servername ...]]</command> +<command>reconnect [-all [-nojoin] | servername [servername ...]] [-nojoin]</command> <programlisting> mit einem Server oder mehreren Servern neu verbinden - -all: Verbinde mit allen Servern neu -servername: Servername, mit dem verbunden werden soll + -all: reconnect to all servers +servername: server name to reconnect + -nojoin: do not join any channel (even if autojoin is enabled on server) </programlisting> <command>server [Servername] | [Servername Hostname Port [-auto | -noauto] [-ipv6] [-ssl] [-pwd Passwort] [-nicks Nick1 Nick2 Nick3] [-username Benutzername] [-realname Name] [-command Befehl] [-autojoin Channel[,Channel]] ] | [del Servername]</command> diff --git a/doc/en/weechat.en.xml b/doc/en/weechat.en.xml index 764f62ff6..bffbddba9 100644 --- a/doc/en/weechat.en.xml +++ b/doc/en/weechat.en.xml @@ -2364,6 +2364,14 @@ msg_handler = plugin->msg_handler_add (plugin, "KICK", <entry>no completion for argument</entry> </row> <row> + <entry><literal>%*</literal></entry> + <entry> + repeat last completion for all following arguments + (this code has to be at the end of completion + template, preceded by "|") + </entry> + </row> + <row> <entry><literal>%a</literal></entry> <entry>alias</entry> </row> diff --git a/doc/en/weechat_commands.xml b/doc/en/weechat_commands.xml index 72bf9daa3..d93fe1b42 100644 --- a/doc/en/weechat_commands.xml +++ b/doc/en/weechat_commands.xml @@ -62,12 +62,13 @@ clear window(s) number: clear buffer by number </programlisting> -<command>connect [-all | servername [servername ...]]</command> +<command>connect [-all [-nojoin] | [-nojoin] servername [servername ...]]</command> <programlisting> connect to server(s) -all: connect to all servers servername: server name to connect + -nojoin: do not join any channel (even if autojoin is enabled on server) </programlisting> <command>disconnect [-all | servername [servername ...]]</command> @@ -149,12 +150,13 @@ autoload: autoload plugins in system or user directory Without argument, /plugin command lists loaded plugins. </programlisting> -<command>reconnect [-all | servername [servername ...]]</command> +<command>reconnect [-all [-nojoin] | servername [servername ...]] [-nojoin]</command> <programlisting> reconnect to server(s) -all: reconnect to all servers servername: server name to reconnect + -nojoin: do not join any channel (even if autojoin is enabled on server) </programlisting> <command>server [servername] | [servername hostname port [-auto | -noauto] [-ipv6] [-ssl] [-pwd password] [-nicks nick1 nick2 nick3] [-username username] [-realname realname] [-command command] [-autojoin channel[,channel]] ] | [del servername]</command> diff --git a/doc/fr/weechat.fr.xml b/doc/fr/weechat.fr.xml index 43e080ffe..4d1854df3 100644 --- a/doc/fr/weechat.fr.xml +++ b/doc/fr/weechat.fr.xml @@ -2426,6 +2426,14 @@ msg_handler = plugin->msg_handler_add (plugin, "KICK", <entry>aucune complétion pour le paramètre</entry> </row> <row> + <entry><literal>%*</literal></entry> + <entry> + répétition de la dernière complétion pour tous + les paramètres suivants (ce code doit être à la + fin du modèle de complétion, précédé d'un "|") + </entry> + </row> + <row> <entry><literal>%a</literal></entry> <entry>alias</entry> </row> diff --git a/doc/fr/weechat_commands.xml b/doc/fr/weechat_commands.xml index 460211806..b0b0d8975 100644 --- a/doc/fr/weechat_commands.xml +++ b/doc/fr/weechat_commands.xml @@ -62,12 +62,13 @@ effacer la/les fenêtre(s) nombre: effacer un tampon par son numéro </programlisting> -<command>connect [-all | nom_serveur [nom_serveur...]]</command> +<command>connect [-all [-nojoin] | [-nojoin] servername [servername ...]]</command> <programlisting> se connecter à un/plusieurs serveur(s) - -all: se connecter à tous les serveurs -nom_serveur: nom du serveur pour se connecter + -all: connect to all servers +servername: server name to connect + -nojoin: do not join any channel (even if autojoin is enabled on server) </programlisting> <command>disconnect [-all | nom_serveur [nom_serveur...]]</command> @@ -149,12 +150,13 @@ autoload: charger automatiquement les extensions dans un répertoire système ou u Sans paramètre, la commande /plugin liste les extensions chargées. </programlisting> -<command>reconnect [-all | nom_serveur [nom_serveur...]]</command> +<command>reconnect [-all [-nojoin] | servername [servername ...]] [-nojoin]</command> <programlisting> se reconnecter à un/plusieurs serveur(s) - -all: se reconnecter à tous les serveurs -nom_serveur: nom du serveur pour se reconnecter + -all: reconnect to all servers +servername: server name to reconnect + -nojoin: do not join any channel (even if autojoin is enabled on server) </programlisting> <command>server [nom_serveur] | [nom_serveur nom/IP port [-auto | -noauto] [-ipv6] [-ssl] [-pwd mot_de_passe] [-nicks pseudo1 pseudo2 pseudo3] [-username nom_utilisateur] [-realname nom_réel] [-command commande] [-autojoin canal[,canal]] ] | [del nom_serveur]</command> diff --git a/src/common/command.c b/src/common/command.c index cff08dca7..3d0152505 100644 --- a/src/common/command.c +++ b/src/common/command.c @@ -96,10 +96,11 @@ t_weechat_command weechat_commands[] = "number: clear buffer by number"), "-all", 0, 1, 0, weechat_cmd_clear, NULL }, { "connect", N_("connect to server(s)"), - N_("[-all | servername [servername ...]]"), + N_("[-all [-nojoin] | [-nojoin] servername [servername ...]]"), N_(" -all: connect to all servers\n" - "servername: server name to connect"), - "%S|-all", 0, MAX_ARGS, 0, weechat_cmd_connect, NULL }, + "servername: server name to connect\n" + " -nojoin: do not join any channel (even if autojoin is enabled on server)"), + "%S|-all|-nojoin|%*", 0, MAX_ARGS, 0, weechat_cmd_connect, NULL }, { "disconnect", N_("disconnect from server(s)"), N_("[-all | servername [servername ...]]"), N_(" -all: disconnect from all servers\n" @@ -166,10 +167,11 @@ t_weechat_command weechat_commands[] = "Without argument, /plugin command lists loaded plugins."), "list|listfull|load|autoload|reload|unload %P", 0, 2, 0, weechat_cmd_plugin, NULL }, { "reconnect", N_("reconnect to server(s)"), - N_("[-all | servername [servername ...]]"), + N_("[-all [-nojoin] | servername [servername ...]] [-nojoin]"), N_(" -all: reconnect to all servers\n" - "servername: server name to reconnect"), - "%S|-all", 0, MAX_ARGS, 0, weechat_cmd_reconnect, NULL }, + "servername: server name to reconnect\n" + " -nojoin: do not join any channel (even if autojoin is enabled on server)"), + "%S|-all|-nojoin|%*", 0, MAX_ARGS, 0, weechat_cmd_reconnect, NULL }, { "server", N_("list, add or remove servers"), N_("[servername] | " "[servername hostname port [-auto | -noauto] [-ipv6] [-ssl] [-pwd password] [-nicks nick1 " @@ -1547,7 +1549,8 @@ weechat_cmd_clear (t_irc_server *server, t_irc_channel *channel, */ int -weechat_cmd_connect_one_server (t_irc_server *server, t_gui_window *window) +weechat_cmd_connect_one_server (t_gui_window *window, t_irc_server *server, + int no_join) { if (server->is_connected) { @@ -1571,7 +1574,7 @@ weechat_cmd_connect_one_server (t_irc_server *server, t_gui_window *window) BUFFER_TYPE_STANDARD, 1)) return 0; } - if (irc_server_connect (server)) + if (irc_server_connect (server, no_join)) { server->reconnect_start = 0; server->reconnect_join = (server->channels) ? 1 : 0; @@ -1593,36 +1596,49 @@ weechat_cmd_connect (t_irc_server *server, t_irc_channel *channel, t_gui_window *window; t_gui_buffer *buffer; t_irc_server *ptr_server; - int i, connect_ok; + int i, nb_connect, connect_ok, all_servers, no_join; gui_buffer_find_context (server, channel, &window, &buffer); + + nb_connect = 0; + connect_ok = 1; - if (argc == 0) - connect_ok = weechat_cmd_connect_one_server (server, window); - else + all_servers = 0; + no_join = 0; + for (i = 0; i < argc; i++) { - connect_ok = 1; - - if (ascii_strcasecmp (argv[0], "-all") == 0) + if (ascii_strcasecmp (argv[i], "-all") == 0) + all_servers = 1; + if (ascii_strcasecmp (argv[i], "-nojoin") == 0) + no_join = 1; + } + + if (all_servers) + { + for (ptr_server = irc_servers; ptr_server; + ptr_server = ptr_server->next_server) { - for (ptr_server = irc_servers; ptr_server; - ptr_server = ptr_server->next_server) + nb_connect++; + if (!ptr_server->is_connected && (ptr_server->child_pid == 0)) { - if (!ptr_server->is_connected && (ptr_server->child_pid == 0)) - { - if (!weechat_cmd_connect_one_server (ptr_server, window)) - connect_ok = 0; - } + if (!weechat_cmd_connect_one_server (window, ptr_server, + no_join)) + connect_ok = 0; } } - else + } + else + { + for (i = 0; i < argc; i++) { - for (i = 0; i < argc; i++) + if (argv[i][0] != '-') { + nb_connect++; ptr_server = irc_server_search (argv[i]); if (ptr_server) { - if (!weechat_cmd_connect_one_server (ptr_server, window)) + if (!weechat_cmd_connect_one_server (window, ptr_server, + no_join)) connect_ok = 0; } else @@ -1636,6 +1652,9 @@ weechat_cmd_connect (t_irc_server *server, t_irc_channel *channel, } } + if (nb_connect == 0) + connect_ok = weechat_cmd_connect_one_server (window, server, no_join); + if (!connect_ok) return -1; @@ -2767,7 +2786,7 @@ weechat_cmd_plugin (t_irc_server *server, t_irc_channel *channel, */ int -weechat_cmd_reconnect_one_server (t_irc_server *server) +weechat_cmd_reconnect_one_server (t_irc_server *server, int no_join) { if ((!server->is_connected) && (server->child_pid == 0)) { @@ -2779,7 +2798,7 @@ weechat_cmd_reconnect_one_server (t_irc_server *server) } irc_send_quit_server (server, NULL); irc_server_disconnect (server, 0); - if (irc_server_connect (server)) + if (irc_server_connect (server, no_join)) { server->reconnect_start = 0; server->reconnect_join = (server->channels) ? 1 : 0; @@ -2800,36 +2819,47 @@ weechat_cmd_reconnect (t_irc_server *server, t_irc_channel *channel, { t_gui_buffer *buffer; t_irc_server *ptr_server; - int i, reconnect_ok; + int i, nb_reconnect, reconnect_ok, all_servers, no_join; - gui_buffer_find_context (server, channel, NULL, &buffer); + gui_buffer_find_context (server, channel, NULL, &buffer); - if (argc == 0) - reconnect_ok = weechat_cmd_reconnect_one_server (server); - else + nb_reconnect = 0; + reconnect_ok = 1; + + all_servers = 0; + no_join = 0; + for (i = 0; i < argc; i++) { - reconnect_ok = 1; - - if (ascii_strcasecmp (argv[0], "-all") == 0) + if (ascii_strcasecmp (argv[i], "-all") == 0) + all_servers = 1; + if (ascii_strcasecmp (argv[i], "-nojoin") == 0) + no_join = 1; + } + + if (all_servers) + { + for (ptr_server = irc_servers; ptr_server; + ptr_server = ptr_server->next_server) { - for (ptr_server = irc_servers; ptr_server; - ptr_server = ptr_server->next_server) + nb_reconnect++; + if ((ptr_server->is_connected) || (ptr_server->child_pid != 0)) { - if ((ptr_server->is_connected) || (ptr_server->child_pid != 0)) - { - if (!weechat_cmd_reconnect_one_server (ptr_server)) - reconnect_ok = 0; - } + if (!weechat_cmd_reconnect_one_server (ptr_server, no_join)) + reconnect_ok = 0; } } - else + } + else + { + for (i = 0; i < argc; i++) { - for (i = 0; i < argc; i++) + if (argv[i][0] != '-') { + nb_reconnect++; ptr_server = irc_server_search (argv[i]); if (ptr_server) { - if (!weechat_cmd_reconnect_one_server (ptr_server)) + if (!weechat_cmd_reconnect_one_server (ptr_server, no_join)) reconnect_ok = 0; } else @@ -2843,6 +2873,9 @@ weechat_cmd_reconnect (t_irc_server *server, t_irc_channel *channel, } } + if (nb_reconnect == 0) + reconnect_ok = weechat_cmd_reconnect_one_server (server, no_join); + if (!reconnect_ok) return -1; @@ -3160,7 +3193,7 @@ weechat_cmd_server (t_irc_server *server, t_irc_channel *channel, { (void) gui_buffer_new (window, new_server, NULL, BUFFER_TYPE_STANDARD, 1); - irc_server_connect (new_server); + irc_server_connect (new_server, 0); } irc_server_destroy (&server_tmp); diff --git a/src/common/completion.c b/src/common/completion.c index cbd7d9ff6..0b4bb5dfe 100644 --- a/src/common/completion.c +++ b/src/common/completion.c @@ -1019,6 +1019,8 @@ completion_build_list_template (t_completion *completion, char *template) free (word); return; break; + case '*': /* repeat last completion (do nothing there) */ + break; case 'a': /* alias */ completion_list_add_alias (completion); break; @@ -1114,8 +1116,10 @@ completion_build_list_template (t_completion *completion, char *template) void completion_build_list (t_completion *completion) { - char *template, *pos_space; - int max_arg, i; + char *template, *pos_template, *pos_space; + int repeat_last, max_arg, i, length; + + repeat_last = 0; completion_get_command_infos (completion, &template, &max_arg); if (!template || (strcmp (template, "-") == 0) || @@ -1124,25 +1128,40 @@ completion_build_list (t_completion *completion) completion_stop (completion); return; } + + length = strlen (template); + if (length >= 2) + { + if (strcmp (template + length - 2, "%*") == 0) + repeat_last = 1; + } + i = 1; - while (template && template[0]) + pos_template = template; + while (pos_template && pos_template[0]) { - pos_space = strchr (template, ' '); + pos_space = strchr (pos_template, ' '); if (i == completion->base_command_arg) { - completion_build_list_template (completion, template); + completion_build_list_template (completion, pos_template); return; } if (pos_space) { - template = pos_space; - while (template[0] == ' ') - template++; + pos_template = pos_space; + while (pos_template[0] == ' ') + pos_template++; } else - template = NULL; + pos_template = NULL; i++; } + if (repeat_last) + { + pos_space = rindex (template, ' '); + completion_build_list_template (completion, + (pos_space) ? pos_space + 1 : template); + } } /* diff --git a/src/irc/irc-recv.c b/src/irc/irc-recv.c index c6686b389..193bb05f5 100644 --- a/src/irc/irc-recv.c +++ b/src/irc/irc-recv.c @@ -2446,7 +2446,7 @@ irc_recv_cmd_001 (t_irc_server *server, char *host, char *nick, char *arguments) } /* auto-join after disconnection (only rejoins opened channels) */ - if (server->reconnect_join && server->channels) + if (!server->disable_autojoin && server->reconnect_join && server->channels) { for (ptr_channel = server->channels; ptr_channel; ptr_channel = ptr_channel->next_channel) @@ -2466,7 +2466,7 @@ irc_recv_cmd_001 (t_irc_server *server, char *host, char *nick, char *arguments) else { /* auto-join when connecting to server for first time */ - if (server->autojoin && server->autojoin[0]) + if (!server->disable_autojoin && server->autojoin && server->autojoin[0]) return irc_send_cmd_join (server, NULL, server->autojoin); } @@ -2480,6 +2480,8 @@ irc_recv_cmd_001 (t_irc_server *server, char *host, char *nick, char *arguments) free (away_msg); } } + + server->disable_autojoin = 0; return 0; } diff --git a/src/irc/irc-server.c b/src/irc/irc-server.c index b5be7c329..8f6d9cce2 100644 --- a/src/irc/irc-server.c +++ b/src/irc/irc-server.c @@ -116,6 +116,7 @@ irc_server_init (t_irc_server *server) server->prefix = NULL; server->reconnect_start = 0; server->reconnect_join = 0; + server->disable_autojoin = 0; server->is_away = 0; server->away_message = NULL; server->away_time = 0; @@ -1741,7 +1742,7 @@ irc_server_child (t_irc_server *server) */ int -irc_server_connect (t_irc_server *server) +irc_server_connect (t_irc_server *server, int disable_autojoin) { int child_pipe[2], set; #ifndef __CYGWIN__ @@ -1882,6 +1883,8 @@ irc_server_connect (t_irc_server *server) server->child_pid = pid; #endif + server->disable_autojoin = disable_autojoin; + return 1; } @@ -1897,7 +1900,7 @@ irc_server_reconnect (t_irc_server *server) PACKAGE_NAME); server->reconnect_start = 0; - if (irc_server_connect (server)) + if (irc_server_connect (server, 0)) server->reconnect_join = 1; else irc_server_reconnect_schedule (server); @@ -1921,7 +1924,7 @@ irc_server_auto_connect (int auto_connect, int command_line) (void) gui_buffer_new (gui_current_window, ptr_server, NULL, BUFFER_TYPE_STANDARD, 1); gui_window_redraw_buffer (gui_current_window->buffer); - if (!irc_server_connect (ptr_server)) + if (!irc_server_connect (ptr_server, 0)) irc_server_reconnect_schedule (ptr_server); } } @@ -2244,6 +2247,7 @@ irc_server_print_log (t_irc_server *server) weechat_log_printf (" prefix. . . . . . . : '%s'\n", server->prefix); weechat_log_printf (" reconnect_start . . : %ld\n", server->reconnect_start); weechat_log_printf (" reconnect_join. . . : %d\n", server->reconnect_join); + weechat_log_printf (" disable_autojoin. . : %d\n", server->disable_autojoin); weechat_log_printf (" is_away . . . . . . : %d\n", server->is_away); weechat_log_printf (" away_message. . . . : '%s'\n", server->away_message); weechat_log_printf (" away_time . . . . . : %ld\n", server->away_time); diff --git a/src/irc/irc.h b/src/irc/irc.h index 7590e164e..3954629a4 100644 --- a/src/irc/irc.h +++ b/src/irc/irc.h @@ -184,6 +184,7 @@ struct t_irc_server char *prefix; /* nick prefix allowed (from msg 005) */ time_t reconnect_start; /* this time + delay = reconnect time */ int reconnect_join; /* 1 if channels opened to rejoin */ + int disable_autojoin; /* 1 if user asked to not autojoin chans */ int is_away; /* 1 is user is marked as away */ char *away_message; /* away message, NULL if not away */ time_t away_time; /* time() when user marking as away */ @@ -388,7 +389,7 @@ extern int irc_server_resolve (char *, char *, int *); extern int irc_server_pass_socks4proxy (int, char*, int, char*); extern int irc_server_pass_socks5proxy (int, char*, int); extern int irc_server_pass_proxy (int, char*, int, char*); -extern int irc_server_connect (t_irc_server *); +extern int irc_server_connect (t_irc_server *, int); extern void irc_server_reconnect (t_irc_server *); extern void irc_server_auto_connect (int, int); extern void irc_server_disconnect (t_irc_server *, int); diff --git a/weechat/ChangeLog b/weechat/ChangeLog index 488d3a674..e144924a5 100644 --- a/weechat/ChangeLog +++ b/weechat/ChangeLog @@ -1,10 +1,12 @@ WeeChat - Wee Enhanced Environment for Chat =========================================== -ChangeLog - 2007-07-12 +ChangeLog - 2007-07-13 Version 0.2.6 (under dev!): + * added "%*" to completion template, to repeat last completion + * added "-nojoin" option for /connect and /reconnect commands (task #7074) * fixed bugs with IRC color in messages, now color codes are inserted in command line with ^Cc,^Cb,.. instead of %C,%B,.. (bug #20222, task #7060) * fixed bug with smart nick completion (last speakers first) when a nick diff --git a/weechat/doc/de/weechat.de.xml b/weechat/doc/de/weechat.de.xml index d7c479f1b..eadfce062 100644 --- a/weechat/doc/de/weechat.de.xml +++ b/weechat/doc/de/weechat.de.xml @@ -2355,6 +2355,15 @@ msg_handler = plugin->msg_handler_add (plugin, "KICK", <entry>keine Vervollständigung für das Argument</entry> </row> <row> + <entry><literal>%*</literal></entry> + <entry> + <!-- TRANSLATION NEEDED --> + repeat last completion for all following arguments + (this code has to be at the end of completion + template, preceded by "|") + </entry> + </row> + <row> <entry><literal>%a</literal></entry> <entry>Alias</entry> </row> diff --git a/weechat/doc/de/weechat_commands.xml b/weechat/doc/de/weechat_commands.xml index c999b7533..87506cf4f 100644 --- a/weechat/doc/de/weechat_commands.xml +++ b/weechat/doc/de/weechat_commands.xml @@ -62,12 +62,13 @@ Fenster leeren Nummer: lösche den Puffer mit der angegebenen Nummer </programlisting> -<command>connect [-all | Servername [Servername ...]]</command> +<command>connect [-all [-nojoin] | [-nojoin] servername [servername ...]]</command> <programlisting> mit Server verbinden - -all: verbinde mit allen Servern -servername: Servername, mit dem verbunden werden soll + -all: connect to all servers +servername: server name to connect + -nojoin: do not join any channel (even if autojoin is enabled on server) </programlisting> <command>disconnect [-all | Servername [Servername ...]]</command> @@ -150,12 +151,13 @@ autoload: lade automatisch alle Plugins im System- oder Benutzerverzeichnis Ohne Argument, listet /plugin alle geladenen Plugins auf. </programlisting> -<command>reconnect [-all | Servername [Servername ...]]</command> +<command>reconnect [-all [-nojoin] | servername [servername ...]] [-nojoin]</command> <programlisting> mit einem Server oder mehreren Servern neu verbinden - -all: Verbinde mit allen Servern neu -servername: Servername, mit dem verbunden werden soll + -all: reconnect to all servers +servername: server name to reconnect + -nojoin: do not join any channel (even if autojoin is enabled on server) </programlisting> <command>server [Servername] | [Servername Hostname Port [-auto | -noauto] [-ipv6] [-ssl] [-pwd Passwort] [-nicks Nick1 Nick2 Nick3] [-username Benutzername] [-realname Name] [-command Befehl] [-autojoin Channel[,Channel]] ] | [del Servername]</command> diff --git a/weechat/doc/en/weechat.en.xml b/weechat/doc/en/weechat.en.xml index 764f62ff6..bffbddba9 100644 --- a/weechat/doc/en/weechat.en.xml +++ b/weechat/doc/en/weechat.en.xml @@ -2364,6 +2364,14 @@ msg_handler = plugin->msg_handler_add (plugin, "KICK", <entry>no completion for argument</entry> </row> <row> + <entry><literal>%*</literal></entry> + <entry> + repeat last completion for all following arguments + (this code has to be at the end of completion + template, preceded by "|") + </entry> + </row> + <row> <entry><literal>%a</literal></entry> <entry>alias</entry> </row> diff --git a/weechat/doc/en/weechat_commands.xml b/weechat/doc/en/weechat_commands.xml index 72bf9daa3..d93fe1b42 100644 --- a/weechat/doc/en/weechat_commands.xml +++ b/weechat/doc/en/weechat_commands.xml @@ -62,12 +62,13 @@ clear window(s) number: clear buffer by number </programlisting> -<command>connect [-all | servername [servername ...]]</command> +<command>connect [-all [-nojoin] | [-nojoin] servername [servername ...]]</command> <programlisting> connect to server(s) -all: connect to all servers servername: server name to connect + -nojoin: do not join any channel (even if autojoin is enabled on server) </programlisting> <command>disconnect [-all | servername [servername ...]]</command> @@ -149,12 +150,13 @@ autoload: autoload plugins in system or user directory Without argument, /plugin command lists loaded plugins. </programlisting> -<command>reconnect [-all | servername [servername ...]]</command> +<command>reconnect [-all [-nojoin] | servername [servername ...]] [-nojoin]</command> <programlisting> reconnect to server(s) -all: reconnect to all servers servername: server name to reconnect + -nojoin: do not join any channel (even if autojoin is enabled on server) </programlisting> <command>server [servername] | [servername hostname port [-auto | -noauto] [-ipv6] [-ssl] [-pwd password] [-nicks nick1 nick2 nick3] [-username username] [-realname realname] [-command command] [-autojoin channel[,channel]] ] | [del servername]</command> diff --git a/weechat/doc/fr/weechat.fr.xml b/weechat/doc/fr/weechat.fr.xml index 43e080ffe..4d1854df3 100644 --- a/weechat/doc/fr/weechat.fr.xml +++ b/weechat/doc/fr/weechat.fr.xml @@ -2426,6 +2426,14 @@ msg_handler = plugin->msg_handler_add (plugin, "KICK", <entry>aucune complétion pour le paramètre</entry> </row> <row> + <entry><literal>%*</literal></entry> + <entry> + répétition de la dernière complétion pour tous + les paramètres suivants (ce code doit être à la + fin du modèle de complétion, précédé d'un "|") + </entry> + </row> + <row> <entry><literal>%a</literal></entry> <entry>alias</entry> </row> diff --git a/weechat/doc/fr/weechat_commands.xml b/weechat/doc/fr/weechat_commands.xml index 460211806..b0b0d8975 100644 --- a/weechat/doc/fr/weechat_commands.xml +++ b/weechat/doc/fr/weechat_commands.xml @@ -62,12 +62,13 @@ effacer la/les fenêtre(s) nombre: effacer un tampon par son numéro </programlisting> -<command>connect [-all | nom_serveur [nom_serveur...]]</command> +<command>connect [-all [-nojoin] | [-nojoin] servername [servername ...]]</command> <programlisting> se connecter à un/plusieurs serveur(s) - -all: se connecter à tous les serveurs -nom_serveur: nom du serveur pour se connecter + -all: connect to all servers +servername: server name to connect + -nojoin: do not join any channel (even if autojoin is enabled on server) </programlisting> <command>disconnect [-all | nom_serveur [nom_serveur...]]</command> @@ -149,12 +150,13 @@ autoload: charger automatiquement les extensions dans un répertoire système ou u Sans paramètre, la commande /plugin liste les extensions chargées. </programlisting> -<command>reconnect [-all | nom_serveur [nom_serveur...]]</command> +<command>reconnect [-all [-nojoin] | servername [servername ...]] [-nojoin]</command> <programlisting> se reconnecter à un/plusieurs serveur(s) - -all: se reconnecter à tous les serveurs -nom_serveur: nom du serveur pour se reconnecter + -all: reconnect to all servers +servername: server name to reconnect + -nojoin: do not join any channel (even if autojoin is enabled on server) </programlisting> <command>server [nom_serveur] | [nom_serveur nom/IP port [-auto | -noauto] [-ipv6] [-ssl] [-pwd mot_de_passe] [-nicks pseudo1 pseudo2 pseudo3] [-username nom_utilisateur] [-realname nom_réel] [-command commande] [-autojoin canal[,canal]] ] | [del nom_serveur]</command> diff --git a/weechat/src/common/command.c b/weechat/src/common/command.c index cff08dca7..3d0152505 100644 --- a/weechat/src/common/command.c +++ b/weechat/src/common/command.c @@ -96,10 +96,11 @@ t_weechat_command weechat_commands[] = "number: clear buffer by number"), "-all", 0, 1, 0, weechat_cmd_clear, NULL }, { "connect", N_("connect to server(s)"), - N_("[-all | servername [servername ...]]"), + N_("[-all [-nojoin] | [-nojoin] servername [servername ...]]"), N_(" -all: connect to all servers\n" - "servername: server name to connect"), - "%S|-all", 0, MAX_ARGS, 0, weechat_cmd_connect, NULL }, + "servername: server name to connect\n" + " -nojoin: do not join any channel (even if autojoin is enabled on server)"), + "%S|-all|-nojoin|%*", 0, MAX_ARGS, 0, weechat_cmd_connect, NULL }, { "disconnect", N_("disconnect from server(s)"), N_("[-all | servername [servername ...]]"), N_(" -all: disconnect from all servers\n" @@ -166,10 +167,11 @@ t_weechat_command weechat_commands[] = "Without argument, /plugin command lists loaded plugins."), "list|listfull|load|autoload|reload|unload %P", 0, 2, 0, weechat_cmd_plugin, NULL }, { "reconnect", N_("reconnect to server(s)"), - N_("[-all | servername [servername ...]]"), + N_("[-all [-nojoin] | servername [servername ...]] [-nojoin]"), N_(" -all: reconnect to all servers\n" - "servername: server name to reconnect"), - "%S|-all", 0, MAX_ARGS, 0, weechat_cmd_reconnect, NULL }, + "servername: server name to reconnect\n" + " -nojoin: do not join any channel (even if autojoin is enabled on server)"), + "%S|-all|-nojoin|%*", 0, MAX_ARGS, 0, weechat_cmd_reconnect, NULL }, { "server", N_("list, add or remove servers"), N_("[servername] | " "[servername hostname port [-auto | -noauto] [-ipv6] [-ssl] [-pwd password] [-nicks nick1 " @@ -1547,7 +1549,8 @@ weechat_cmd_clear (t_irc_server *server, t_irc_channel *channel, */ int -weechat_cmd_connect_one_server (t_irc_server *server, t_gui_window *window) +weechat_cmd_connect_one_server (t_gui_window *window, t_irc_server *server, + int no_join) { if (server->is_connected) { @@ -1571,7 +1574,7 @@ weechat_cmd_connect_one_server (t_irc_server *server, t_gui_window *window) BUFFER_TYPE_STANDARD, 1)) return 0; } - if (irc_server_connect (server)) + if (irc_server_connect (server, no_join)) { server->reconnect_start = 0; server->reconnect_join = (server->channels) ? 1 : 0; @@ -1593,36 +1596,49 @@ weechat_cmd_connect (t_irc_server *server, t_irc_channel *channel, t_gui_window *window; t_gui_buffer *buffer; t_irc_server *ptr_server; - int i, connect_ok; + int i, nb_connect, connect_ok, all_servers, no_join; gui_buffer_find_context (server, channel, &window, &buffer); + + nb_connect = 0; + connect_ok = 1; - if (argc == 0) - connect_ok = weechat_cmd_connect_one_server (server, window); - else + all_servers = 0; + no_join = 0; + for (i = 0; i < argc; i++) { - connect_ok = 1; - - if (ascii_strcasecmp (argv[0], "-all") == 0) + if (ascii_strcasecmp (argv[i], "-all") == 0) + all_servers = 1; + if (ascii_strcasecmp (argv[i], "-nojoin") == 0) + no_join = 1; + } + + if (all_servers) + { + for (ptr_server = irc_servers; ptr_server; + ptr_server = ptr_server->next_server) { - for (ptr_server = irc_servers; ptr_server; - ptr_server = ptr_server->next_server) + nb_connect++; + if (!ptr_server->is_connected && (ptr_server->child_pid == 0)) { - if (!ptr_server->is_connected && (ptr_server->child_pid == 0)) - { - if (!weechat_cmd_connect_one_server (ptr_server, window)) - connect_ok = 0; - } + if (!weechat_cmd_connect_one_server (window, ptr_server, + no_join)) + connect_ok = 0; } } - else + } + else + { + for (i = 0; i < argc; i++) { - for (i = 0; i < argc; i++) + if (argv[i][0] != '-') { + nb_connect++; ptr_server = irc_server_search (argv[i]); if (ptr_server) { - if (!weechat_cmd_connect_one_server (ptr_server, window)) + if (!weechat_cmd_connect_one_server (window, ptr_server, + no_join)) connect_ok = 0; } else @@ -1636,6 +1652,9 @@ weechat_cmd_connect (t_irc_server *server, t_irc_channel *channel, } } + if (nb_connect == 0) + connect_ok = weechat_cmd_connect_one_server (window, server, no_join); + if (!connect_ok) return -1; @@ -2767,7 +2786,7 @@ weechat_cmd_plugin (t_irc_server *server, t_irc_channel *channel, */ int -weechat_cmd_reconnect_one_server (t_irc_server *server) +weechat_cmd_reconnect_one_server (t_irc_server *server, int no_join) { if ((!server->is_connected) && (server->child_pid == 0)) { @@ -2779,7 +2798,7 @@ weechat_cmd_reconnect_one_server (t_irc_server *server) } irc_send_quit_server (server, NULL); irc_server_disconnect (server, 0); - if (irc_server_connect (server)) + if (irc_server_connect (server, no_join)) { server->reconnect_start = 0; server->reconnect_join = (server->channels) ? 1 : 0; @@ -2800,36 +2819,47 @@ weechat_cmd_reconnect (t_irc_server *server, t_irc_channel *channel, { t_gui_buffer *buffer; t_irc_server *ptr_server; - int i, reconnect_ok; + int i, nb_reconnect, reconnect_ok, all_servers, no_join; - gui_buffer_find_context (server, channel, NULL, &buffer); + gui_buffer_find_context (server, channel, NULL, &buffer); - if (argc == 0) - reconnect_ok = weechat_cmd_reconnect_one_server (server); - else + nb_reconnect = 0; + reconnect_ok = 1; + + all_servers = 0; + no_join = 0; + for (i = 0; i < argc; i++) { - reconnect_ok = 1; - - if (ascii_strcasecmp (argv[0], "-all") == 0) + if (ascii_strcasecmp (argv[i], "-all") == 0) + all_servers = 1; + if (ascii_strcasecmp (argv[i], "-nojoin") == 0) + no_join = 1; + } + + if (all_servers) + { + for (ptr_server = irc_servers; ptr_server; + ptr_server = ptr_server->next_server) { - for (ptr_server = irc_servers; ptr_server; - ptr_server = ptr_server->next_server) + nb_reconnect++; + if ((ptr_server->is_connected) || (ptr_server->child_pid != 0)) { - if ((ptr_server->is_connected) || (ptr_server->child_pid != 0)) - { - if (!weechat_cmd_reconnect_one_server (ptr_server)) - reconnect_ok = 0; - } + if (!weechat_cmd_reconnect_one_server (ptr_server, no_join)) + reconnect_ok = 0; } } - else + } + else + { + for (i = 0; i < argc; i++) { - for (i = 0; i < argc; i++) + if (argv[i][0] != '-') { + nb_reconnect++; ptr_server = irc_server_search (argv[i]); if (ptr_server) { - if (!weechat_cmd_reconnect_one_server (ptr_server)) + if (!weechat_cmd_reconnect_one_server (ptr_server, no_join)) reconnect_ok = 0; } else @@ -2843,6 +2873,9 @@ weechat_cmd_reconnect (t_irc_server *server, t_irc_channel *channel, } } + if (nb_reconnect == 0) + reconnect_ok = weechat_cmd_reconnect_one_server (server, no_join); + if (!reconnect_ok) return -1; @@ -3160,7 +3193,7 @@ weechat_cmd_server (t_irc_server *server, t_irc_channel *channel, { (void) gui_buffer_new (window, new_server, NULL, BUFFER_TYPE_STANDARD, 1); - irc_server_connect (new_server); + irc_server_connect (new_server, 0); } irc_server_destroy (&server_tmp); diff --git a/weechat/src/common/completion.c b/weechat/src/common/completion.c index cbd7d9ff6..0b4bb5dfe 100644 --- a/weechat/src/common/completion.c +++ b/weechat/src/common/completion.c @@ -1019,6 +1019,8 @@ completion_build_list_template (t_completion *completion, char *template) free (word); return; break; + case '*': /* repeat last completion (do nothing there) */ + break; case 'a': /* alias */ completion_list_add_alias (completion); break; @@ -1114,8 +1116,10 @@ completion_build_list_template (t_completion *completion, char *template) void completion_build_list (t_completion *completion) { - char *template, *pos_space; - int max_arg, i; + char *template, *pos_template, *pos_space; + int repeat_last, max_arg, i, length; + + repeat_last = 0; completion_get_command_infos (completion, &template, &max_arg); if (!template || (strcmp (template, "-") == 0) || @@ -1124,25 +1128,40 @@ completion_build_list (t_completion *completion) completion_stop (completion); return; } + + length = strlen (template); + if (length >= 2) + { + if (strcmp (template + length - 2, "%*") == 0) + repeat_last = 1; + } + i = 1; - while (template && template[0]) + pos_template = template; + while (pos_template && pos_template[0]) { - pos_space = strchr (template, ' '); + pos_space = strchr (pos_template, ' '); if (i == completion->base_command_arg) { - completion_build_list_template (completion, template); + completion_build_list_template (completion, pos_template); return; } if (pos_space) { - template = pos_space; - while (template[0] == ' ') - template++; + pos_template = pos_space; + while (pos_template[0] == ' ') + pos_template++; } else - template = NULL; + pos_template = NULL; i++; } + if (repeat_last) + { + pos_space = rindex (template, ' '); + completion_build_list_template (completion, + (pos_space) ? pos_space + 1 : template); + } } /* diff --git a/weechat/src/irc/irc-recv.c b/weechat/src/irc/irc-recv.c index c6686b389..193bb05f5 100644 --- a/weechat/src/irc/irc-recv.c +++ b/weechat/src/irc/irc-recv.c @@ -2446,7 +2446,7 @@ irc_recv_cmd_001 (t_irc_server *server, char *host, char *nick, char *arguments) } /* auto-join after disconnection (only rejoins opened channels) */ - if (server->reconnect_join && server->channels) + if (!server->disable_autojoin && server->reconnect_join && server->channels) { for (ptr_channel = server->channels; ptr_channel; ptr_channel = ptr_channel->next_channel) @@ -2466,7 +2466,7 @@ irc_recv_cmd_001 (t_irc_server *server, char *host, char *nick, char *arguments) else { /* auto-join when connecting to server for first time */ - if (server->autojoin && server->autojoin[0]) + if (!server->disable_autojoin && server->autojoin && server->autojoin[0]) return irc_send_cmd_join (server, NULL, server->autojoin); } @@ -2480,6 +2480,8 @@ irc_recv_cmd_001 (t_irc_server *server, char *host, char *nick, char *arguments) free (away_msg); } } + + server->disable_autojoin = 0; return 0; } diff --git a/weechat/src/irc/irc-server.c b/weechat/src/irc/irc-server.c index b5be7c329..8f6d9cce2 100644 --- a/weechat/src/irc/irc-server.c +++ b/weechat/src/irc/irc-server.c @@ -116,6 +116,7 @@ irc_server_init (t_irc_server *server) server->prefix = NULL; server->reconnect_start = 0; server->reconnect_join = 0; + server->disable_autojoin = 0; server->is_away = 0; server->away_message = NULL; server->away_time = 0; @@ -1741,7 +1742,7 @@ irc_server_child (t_irc_server *server) */ int -irc_server_connect (t_irc_server *server) +irc_server_connect (t_irc_server *server, int disable_autojoin) { int child_pipe[2], set; #ifndef __CYGWIN__ @@ -1882,6 +1883,8 @@ irc_server_connect (t_irc_server *server) server->child_pid = pid; #endif + server->disable_autojoin = disable_autojoin; + return 1; } @@ -1897,7 +1900,7 @@ irc_server_reconnect (t_irc_server *server) PACKAGE_NAME); server->reconnect_start = 0; - if (irc_server_connect (server)) + if (irc_server_connect (server, 0)) server->reconnect_join = 1; else irc_server_reconnect_schedule (server); @@ -1921,7 +1924,7 @@ irc_server_auto_connect (int auto_connect, int command_line) (void) gui_buffer_new (gui_current_window, ptr_server, NULL, BUFFER_TYPE_STANDARD, 1); gui_window_redraw_buffer (gui_current_window->buffer); - if (!irc_server_connect (ptr_server)) + if (!irc_server_connect (ptr_server, 0)) irc_server_reconnect_schedule (ptr_server); } } @@ -2244,6 +2247,7 @@ irc_server_print_log (t_irc_server *server) weechat_log_printf (" prefix. . . . . . . : '%s'\n", server->prefix); weechat_log_printf (" reconnect_start . . : %ld\n", server->reconnect_start); weechat_log_printf (" reconnect_join. . . : %d\n", server->reconnect_join); + weechat_log_printf (" disable_autojoin. . : %d\n", server->disable_autojoin); weechat_log_printf (" is_away . . . . . . : %d\n", server->is_away); weechat_log_printf (" away_message. . . . : '%s'\n", server->away_message); weechat_log_printf (" away_time . . . . . : %ld\n", server->away_time); diff --git a/weechat/src/irc/irc.h b/weechat/src/irc/irc.h index 7590e164e..3954629a4 100644 --- a/weechat/src/irc/irc.h +++ b/weechat/src/irc/irc.h @@ -184,6 +184,7 @@ struct t_irc_server char *prefix; /* nick prefix allowed (from msg 005) */ time_t reconnect_start; /* this time + delay = reconnect time */ int reconnect_join; /* 1 if channels opened to rejoin */ + int disable_autojoin; /* 1 if user asked to not autojoin chans */ int is_away; /* 1 is user is marked as away */ char *away_message; /* away message, NULL if not away */ time_t away_time; /* time() when user marking as away */ @@ -388,7 +389,7 @@ extern int irc_server_resolve (char *, char *, int *); extern int irc_server_pass_socks4proxy (int, char*, int, char*); extern int irc_server_pass_socks5proxy (int, char*, int); extern int irc_server_pass_proxy (int, char*, int, char*); -extern int irc_server_connect (t_irc_server *); +extern int irc_server_connect (t_irc_server *, int); extern void irc_server_reconnect (t_irc_server *); extern void irc_server_auto_connect (int, int); extern void irc_server_disconnect (t_irc_server *, int); |