Woojong Koh avatar Woojong Koh committed 79dc955

Update WeeChat plugins and move irc.conf to Dropbox directory

Comments (0)

Files changed (20)

 tags
 
 .vim/tmp/
+.weechat/irc.conf
 .weechat/logs/
 .weechat/weechat.log
 be5842a376f16c16c5dc4cc1879d7168a074f7de .vim/bundle/ctrlp.vim
 1e5658c6d9575cd34be32d0227e06f07c9d58a2e .vim/bundle/grep.vim
 8c570a493d260890242cbdc5a22d8500dc4604cb .vim/bundle/gundo.vim
-a1433c485eb254838c1db52e087d5ec4d1e77cfd .vim/bundle/nerdtree
+bf79e223aefe0665bcc62b5dcc4c2c23c6f23fc5 .vim/bundle/nerdtree
 e877c7e3e249e5784fcee8feaff7f1a8799335a1 .vim/bundle/python-mode
 f5a75d075d3c005ebe69e3f5e56cf99516e8aa3b .vim/bundle/snipmate.vim
-2ad1437af7224629677231f8830b1ee204b91e40 .vim/bundle/syntastic
+2e7d73305b70a456abb20b1754e094cccfefa3d3 .vim/bundle/syntastic
 568ef5fd25468a58723b50cf40a48c5dcb46c802 .vim/bundle/tagbar
 53041fbc45398a9af631a20657e109707a455339 .vim/bundle/taglist.vim
 13fe3d8064647e2cdf07e12840108c3f917f5636 .vim/bundle/vim-autocomplpop

.weechat/alias.conf

 #
-# alias.conf -- WeeChat v0.3.6
+# alias.conf -- WeeChat v0.3.8
 #
 
 [cmd]

.weechat/aspell.conf

 #
-# aspell.conf -- WeeChat v0.3.6
+# aspell.conf -- WeeChat v0.3.8
 #
 
 [look]

.weechat/buffers.conf

 #
-# buffers.conf -- WeeChat v0.3.6
+# buffers.conf -- WeeChat v0.3.8
 #
 
 [color]
 
 [look]
 core_to_front = off
-hide_merged_buffers = off
+detach = 0
+hide_merged_buffers = none
+immune_detach_buffers = ""
 indenting = off
 indenting_number = on
 jump_prev_next_visited_buffer = off
+name_crop_suffix = "+"
+name_size_max = 0
 number_char = "."
 prefix = off
 prefix_empty = on
 short_names = on
+show_lag = off
 show_number = on
 sort = number
 whitelist_buffers = ""

.weechat/charset.conf

 #
-# charset.conf -- WeeChat v0.3.6
+# charset.conf -- WeeChat v0.3.8
 #
 
 [default]

.weechat/irc.conf

-#
-# irc.conf -- WeeChat v0.3.6
-#
-
-[look]
-buffer_switch_autojoin = on
-buffer_switch_join = on
-color_nicks_in_names = off
-color_nicks_in_nicklist = off
-color_nicks_in_server_messages = on
-color_pv_nick_like_channel = on
-display_away = local
-display_ctcp_blocked = on
-display_ctcp_reply = on
-display_ctcp_unknown = on
-display_host_join = on
-display_host_join_local = on
-display_host_quit = on
-display_old_topic = on
-display_pv_away_once = on
-display_pv_back = on
-hide_nickserv_pwd = on
-highlight_tags = "irc_privmsg,irc_notice"
-item_away_message = on
-item_channel_modes = on
-item_channel_modes_hide_key = off
-item_display_server = buffer_plugin
-item_nick_modes = on
-item_nick_prefix = on
-msgbuffer_fallback = current
-new_channel_position = none
-new_pv_position = none
-nick_color_force = ""
-nick_color_stop_chars = "_|["
-nick_completion_smart = speakers
-nick_prefix = ""
-nick_suffix = ""
-notice_as_pv = auto
-notify_tags_ison = "notify_message"
-notify_tags_whois = "notify_message"
-part_closes_buffer = off
-raw_messages = 256
-server_buffer = merge_with_core
-smart_filter = on
-smart_filter_delay = 5
-smart_filter_join = on
-smart_filter_nick = on
-smart_filter_quit = on
-topic_strip_colors = off
-
-[color]
-input_nick = lightcyan
-item_away = yellow
-item_channel_modes = default
-item_lag_counting = default
-item_lag_finished = yellow
-message_join = green
-message_quit = red
-nick_prefix = green
-nick_prefixes = "q:lightred;a:lightcyan;o:lightgreen;h:lightmagenta;v:yellow;*:lightblue"
-nick_suffix = green
-notice = green
-reason_quit = default
-topic_new = white
-topic_old = darkgray
-
-[network]
-autoreconnect_delay_growing = 2
-autoreconnect_delay_max = 1800
-colors_receive = on
-colors_send = on
-lag_check = 60
-lag_disconnect = 0
-lag_min_show = 500
-lag_refresh_interval = 1
-notify_check_ison = 1
-notify_check_whois = 5
-send_unknown_commands = off
-
-[msgbuffer]
-
-[ctcp]
-
-[ignore]
-
-[server_default]
-addresses = ""
-anti_flood_prio_high = 2
-anti_flood_prio_low = 2
-autoconnect = off
-autojoin = ""
-autoreconnect = on
-autoreconnect_delay = 10
-autorejoin = off
-autorejoin_delay = 30
-away_check = 0
-away_check_max_nicks = 25
-command = ""
-command_delay = 0
-connection_timeout = 60
-default_msg_part = "WeeChat %v"
-default_msg_quit = "WeeChat %v"
-ipv6 = off
-local_hostname = ""
-nicks = "wjkoh,wjkoh1,wjkoh2,wjkoh3,wjkoh4"
-notify = ""
-password = ""
-proxy = ""
-realname = ""
-sasl_mechanism = plain
-sasl_password = ""
-sasl_timeout = 15
-sasl_username = ""
-ssl = off
-ssl_cert = ""
-ssl_dhkey_size = 2048
-ssl_priorities = "NORMAL"
-ssl_verify = on
-username = "wjkoh"
-
-[server]
-freenode.addresses = "chat.freenode.net/6667"
-freenode.proxy
-freenode.ipv6
-freenode.ssl
-freenode.ssl_cert
-freenode.ssl_priorities
-freenode.ssl_dhkey_size
-freenode.ssl_verify
-freenode.password
-freenode.sasl_mechanism
-freenode.sasl_username
-freenode.sasl_password
-freenode.sasl_timeout
-freenode.autoconnect
-freenode.autoreconnect
-freenode.autoreconnect_delay
-freenode.nicks
-freenode.username
-freenode.realname
-freenode.local_hostname
-freenode.command
-freenode.command_delay
-freenode.autojoin
-freenode.autorejoin
-freenode.autorejoin_delay
-freenode.connection_timeout
-freenode.anti_flood_prio_high
-freenode.anti_flood_prio_low
-freenode.away_check
-freenode.away_check_max_nicks
-freenode.default_msg_part
-freenode.default_msg_quit
-freenode.notify

.weechat/irc.conf.orig

+#
+# irc.conf -- WeeChat v0.3.8
+#
+
+[look]
+buffer_switch_autojoin = on
+buffer_switch_join = on
+color_nicks_in_names = off
+color_nicks_in_nicklist = off
+color_nicks_in_server_messages = on
+color_pv_nick_like_channel = on
+display_away = local
+display_ctcp_blocked = on
+display_ctcp_reply = on
+display_ctcp_unknown = on
+display_host_join = on
+display_host_join_local = on
+display_host_quit = on
+display_old_topic = on
+display_pv_away_once = on
+display_pv_back = on
+hide_nickserv_pwd = on
+highlight_channel = "$nick"
+highlight_pv = "$nick"
+highlight_server = "$nick"
+highlight_tags = "irc_privmsg,irc_notice"
+item_away_message = on
+item_channel_modes = on
+item_channel_modes_hide_key = off
+item_display_server = buffer_plugin
+item_nick_modes = on
+item_nick_prefix = on
+msgbuffer_fallback = current
+new_channel_position = none
+new_pv_position = none
+nick_color_force = ""
+nick_color_stop_chars = "_|["
+nick_completion_smart = speakers
+nick_prefix = ""
+nick_suffix = ""
+notice_as_pv = auto
+notify_tags_ison = "notify_message"
+notify_tags_whois = "notify_message"
+part_closes_buffer = off
+raw_messages = 256
+server_buffer = merge_with_core
+smart_filter = on
+smart_filter_delay = 5
+smart_filter_join = on
+smart_filter_nick = on
+smart_filter_quit = on
+topic_strip_colors = off
+
+[color]
+input_nick = lightcyan
+item_away = yellow
+item_channel_modes = default
+item_lag_counting = default
+item_lag_finished = yellow
+message_join = green
+message_quit = red
+mirc_remap = "1,-1:darkgray"
+nick_prefix = green
+nick_prefixes = "q:lightred;a:lightcyan;o:lightgreen;h:lightmagenta;v:yellow;*:lightblue"
+nick_suffix = green
+notice = green
+reason_quit = default
+topic_new = white
+topic_old = darkgray
+
+[network]
+autoreconnect_delay_growing = 2
+autoreconnect_delay_max = 1800
+colors_receive = on
+colors_send = on
+lag_check = 60
+lag_disconnect = 0
+lag_min_show = 500
+lag_refresh_interval = 1
+notify_check_ison = 1
+notify_check_whois = 5
+send_unknown_commands = off
+
+[msgbuffer]
+
+[ctcp]
+
+[ignore]
+
+[server_default]
+addresses = ""
+anti_flood_prio_high = 2
+anti_flood_prio_low = 2
+autoconnect = off
+autojoin = ""
+autoreconnect = on
+autoreconnect_delay = 10
+autorejoin = off
+autorejoin_delay = 30
+away_check = 0
+away_check_max_nicks = 25
+capabilities = ""
+command = ""
+command_delay = 0
+connection_timeout = 60
+default_msg_part = "WeeChat %v"
+default_msg_quit = "WeeChat %v"
+ipv6 = off
+local_hostname = ""
+nicks = "wjkoh,wjkoh1,wjkoh2,wjkoh3,wjkoh4"
+notify = ""
+password = ""
+proxy = ""
+realname = ""
+sasl_mechanism = plain
+sasl_password = ""
+sasl_timeout = 15
+sasl_username = ""
+ssl = off
+ssl_cert = ""
+ssl_dhkey_size = 2048
+ssl_priorities = "NORMAL"
+ssl_verify = on
+username = "wjkoh"
+
+[server]
+freenode.addresses = "chat.freenode.net/6667"
+freenode.proxy
+freenode.ipv6
+freenode.ssl
+freenode.ssl_cert
+freenode.ssl_priorities
+freenode.ssl_dhkey_size
+freenode.ssl_verify
+freenode.password
+freenode.capabilities
+freenode.sasl_mechanism
+freenode.sasl_username
+freenode.sasl_password
+freenode.sasl_timeout
+freenode.autoconnect
+freenode.autoreconnect
+freenode.autoreconnect_delay
+freenode.nicks
+freenode.username
+freenode.realname
+freenode.local_hostname
+freenode.command
+freenode.command_delay
+freenode.autojoin = ""
+freenode.autorejoin
+freenode.autorejoin_delay
+freenode.connection_timeout
+freenode.anti_flood_prio_high
+freenode.anti_flood_prio_low
+freenode.away_check
+freenode.away_check_max_nicks
+freenode.default_msg_part
+freenode.default_msg_quit
+freenode.notify

.weechat/logger.conf

 #
-# logger.conf -- WeeChat v0.3.6
+# logger.conf -- WeeChat v0.3.8
 #
 
 [look]
 backlog = 20
 
+[color]
+backlog_end = darkgray
+backlog_line = darkgray
+
 [file]
 auto_log = on
 flush_delay = 120

.weechat/perl/buffers.pl

 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
 #
 #
 # Display sidebar with list of buffers.
 #
 # History:
-# 2012-01-08, Nils G <weechatter@arcor.de>:
-#     2.8: fix indenting for option "show_number off"
-#          fix unset of buffer activity in hotlist when buffer was moved with mouse
-#          add buffer with free content and core buffer sorted first (suggested  by nyuszika7h)
-#          add options queries_default_fg/bg and queries_message_fg/bg (suggested by FiXato)
-#          add clicking with left button on current buffer will do a jump_previously_visited_buffer (suggested by FiXato)
-#          add clicking with right button on current buffer will do a jump_next_visited_buffer
-#          add additional informations in help texts
-#          add default_fg and default_bg for whitelist channels
-#          internal changes  (script is now 3Kb smaller)
+#
+# 2012-06-02, nils_2 <weechatter@arcor.de>:
+#     v3.5: add values "server|channel|private|all|keepserver|none" to option "hide_merged_buffers" (suggested by dominikh).
+# 2012-05-25, nils_2 <weechatter@arcor.de>:
+#     v3.4: add new option "show_lag".
+# 2012-04-07, Sebastien Helleu <flashcode@flashtux.org>:
+#     v3.3: fix truncation of wide chars in buffer name (option name_size_max) (bug #36034)
+# 2012-03-15, nils_2 <weechatter@arcor.de>:
+#     v3.2: add new option "detach"(weechat >= 0.3.8)
+#           add new option "immune_detach_buffers" (requested by Mkaysi)
+#           add new function buffers_whitelist add|del|reset (suggested by FiXato)
+#           add new function buffers_detach add|del|reset
+# 2012-03-09, Sebastien Helleu <flashcode@flashtux.org>:
+#     v3.1: fix reload of config file
+# 2012-01-29, nils_2 <weechatter@arcor.de>:
+#     v3.0: fix: buffers did not update directly during window_switch (reported by FiXato)
+# 2012-01-29, nils_2 <weechatter@arcor.de>:
+#     v2.9: add options "name_size_max" and "name_crop_suffix"
+# 2012-01-08, nils_2 <weechatter@arcor.de>:
+#     v2.8: fix indenting for option "show_number off"
+#           fix unset of buffer activity in hotlist when buffer was moved with mouse
+#           add buffer with free content and core buffer sorted first (suggested  by nyuszika7h)
+#           add options queries_default_fg/bg and queries_message_fg/bg (suggested by FiXato)
+#           add clicking with left button on current buffer will do a jump_previously_visited_buffer (suggested by FiXato)
+#           add clicking with right button on current buffer will do a jump_next_visited_buffer
+#           add additional informations in help texts
+#           add default_fg and default_bg for whitelist channels
+#           internal changes  (script is now 3Kb smaller)
 # 2012-01-04, Sebastien Helleu <flashcode@flashtux.org>:
-#     2.7: fix regex lookup in whitelist buffers list
-# 2011-12-04, Nils G <weechatter@arcor.de>:
-#     2.6: add own config file (buffers.conf)
-#          add new behavior for indenting (under_name)
-#          add new option to set different color for server buffers and buffers with free content
-# 2011-10-30, Nils G <weechatter@arcor.de>:
-#     2.5: add new options "show_number_char" and "color_number_char",
-#          add help-description for options
+#     v2.7: fix regex lookup in whitelist buffers list
+# 2011-12-04, nils_2 <weechatter@arcor.de>:
+#     v2.6: add own config file (buffers.conf)
+#           add new behavior for indenting (under_name)
+#           add new option to set different color for server buffers and buffers with free content
+# 2011-10-30, nils_2 <weechatter@arcor.de>:
+#     v2.5: add new options "show_number_char" and "color_number_char",
+#           add help-description for options
 # 2011-08-24, Sebastien Helleu <flashcode@flashtux.org>:
 #     v2.4: add mouse support
-# 2011-06-06, Nils G <weechatter@arcor.de>:
+# 2011-06-06, nils_2 <weechatter@arcor.de>:
 #     v2.3: added: missed option "color_whitelist_default"
 # 2011-03-23, Sebastien Helleu <flashcode@flashtux.org>:
 #     v2.2: fix color of nick prefix with WeeChat >= 0.3.5
-# 2011-02-13, Nils G <weechatter@arcor.de>:
+# 2011-02-13, nils_2 <weechatter@arcor.de>:
 #     v2.1: add options "color_whitelist_*"
 # 2010-10-05, Sebastien Helleu <flashcode@flashtux.org>:
 #     v2.0: add options "sort" and "show_number"
 #
 
 use strict;
+use Encode qw( decode encode );
 # -------------------------------[ internal ]-------------------------------------
-my $version = "2.8";
+my $version = "3.5";
 
 my $BUFFERS_CONFIG_FILE_NAME = "buffers";
 my $buffers_config_file;
+my $cmd_buffers_whitelist= "buffers_whitelist";
+my $cmd_buffers_detach   = "buffers_detach";
 
-my %mouse_keys = ("\@item(buffers):button1*"    => "hsignal:buffers_mouse",     # catch all left mouse button gestures
-                  "\@item(buffers):button2"     => "hsignal:buffers_mouse");    # catch right mouse button
+my %mouse_keys          = ("\@item(buffers):button1*"    => "hsignal:buffers_mouse",     # catch all left mouse button gestures
+                           "\@item(buffers):button2"     => "hsignal:buffers_mouse");    # catch right mouse button
 my %options;
-my %hotlist_level = (0 => "low", 1 => "message", 2 => "private", 3 => "highlight");
-my @whitelist_buffers = "";
-my @buffers_focus = ();
+my %hotlist_level       = (0 => "low", 1 => "message", 2 => "private", 3 => "highlight");
+my @whitelist_buffers   = ();
+my @immune_detach_buffers= ();
+my @buffers_focus       = ();
+my %buffers_timer       = ();
+my %Hooks               = ();
 
 # --------------------------------[ init ]--------------------------------------
 weechat::register("buffers", "Sebastien Helleu <flashcode\@flashtux.org>", $version,
                  "vertical", "0", "0", "default", "default", "default", "1",
                  "buffers");
 weechat::hook_signal("buffer_*", "buffers_signal_buffer", "");
+weechat::hook_signal("window_switch", "buffers_signal_buffer", "");
 weechat::hook_signal("hotlist_*", "buffers_signal_hotlist", "");
 weechat::bar_item_update("buffers");
 if ($weechat_version >= 0x00030600)
     weechat::key_bind("mouse", \%mouse_keys);
 }
 
+weechat::hook_command(  $cmd_buffers_whitelist,
+                        "add/del current buffer to/from buffers whitelist",
+                        "[add] || [del] || [reset]",
+
+                        "  add: add current buffer in configuration file\n".
+                        "  del: delete current buffer from configuration file\n".
+                        "reset: reset all buffers from configuration file (no confirmation!)\n\n".
+                        "Examples:\n".
+                        "/$cmd_buffers_whitelist add\n",
+                        "add %-||".
+                        "del %-||".
+                        "reset %-",
+                        "buffers_cmd_whitelist", "");
+
+weechat::hook_command(  $cmd_buffers_detach,
+                        "add/del current buffer to/from buffers detach",
+                        "[add] || [del] || [reset]",
+
+                        "  add: add current buffer in configuration file\n".
+                        "  del: delete current buffer from configuration file\n".
+                        "reset: reset all buffers from configuration file (no confirmation!)\n\n".
+                        "Examples:\n".
+                        "/$cmd_buffers_detach add\n",
+                        "add %-||".
+                        "del %-||".
+                        "reset %-",
+                        "buffers_cmd_detach", "");
+
+if ($weechat_version >= 0x00030800)
+{
+    weechat::hook_config("buffers.look.detach", "hook_timer_detach", "");
+}
+
+    weechat::hook_config("buffers.look.show_lag", "hook_timer_lag", "");
+
+# -------------------------------- [ command ] --------------------------------
+sub buffers_cmd_whitelist
+{
+my ( $data, $buffer, $args ) = @_;
+    $args = lc($args);
+    my $buffers_whitelist = weechat::config_string( weechat::config_get("buffers.look.whitelist_buffers") );
+    return weechat::WEECHAT_RC_OK if ( $buffers_whitelist eq "" and $args eq "del" or $buffers_whitelist eq "" and $args eq "reset" );
+    my @buffers_list = split( /,/, $buffers_whitelist );
+    # get buffers name
+    my $infolist = weechat::infolist_get("buffer", weechat::current_buffer(), "");
+    weechat::infolist_next($infolist);
+    my $buffers_name = weechat::infolist_string($infolist, "name");
+    weechat::infolist_free($infolist);
+    return weechat::WEECHAT_RC_OK if ( $buffers_name eq "" );                   # should never happen
+
+    if ( $args eq "add" )
+    {
+        return weechat::WEECHAT_RC_OK if ( grep /^$buffers_name$/, @buffers_list );     # check if buffer already in list
+        push @buffers_list,( $buffers_name );
+        my $buffers_list = &create_whitelist(\@buffers_list);
+        weechat::config_option_set( weechat::config_get("buffers.look.whitelist_buffers"), $buffers_list,1 );
+        weechat::print(weechat::current_buffer(), "buffer \"$buffers_name\" added to buffers whitelist");
+    }
+    elsif ( $args eq "del" )
+    {
+        return weechat::WEECHAT_RC_OK unless ( grep /^$buffers_name$/, @buffers_list );     # check if buffer is in list
+        @buffers_list = grep {$_ ne $buffers_name} @buffers_list;                           # delete entry
+        my $buffers_list = &create_whitelist(\@buffers_list);
+        weechat::config_option_set( weechat::config_get("buffers.look.whitelist_buffers"), $buffers_list,1 );
+        weechat::print(weechat::current_buffer(), "buffer \"$buffers_name\" deleted from buffers whitelist");
+    }
+    elsif ( $args eq "reset" )
+    {
+        return weechat::WEECHAT_RC_OK if ( $buffers_whitelist eq "" );
+        weechat::config_option_set( weechat::config_get("buffers.look.whitelist_buffers"), "",1 );
+        weechat::print(weechat::current_buffer(), "buffers whitelist is empty, now...");
+    }
+    return weechat::WEECHAT_RC_OK;
+}
+sub buffers_cmd_detach
+{
+my ( $data, $buffer, $args ) = @_;
+    $args = lc($args);
+    my $immune_detach_buffers = weechat::config_string( weechat::config_get("buffers.look.immune_detach_buffers") );
+    return weechat::WEECHAT_RC_OK if ( $immune_detach_buffers eq "" and $args eq "del" or $immune_detach_buffers eq "" and $args eq "reset" );
+    my @buffers_list = split( /,/, $immune_detach_buffers );
+    # get buffers name
+    my $infolist = weechat::infolist_get("buffer", weechat::current_buffer(), "");
+    weechat::infolist_next($infolist);
+    my $buffers_name = weechat::infolist_string($infolist, "name");
+    weechat::infolist_free($infolist);
+    return weechat::WEECHAT_RC_OK if ( $buffers_name eq "" );                   # should never happen
+
+    if ( $args eq "add" )
+    {
+        return weechat::WEECHAT_RC_OK if ( grep /^$buffers_name$/, @buffers_list );     # check if buffer already in list
+        push @buffers_list,( $buffers_name );
+        my $buffers_list = &create_whitelist(\@buffers_list);
+        weechat::config_option_set( weechat::config_get("buffers.look.immune_detach_buffers"), $buffers_list,1 );
+        weechat::print(weechat::current_buffer(), "buffer \"$buffers_name\" added to immune detach buffers");
+    }
+    elsif ( $args eq "del" )
+    {
+        return weechat::WEECHAT_RC_OK unless ( grep /^$buffers_name$/, @buffers_list );     # check if buffer is in list
+        @buffers_list = grep {$_ ne $buffers_name} @buffers_list;                           # delete entry
+        my $buffers_list = &create_whitelist(\@buffers_list);
+        weechat::config_option_set( weechat::config_get("buffers.look.immune_detach_buffers"), $buffers_list,1 );
+        weechat::print(weechat::current_buffer(), "buffer \"$buffers_name\" deleted from immune detach buffers");
+    }
+    elsif ( $args eq "reset" )
+    {
+        return weechat::WEECHAT_RC_OK if ( $immune_detach_buffers eq "" );
+        weechat::config_option_set( weechat::config_get("buffers.look.immune_detach_buffers"), "",1 );
+        weechat::print(weechat::current_buffer(), "immune detach buffers is empty, now...");
+    }
+    return weechat::WEECHAT_RC_OK;
+}
+sub create_whitelist
+{
+    my @buffers_list = @{$_[0]};
+    my $buffers_list = "";
+        foreach (@buffers_list)
+        {
+            $buffers_list .= $_ .",";
+        }
+        chop $buffers_list;                                                               # remove last ","
+    return $buffers_list;
+}
+
 # -------------------------------- [ config ] --------------------------------
+sub hook_timer_detach
+{
+    my $detach = $_[2];
+    if ( $detach eq 0 )
+    {
+        weechat::unhook($Hooks{timer_detach}) if $Hooks{timer_detach};
+        $Hooks{timer_detach} = "";
+    }
+    else
+    {
+        weechat::unhook($Hooks{timer_detach}) if $Hooks{timer_detach};
+        $Hooks{timer_detach} = weechat::hook_timer( weechat::config_integer( $options{"detach"}) * 1000, 60, 0, "buffers_signal_buffer", "");
+    }
+    weechat::bar_item_update("buffers");
+    return weechat::WEECHAT_RC_OK;
+}
+
+sub hook_timer_lag
+{
+    my $lag = $_[2];
+    if ( $lag eq 0 )
+    {
+        weechat::unhook($Hooks{timer_lag}) if $Hooks{timer_lag};
+        $Hooks{timer_lag} = "";
+    }
+    else
+    {
+        weechat::unhook($Hooks{timer_lag}) if $Hooks{timer_lag};
+        $Hooks{timer_lag} = weechat::hook_timer( weechat::config_integer(weechat::config_get("irc.network.lag_refresh_interval")) * 1000, 0, 0, "buffers_signal_hotlist", "");
+    }
+    weechat::bar_item_update("buffers");
+    return weechat::WEECHAT_RC_OK;
+}
+
 sub buffers_config_read
 {
     return weechat::config_read($buffers_config_file) if ($buffers_config_file ne "");
 sub buffers_config_reload_cb
 {
     my ($data,$config_file) = ($_[0], $_[1]);
-    return weechat::config_read($config_file)
+    return weechat::config_reload($config_file)
 }
 sub buffers_config_init
 {
 
 my %default_options_look =
 (
- "color_whitelist_buffers" => ["whitelist_buffers", "string", "comma separated list of buffers for using a differnt color scheme (for example: freenode.#weechat,freenode.#weechat-fr)", "", 0, 0,"", "", 0, "", "", "buffers_signal_config_whitelist", "", "", ""],
-
- "hide_merged_buffers" => ["hide_merged_buffers", "boolean", "hide merged buffers", "", 0, 0,"off", "off", 0, "", "", "buffers_signal_config", "", "", ""],
- "indenting" => ["indenting", "integer", "use indenting for channel and query buffers. This option only takes effect if bar is left/right positioned", "off|on|under_name", 0, 0,"off", "off", 0, "", "", "buffers_signal_config", "", "", ""],
- "indenting_number" => ["indenting_number", "boolean", "use indenting for numbers. This option only takes effect if bar is left/right positioned", "", 0, 0,"on", "on", 0, "", "", "buffers_signal_config", "", "", ""],
- "short_names" => ["short_names", "boolean", "display short names (remove text before first \".\" in buffer name)", "", 0, 0,"on", "on", 0, "", "", "buffers_signal_config", "", "", ""],
- "show_number" => ["show_number", "boolean", "display channel number in front of buffername", "", 0, 0,"on", "on", 0, "", "", "buffers_signal_config", "", "", ""],
- "show_number_char" => ["number_char", "string", "display a char after channel number", "", 0, 0,".", ".", 0, "", "", "buffers_signal_config", "", "", ""],
- "show_prefix" => ["prefix", "boolean", "show your prefix for channel", "", 0, 0,"off", "off", 0, "", "", "buffers_signal_config", "", "", ""],
- "show_prefix_empty" => ["prefix_empty", "boolean", "use a placeholder for channels without prefix", "", 0, 0,"on", "on", 0, "", "", "buffers_signal_config", "", "", ""],
- "sort" => ["sort", "integer", "sort buffer-list by \"number\" or \"name\"", "number|name", 0, 0,"number", "number", 0, "", "", "buffers_signal_config", "", "", ""],
- "core_to_front" => ["core_to_front", "boolean", "core buffer and buffers with free content will be listed first. Take only effect if buffer sort is by name", "", 0, 0,"off", "off", 0, "", "", "buffers_signal_config", "", "", ""],
+ "show_lag"             =>      ["show_lag","boolean","show lag behind servername. This option is using \"irc.color.item_lag_finished\", \"irc.network.lag_min_show\" and \"irc.network.lag_refresh_interval\"","",0,0,"off","off",0,"","","buffers_signal_config","","",""],
+ "look_whitelist_buffers" =>    ["whitelist_buffers", "string", "comma separated list of buffers for using a differnt color scheme (for example: freenode.#weechat,freenode.#weechat-fr)", "", 0, 0,"", "", 0, "", "", "buffers_signal_config_whitelist", "", "", ""],
+ "hide_merged_buffers"  =>      ["hide_merged_buffers", "integer", "hide merged buffers. The value determines which merged buffers should be hidden, keepserver meaning 'all except server buffers'. Other values correspondent to the buffer type.", "server|channel|private|keepserver|all|none", 0, 0,"none", "none", 0, "", "", "buffers_signal_config", "", "", ""],
+ "indenting"            =>      ["indenting", "integer", "use indenting for channel and query buffers. This option only takes effect if bar is left/right positioned", "off|on|under_name", 0, 0,"off", "off", 0, "", "", "buffers_signal_config", "", "", ""],
+ "indenting_number"     =>      ["indenting_number", "boolean", "use indenting for numbers. This option only takes effect if bar is left/right positioned", "", 0, 0,"on", "on", 0, "", "", "buffers_signal_config", "", "", ""],
+ "short_names"          =>      ["short_names", "boolean", "display short names (remove text before first \".\" in buffer name)", "", 0, 0,"on", "on", 0, "", "", "buffers_signal_config", "", "", ""],
+ "show_number"          =>      ["show_number", "boolean", "display channel number in front of buffername", "", 0, 0,"on", "on", 0, "", "", "buffers_signal_config", "", "", ""],
+ "show_number_char"     =>      ["number_char", "string", "display a char after channel number", "", 0, 0,".", ".", 0, "", "", "buffers_signal_config", "", "", ""],
+ "show_prefix"          =>      ["prefix", "boolean", "show your prefix for channel", "", 0, 0,"off", "off", 0, "", "", "buffers_signal_config", "", "", ""],
+ "show_prefix_empty"    =>      ["prefix_empty", "boolean", "use a placeholder for channels without prefix", "", 0, 0,"on", "on", 0, "", "", "buffers_signal_config", "", "", ""],
+ "sort"                 =>      ["sort", "integer", "sort buffer-list by \"number\" or \"name\"", "number|name", 0, 0,"number", "number", 0, "", "", "buffers_signal_config", "", "", ""],
+ "core_to_front"        =>      ["core_to_front", "boolean", "core buffer and buffers with free content will be listed first. Take only effect if buffer sort is by name", "", 0, 0,"off", "off", 0, "", "", "buffers_signal_config", "", "", ""],
  "jump_prev_next_visited_buffer" => ["jump_prev_next_visited_buffer", "boolean", "jump to previously or next visited buffer if you click with left/right mouse button on currently visiting buffer", "", 0, 0,"off", "off", 0, "", "", "buffers_signal_config", "", "", ""],
+ "name_size_max"        =>      ["name_size_max","integer","maximum size of buffer name. 0 means no limitation","",0,256,0,0,0, "", "", "buffers_signal_config", "", "", ""],
+ "name_crop_suffix"     =>      ["name_crop_suffix","string","contains an optional char(s) that is appended when buffer name is shortened","",0,0,"+","+",0,"","","buffers_signal_config", "", "", ""],
+ "detach"               =>      ["detach", "integer","detach channel from buffers list after a specific period of time (in seconds) without action (weechat ≥ 0.3.8 required)", "", 0, 31536000,0, "number", 0, "", "", "buffers_signal_config", "", "", ""],
+ "immune_detach_buffers" =>     ["immune_detach_buffers", "string", "comma separated list of buffers which will not get detached automatically. Good with e.g. BitlBee", "", 0, 0,"", "", 0, "", "", "buffers_signal_config_immune_detach_buffers", "", "", ""],
 );
     # section "color"
     my $section_color = weechat::config_new_section($buffers_config_file,"color", 0, 0, "", "", "", "", "", "", "", "", "", "");
         $buffer->{"name"} = weechat::infolist_string($infolist, "name");
         $buffer->{"short_name"} = weechat::infolist_string($infolist, "short_name");
         $buffer->{"full_name"} = $buffer->{"plugin_name"}.".".$buffer->{"name"};
-        if ($active_seen)
+        $buffer->{"type"} = weechat::buffer_get_string($buffer->{"pointer"},"localvar_type");
+#        weechat::print("",$buffer->{"type"});
+
+        unless( grep {$_ eq $buffer->{"name"}} @immune_detach_buffers )
         {
-            push(@current2, $buffer);
+            my $detach_time = weechat::config_integer( $options{"detach"});
+            my $current_time = time();
+            # set timer for buffers with no hotlist action
+            $buffers_timer{$buffer->{"pointer"}} = $current_time
+             if ( not exists $hotlist{$buffer->{"pointer"}}
+             and $buffer->{"type"} eq "channel"
+             and not exists $buffers_timer{$buffer->{"pointer"}}
+             and $detach_time > 0);
+
+            # check for detach
+            unless ( $buffer->{"current_buffer"} eq 0
+            and not exists $hotlist{$buffer->{"pointer"}}
+            and $buffer->{"type"} eq "channel"
+            and exists $buffers_timer{$buffer->{"pointer"}}
+            and $detach_time > 0
+            and $weechat_version >= 0x00030800
+            and $current_time - $buffers_timer{$buffer->{"pointer"}} >= $detach_time )
+            {
+                if ($active_seen)
+                {
+                    push(@current2, $buffer);
+                }
+                else
+                {
+                    push(@current1, $buffer);
+                }
+            }
         }
         else
         {
-            push(@current1, $buffer);
+                if ($active_seen)
+                {
+                    push(@current2, $buffer);
+                }
+                else
+                {
+                    push(@current1, $buffer);
+                }
         }
-    }
+
+    }   # while end
+
+
     if ($max_number >= 1)
     {
         $max_number_digits = length(int($max_number));
             {
                 my $name = $buffer->{"name"};
                 $name = $buffer->{"short_name"} if (weechat::config_boolean( $options{"short_names"} ) eq 1);
-
+                if (weechat::config_integer($options{"name_size_max"}) >= 1){
+                    $name = encode("UTF-8", substr(decode("UTF-8", $name), 0, weechat::config_integer($options{"name_size_max"})));
+                }
                 if ( weechat::config_boolean($options{"core_to_front"}) eq 1)
                 {
                     if ( (weechat::buffer_get_string($buffer->{"pointer"}, "localvar_type") ne "channel" ) and ( weechat::buffer_get_string($buffer->{"pointer"}, "localvar_type") ne "private") )
     foreach my $key (sort keys %sorted_buffers)
     {
         my $buffer = $sorted_buffers{$key};
-        if ( (weechat::config_boolean( $options{"hide_merged_buffers"} ) eq 1) && (! $buffer->{"active"}) )
+
+        if ( weechat::config_string($options{"hide_merged_buffers"}) eq "server" )
         {
-            next;
+            # buffer type "server" or merged with core?
+            if ( ($buffer->{"type"} eq "server" or $buffer->{"plugin_name"} eq "core") && (! $buffer->{"active"}) )
+            {
+                next;
+            }
+        }
+        if ( weechat::config_string($options{"hide_merged_buffers"}) eq "channel" )
+        {
+            # buffer type "channel" or merged with core?
+            if ( ($buffer->{"type"} eq "channel" or $buffer->{"plugin_name"} eq "core") && (! $buffer->{"active"}) )
+            {
+                next;
+            }
+        }
+        if ( weechat::config_string($options{"hide_merged_buffers"}) eq "private" )
+        {
+            # buffer type "private" or merged with core?
+            if ( ($buffer->{"type"} eq "private" or $buffer->{"plugin_name"} eq "core") && (! $buffer->{"active"}) )
+            {
+                next;
+            }
+        }
+        if ( weechat::config_string($options{"hide_merged_buffers"}) eq "keepserver" )
+        {
+            if ( ($buffer->{"type"} ne "server" or $buffer->{"plugin_name"} eq "core") && (! $buffer->{"active"}) )
+            {
+                next;
+            }
+        }
+        if ( weechat::config_string($options{"hide_merged_buffers"}) eq "all" )
+        {
+            if ( ! $buffer->{"active"} )
+            {
+                next;
+            }
         }
 
-        push(@buffers_focus, $buffer);
+        push(@buffers_focus, $buffer);                                          # buffer > buffers_focus, for mouse support
         my $color = "";
         my $bg = "";
 
         # color for channel and query buffer
         if (exists $hotlist{$buffer->{"pointer"}})
         {
+        delete $buffers_timer{$buffer->{"pointer"}};
             # check if buffer is in whitelist buffer
             if (grep {$_ eq $buffer->{"name"}} @whitelist_buffers)
             {
                       $bg = weechat::config_color( $options{"queries_highlight_bg"} );
                       $color = weechat::config_color( $options{"queries_highlight_fg"} );
                   }
-              }else
-              {
+                }else
+                {
                       $bg = weechat::config_color( $options{"color_hotlist_".$hotlist_level{$hotlist{$buffer->{"pointer"}}}."_bg"} );
                       $color = weechat::config_color( $options{"color_hotlist_".$hotlist_level{$hotlist{$buffer->{"pointer"}}}."_fg"}  );
-              }
+                }
             }else
             {
                       $bg = weechat::config_color( $options{"color_hotlist_".$hotlist_level{$hotlist{$buffer->{"pointer"}}}."_bg"} );
         }
         my $color_bg = "";
         $color_bg = weechat::color(",".$bg) if ($bg ne "");
+
+        # create channel number for output
         if ( weechat::config_boolean( $options{"show_number"} ) eq 1 )   # on
         {
             if (( weechat::config_boolean( $options{"indenting_number"} ) eq 1)
             }
         }
         $str .= weechat::color($color) . weechat::color(",".$bg);
+
         if (weechat::config_boolean( $options{"short_names"} ) eq 1)
         {
-            $str .= $buffer->{"short_name"};
+            if (weechat::config_integer($options{"name_size_max"}) >= 1)                # check max_size of buffer name
+            {
+                $str .= encode("UTF-8", substr(decode("UTF-8", $buffer->{"short_name"}), 0, weechat::config_integer($options{"name_size_max"})));
+                $str .= weechat::color(weechat::config_color( $options{"color_number_char"})).weechat::config_string($options{"name_crop_suffix"}) if (length($buffer->{"short_name"}) > weechat::config_integer($options{"name_size_max"}));
+            }
+            else
+            {
+                $str .= $buffer->{"short_name"};
+            }
         }
         else
         {
-            $str .= $buffer->{"name"};
+            if (weechat::config_integer($options{"name_size_max"}) >= 1)                # check max_size of buffer name
+            {
+                $str .= encode("UTF-8", substr(decode("UTF-8", $buffer->{"name"},), 0, weechat::config_integer($options{"name_size_max"})));
+                $str .= weechat::color(weechat::config_color( $options{"color_number_char"})).weechat::config_string($options{"name_crop_suffix"}) if (length($buffer->{"name"}) > weechat::config_integer($options{"name_size_max"}));
+            }
+            else
+            {
+                $str .= $buffer->{"name"};
+            }
+        }
+        if ( weechat::buffer_get_string($buffer->{"pointer"}, "localvar_type") eq "server" and weechat::config_boolean($options{"show_lag"}) eq 1)
+        {
+            my $color_lag = weechat::config_color(weechat::config_get("irc.color.item_lag_finished"));
+            my $min_lag = weechat::config_integer(weechat::config_get("irc.network.lag_min_show"));
+            my $infolist_server = weechat::infolist_get("irc_server","",$buffer->{"short_name"});
+            weechat::infolist_next($infolist_server);
+            my $lag = (weechat::infolist_integer($infolist_server, "lag"));
+            weechat::infolist_free($infolist_server);
+            if ( int($lag) > int($min_lag) )
+            {
+                $lag = $lag / 1000;
+                $str .= weechat::color("default") . " (" . weechat::color($color_lag) . $lag . weechat::color("default") . ")";
+            }
         }
         $str .= "\n";
         $old_number = $buffer->{"number"};
 
 sub buffers_signal_buffer
 {
+my ($data, $signal, $signal_data) = @_;
+    # check for buffer_switch and set the detach time or remove detach time
+    if ($weechat_version >= 0x00030800)
+    {
+        if ($signal eq "buffer_switch")
+        {
+            my $pointer = weechat::hdata_get_list (weechat::hdata_get("buffer"), "gui_buffer_last_displayed"); # get switched buffer
+            my $current_time = time();
+            if ( weechat::buffer_get_string($pointer, "localvar_type") eq "channel")
+            {
+                $buffers_timer{$pointer} = $current_time;
+            }
+            else
+            {
+                delete $buffers_timer{$pointer};
+            }
+        }
+        if ($signal eq "buffer_opened")
+        {
+            my $current_time = time();
+            $buffers_timer{$signal_data} = $current_time;
+        }
+        if ($signal eq "buffer_closing")
+        {
+            delete $buffers_timer{$signal_data};
+        }
+    }
+
     weechat::bar_item_update("buffers");
     return weechat::WEECHAT_RC_OK;
 }
 
 sub buffers_signal_config_whitelist
 {
-    @whitelist_buffers = split( /,/, weechat::config_string( $options{"color_whitelist_buffers"} ) );
+    @whitelist_buffers = ();
+    @whitelist_buffers = split( /,/, weechat::config_string( $options{"look_whitelist_buffers"} ) );
+    weechat::bar_item_update("buffers");
+    return weechat::WEECHAT_RC_OK;
+}
+sub buffers_signal_config_immune_detach_buffers
+{
+    @immune_detach_buffers = ();
+    @immune_detach_buffers = split( /,/, weechat::config_string( $options{"immune_detach_buffers"} ) );
     weechat::bar_item_update("buffers");
     return weechat::WEECHAT_RC_OK;
 }
 }
 
 # called when a mouse action is done on buffers item, to execute action
-# action can be: jump to a buffer, or move buffer in list (drag & drop of buffer)
+# possible actions: jump to a buffer or move buffer in list (drag & drop of buffer)
 sub buffers_hsignal_mouse
 {
     my ($data, $signal, %hash) = ($_[0], $_[1], %{$_[2]});

.weechat/perl/colorize_lines.pl

 #
-# Copyright (c) 2010-2011 by Nils Görs <weechatter@arcor.de>
+# Copyright (c) 2010-2012 by Nils Görs <weechatter@arcor.de>
 #
 # colors the channel text with nick color and also highlight the whole line
 # colorize_nicks.py script will be supported
 # for settings see help page
 #
 # history:
-# 1.0: fixed: irc.look.nick_prefix wasn't supported
+# 1.5: sync: option weechat.look.nickmode changed in 0.3.9 to "irc.look.nick_mode"
+# 1.4: fix: whole ctcp message was display in prefix (reported by : Mkaysi)
+# 1.3: fix: now using weechat::buffer_get_string() instead of regex to prevent problems with dots inside server-/channelnames (reported by surfhai)
+# 1.2: add: hook_modifier("colorize_lines") to use colorize_lines with another script.
+#    : fix: regex was too greedy and also hit tag "prefix_nick_ccc"
+# 1.1: fix:  problems with temporary server (reported by nand`)
+#    : improved: using weechat_string_has_highlight()
+# 1.0: fix: irc.look.nick_prefix wasn't supported
 # 0.9: added: option "own_nick" (idea by travkin)
 #    : new value (always) for option highlight
 #    : clean up code
-# 0.8.1: fixed: regex()
+# 0.8.1: fix: regex()
 # 0.8: added: option "avail_buffer" and "nicks" (please read help-page) (suggested by ldvx)
-#    : fixed: blacklist_channels wasn't load at start
-#    : fixed: nick_modes wasn't displayed since v0.7
+#    : fix: blacklist_channels wasn't load at start
+#    : fix: nick_modes wasn't displayed since v0.7
 #    : rewrote init() routine
 #    : thanks to stfn for hint with unescaped variables in regex.
-# 0.7: fixed: bug when irc.look.nick_suffix was set (reported and beta-testing by: hw2) (>= weechat 0.3.4)
+# 0.7: fix: bug when irc.look.nick_suffix was set (reported and beta-testing by: hw2) (>= weechat 0.3.4)
 #      blacklist_channels option supports servername
 #      clean up code
 # 0.6: code optimazations.
 
 use strict;
 my $prgname	= "colorize_lines";
-my $version	= "1.0";
+my $version	= "1.5";
 my $description	= "colors text in chat area with according nick color. Highlight messages will be fully highlighted in chat area";
 
 # default values
                   "blacklist_channels"   => "comma separated list with channelname. Channels in this list will be ignored. (e.g.: freenode.#weechat,freenode.#weechat-fr)",
                   "shuffle"              => "toggle shuffle color mode for chats area (default: off)",
                   "chat"                 => "colors text in chat area with according nick color (default: on)",
-                  "highlight"            => "highlight messages will be fully highlighted in chat area (on = whole line will be highlighted, off = only nick will be highlighted, always = a highlight will always color the whole message) (default: on)",
+                  "highlight"            => "highlight messages will be fully highlighted in chat area (on = whole line will be highlighted (using whitelist, only messages from your buddies will be fully highlighted), off = only nick will be highlighted, always = a highlight will always color the whole message (highlight messages from nicks not in your whitelist will be fully highlighted)) (default: on)",
                   "hotlist_max_level_nicks_add"         => "toggle highlight for hotlist (default: off)",
                   "buffer_autoset"       => "toggle highlight color in chat area for buffer_autoset (default: off)",
                   "look_highlight"       => "toggle highlight color in chat area for option weechat.look.highlight (default: off)",
                   "own_lines"            => "colors own written messages (default: off)",
 );
 
+my $weechat_version;
 my $zahl = 0;
-my $weechat_version = 0;
 my $nick_mode = "";
 my $get_prefix_action = "";
 my @var_blacklist_channels = "";
 sub colorize_cb {
 my ( $data, $modifier, $modifier_data, $string ) = @_;
 
-if (index($modifier_data,"irc_privmsg") == -1){							# its neither a channel nor a query buffer
+if (index($modifier_data,"irc_privmsg") == -1){                                                 # its neither a channel nor a query buffer
+  return $string;
+}
+
+if (index($modifier_data,"irc_ctcp") >= 0){                                                    # don't do anything with CTCP messages
   return $string;
 }
 
   return $string;
 }
 
-$modifier_data =~ (m/irc;(.+?)\.(.+?)\;/);                                                      # irc;servername.channelname;
-my ($t0, $t1 , $t2) = split(/;/,$modifier_data);
-#$t1 =~ m/^(.+)\.(.+)$/;
-my $servername = $1;
-my $channel_name = $2;
+# get servername and channelname. Do not use regex to extract server- and channelname out of $modifier_data. You will FAIL!
+# some possible names: freenode.#weechat, freenode.#weechat.de, freenode.query, chat.freenode.net.#weechat, chat.freenode.net.#weechat.de
+$modifier_data =~ (m/(.*);(.*);/);
+my $plugin = $1;
+my $name = $2;
+my $buf_pointer = weechat::buffer_search($plugin,$name);
+return $string if ($buf_pointer eq "");
+my $servername = weechat::buffer_get_string($buf_pointer, "localvar_server");
+my $channel_name = weechat::buffer_get_string($buf_pointer, "localvar_channel");
+
 my $my_nick = weechat::info_get( 'irc_nick', $servername );                                     # get nick with servername (;freenode.)
 
 if ( grep /^$servername.$channel_name$/, @var_blacklist_channels ) {                            # check for blacklist_channels
 $string =~ m/^(.*)\t(.*)/;                                                                      # get the nick name: nick[tab]string
 my $nick = $1;                                                                                  # nick with nick_mode and color codes
 my $line = $2;                                                                                  # get written text
+
 $line = weechat::string_remove_color($line,"");                                                 # remove color-codes from line, first
-$modifier_data =~ m/nick_(.*),/;                                                                # get the nick name from modifier_data (without nick_mode and color codes!)
-my $nick_wo_suffix = $1;                                                                        # nickname without nick_suffix
+# get the nick name from modifier_data (without nick_mode and color codes! Take care of tag "prefix_nick_ccc")
+$modifier_data =~ m/(^|,)nick_(.*),/;
+my $nick_wo_suffix = $2;                                                                        # nickname without nick_suffix
 
 if ( lc($nick_wo_suffix) eq lc($my_nick) ){                                                     # this one checks for own messages
   if ( $default_options{var_avail_buffer} ne "all" ){                                           # check for option avail_buffer
 
 # check if look.nickmode is ON and no prefix and no query buffer
 $nick_mode = "";
-if ( weechat::config_boolean(weechat::config_get("weechat.look.nickmode")) ==  1 and ($nick ne $get_prefix_action) and (index($modifier_data,"notify_private")) == -1){
+my $nickmode_value = 0;
+
+if (($weechat_version ne "") && ($weechat_version >= 0x00030900)){
+    my $temp_nickmode_value = weechat::config_integer(weechat::config_get("irc.look.nick_mode"));
+    $nickmode_value = 1 if ($temp_nickmode_value == 1 or $temp_nickmode_value == 3);
+}else{
+    $nickmode_value = weechat::config_boolean(weechat::config_get("weechat.look.nickmode"));
+}
+
+if ( $nickmode_value ==  1 and ($nick ne $get_prefix_action) and (index($modifier_data,"notify_private")) == -1){
 #   if ($nick  =~ m/^\@|^\%|^\+|^\~|^\*|^\&|^\!|^\-/) {                                                  # check for nick modes (@%+~*&!-) without colour
-      my $buf_pointer = weechat::buffer_search("irc",$servername . "." . $channel_name);
       my $nick_pointer = weechat::nicklist_search_nick($buf_pointer,"",$nick_wo_suffix);
       $nick_mode = weechat::nicklist_nick_get_string($buf_pointer,$nick_pointer,"prefix");
       my $color_mode = weechat::color( weechat::nicklist_nick_get_string($buf_pointer, $nick_pointer, "prefix_color") );
 }
 
 # i wrote the message
+#weechat::print("","nick_wo: $nick_wo_suffix");
+#weechat::print("","my_nick: $my_nick");
     if ($nick_wo_suffix eq $my_nick ){                                                                  # i wrote the message
       return $string if check_whitelist_nicks($servername, $my_nick, $nick_wo_suffix);                  # check for whitelist
-
       if ($default_options{var_chat} eq "on"){
 	  my $nick_color = weechat::config_color(weechat::config_get("weechat.color.chat_nick_self"));  # get my nick color
 	  $nick_color = weechat::color($nick_color);
 
 	    chomp($highlight_words);
 
+#            weechat::print("",$highlight_words);
 	      foreach ( split( /,+/, $highlight_words ) ) {                                     # check for highlight_words
 		  if ($_ eq ""){next;}                                                          # ignore empty string
 		    my $search_string = shell2regex($_);
 	      }
       }
 	# buffer_autoset is off.
-	if (lc($string) =~ m/(\w.*$my_nick.*)/){						# my name called in string (case insensitiv)?
+        if ( weechat::string_has_highlight($line, $my_nick) >= 1){
+#        if (lc($string) =~ m/(\w.*$my_nick.*)/){                                                # my name called in string (case insensitiv)?
 	    my $color_highlight = weechat::config_color(weechat::config_get("weechat.color.chat_highlight"));
 	    my $color_highlight_bg = weechat::config_color(weechat::config_get("weechat.color.chat_highlight_bg"));
+
 	    my $high_color = weechat::color("$color_highlight,$color_highlight_bg");
 
               if (index($modifier_data,"irc_action") >= 0){                                    # action used (/me)?
 	}
     } # highlight area finished
 
-return $string if check_whitelist_nicks($servername, $my_nick, $nick_wo_suffix);        # check for whitelist
+return $string if check_whitelist_nicks($servername, $my_nick, $nick_wo_suffix);                # check for whitelist
 # this one check for other nick!!
 if ( $default_options{var_avail_buffer} ne "all" ){                                             # check for option avail_buffer
   if ( index($modifier_data,"notify_message") > -1){                                            # message is public
 	}
 
 # check for weechat version and use weechat.look.highlight_regex option
-       if ( $weechat_version eq 1 ){                                                            # weechat is >= 0.3.4?
+       if (( $weechat_version ne "" ) && ( $weechat_version >= 0x00030400 )){        # >= v0.3.4?
 	  if ( $default_options{var_look_highlight_regex} eq "on" ){
 	    if ( weechat::string_has_highlight_regex($line,weechat::config_string(weechat::config_get("weechat.look.highlight_regex"))) eq 1 ){
 		my $color_highlight = weechat::config_color(weechat::config_get("weechat.color.chat_highlight"));
 		my $color_highlight_bg = weechat::config_color(weechat::config_get("weechat.color.chat_highlight_bg"));
+
 		my $high_color = weechat::color("$color_highlight,$color_highlight_bg");
 		$line = colorize_nicks($high_color,$modifier_data,$line);
 		$line = $nick_prefix_with_color . $nick_mode . $high_color . $nick . $nick_suffix_with_color . "\t" . $high_color . $line . weechat::color('reset');
 sub check_whitelist_nicks{
 my ( $servername, $my_nick, $nick_wo_suffix ) = @_;
   if ( $default_options{var_nicks} ne "" and $default_options{var_own_lines} eq "off" ){          # nicks in option and own_lines = off
-        return 1 unless (grep /^\Q$servername.$nick_wo_suffix\E$/i, @nick_list)             # check other nicks
+        return 1 unless (grep /^\Q$servername.$nick_wo_suffix\E$/i, @nick_list)                   # check other nicks
   }elsif ( $default_options{var_nicks} ne "" and $default_options{var_own_lines} eq "on" ){       # nicks in option and own_lines = on
       if ( $nick_wo_suffix ne $my_nick){                                                          # not my nick!
-        return 1 unless (grep /^\Q$servername.$nick_wo_suffix\E$/i, @nick_list)             # check other nicks
+        return 1 unless (grep /^\Q$servername.$nick_wo_suffix\E$/i, @nick_list)                   # check other nicks
       }
   }elsif( $default_options{var_nicks} eq "" and $default_options{var_own_lines} eq "off" ){       # no nicks and do not color my line?
       if ( $nick_wo_suffix eq $my_nick){                                                          # my nick?
 
 $get_prefix_action = weechat::config_string(weechat::config_get("weechat.look.prefix_action"));
 weechat::hook_modifier("weechat_print","colorize_cb", "");
-#weechat::hook_modifier("colorize_text","colorize_cb", "");
+weechat::hook_modifier("colorize_lines","colorize_cb", "");
 
-  if (( $weechat_version ne "" ) && ( $weechat_version >= 0x00030400 )){        # v0.3.4?
-    $weechat_version = 1;                                                       # yes!
-
+  if (( $weechat_version ne "" ) && ( $weechat_version >= 0x00030400 )){        # >= v0.3.4?
     # read nick colours if exists (>= weechat 0.3.4) in %colours
     my $colours_buf = weechat::config_string(weechat::config_get("weechat.color.chat_nick_colors"));
     if ( $colours_buf ne "" ) {

.weechat/plugins.conf

 #
-# plugins.conf -- WeeChat v0.3.6
+# plugins.conf -- WeeChat v0.3.8
 #
 
 [var]
 perl.colorize_lines.blacklist_channels = "comma separated list with channelname. Channels in this list will be ignored. (e.g.: freenode.#weechat,freenode.#weechat-fr)"
 perl.colorize_lines.buffer_autoset = "toggle highlight color in chat area for buffer_autoset (default: off)"
 perl.colorize_lines.chat = "colors text in chat area with according nick color (default: on)"
-perl.colorize_lines.highlight = "highlight messages will be fully highlighted in chat area (on = whole line will be highlighted, off = only nick will be highlighted, always = a highlight will always color the whole message) (default: on)"
+perl.colorize_lines.highlight = "highlight messages will be fully highlighted in chat area (on = whole line will be highlighted (using whitelist, only messages from your buddies will be fully highlighted), off = only nick will be highlighted, always = a highlight will always color the whole message (highlight messages from nicks not in your whitelist will be fully highlighted)) (default: on)"
 perl.colorize_lines.hotlist_max_level_nicks_add = "toggle highlight for hotlist (default: off)"
 perl.colorize_lines.look_highlight = "toggle highlight color in chat area for option weechat.look.highlight (default: off)"
 perl.colorize_lines.look_highlight_regex = "toggle highlight color in chat area for option weechat.look.highlight_regex (default: off)"

.weechat/python/autojoin.py

 #     version 0.2.2: fixed quit callback
 #     removed the callbacks on part & join messages
 #
+# 2012-04-14, Filip H.F. "FiXato" Slagter <fixato+weechat+autojoin@gmail.com>
+#     version 0.2.3: fixed bug with buffers of which short names were changed.
+#                    Now using 'name' from irc_channel infolist.
+#     version 0.2.4: Added support for key-protected channels
+#
 # @TODO: add options to ignore certain buffers
 # @TODO: maybe add an option to enable autosaving on part/join messages
 
 
 SCRIPT_NAME    = "autojoin"
 SCRIPT_AUTHOR  = "xt <xt@bash.no>"
-SCRIPT_VERSION = "0.2.2"
+SCRIPT_VERSION = "0.2.4"
 SCRIPT_LICENSE = "GPL3"
-SCRIPT_DESC    = "Configure autojoin for all servers according to currently \
-                  joined channels. Autosaving support is added in version 0.2"
+SCRIPT_DESC    = "Configure autojoin for all servers according to currently joined channels"
 SCRIPT_COMMAND = "autojoin"
 
 # script options
     ''' Autojoin current channels '''
     if w.config_get_plugin(option) != "on":
         return w.WEECHAT_RC_OK
-    
+
     items = find_channels()
 
     # print/execute commands
     ''' Autojoin current channels '''
     if w.config_get_plugin(option) != "on":
         return w.WEECHAT_RC_OK
-    
+
     items = find_channels()
 
     # print/execute commands
 
         pattern = "^:%s!.*(JOIN|PART) :?(#[^ ]*)( :.*$)?" % nick
         match = re.match(pattern, callback_data)
-        
+
         if match: # check if nick is my nick. In that case: save
             channel = match.group(2)
             channels = channels.rstrip(',')
 
     # populate channels per server
     for server in items.keys():
+        keys = []
+        channels = []
         items[server] = '' #init if connected but no channels
         infolist = w.infolist_get('irc_channel', '',  server)
         while w.infolist_next(infolist):
                 #parted but still open in a buffer: bit hackish
                 continue
             if w.infolist_integer(infolist, 'type') == 0:
-                channel = w.infolist_string(infolist, "buffer_short_name")
-                items[server] += '%s,' %channel
+                channels.append(w.infolist_string(infolist, "name"))
+                key = w.infolist_string(infolist, "key")
+                if len(key) > 0:
+                    keys.append(key)
+        items[server] = ','.join(channels)
+        if len(keys) > 0:
+            items[server] += ' %s' % ','.join(keys)
         w.infolist_free(infolist)
 
     return items
+

.weechat/python/autoload/weeget.py

-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2009-2012 Sebastien Helleu <flashcode@flashtux.org>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#
-
-#
-# WeeChat scripts manager.
-# (this script requires WeeChat >= 0.3.0 and python >= 2.6)
-#
-# History:
-#
-# 2012-01-03, Sebastien Helleu <flashcode@flashtux.org>:
-#     version 1.5: make script compatible with Python 3.x
-# 2011-03-25, Sebastien Helleu <flashcode@flashtux.org>:
-#     version 1.4: add completion with installed scripts for action "remove"
-# 2011-03-10, Sebastien Helleu <flashcode@flashtux.org>:
-#     version 1.3: add script extension in script name completion and a new
-#                  completion with tags for actions "list" and "listinstalled"
-# 2011-02-13, Sebastien Helleu <flashcode@flashtux.org>:
-#     version 1.2: use new help format for command arguments
-# 2010-11-08, Sebastien Helleu <flashcode@flashtux.org>:
-#     version 1.1: get python 2.x binary for hook_process (fix problem
-#                  when python 3.x is default python version, requires
-#                  WeeChat >= 0.3.4)
-# 2010-02-22, Blake Winton <bwinton@latte.ca>:
-#     version 1.0: add action "listinstalled" for command /weeget
-# 2010-01-25, Sebastien Helleu <flashcode@flashtux.org>:
-#     version 0.9: fix "running" status of scripts with /weeget check
-# 2009-09-30, Sebastien Helleu <flashcode@flashtux.org>:
-#     version 0.8: fix bugs and add missing info in "/weeget show",
-#                  display warning if url for plugins.xml.gz is old site
-# 2009-09-07, Sebastien Helleu <flashcode@flashtux.org>:
-#     version 0.7: update weechat site with new URL
-# 2009-05-02, Sebastien Helleu <flashcode@flashtux.org>:
-#     version 0.6: sync with last API changes
-# 2009-04-15, Sebastien Helleu <flashcode@flashtux.org>:
-#     version 0.5: display missing module(s) when import failed
-# 2009-04-11, Sebastien Helleu <flashcode@flashtux.org>:
-#     version 0.4: use new completion for command arguments
-# 2009-04-07, Sebastien Helleu <flashcode@flashtux.org>:
-#     version 0.3: fix bug with install/upgrade when weeget is updated with
-#                  other scripts: ensure that weeget is always the last
-#                  installed script
-# 2009-04-07, Sebastien Helleu <flashcode@flashtux.org>:
-#     version 0.2: add author's mail in script description
-# 2009-04-05, Sebastien Helleu <flashcode@flashtux.org>:
-#     version 0.1: initial release
-#
-
-SCRIPT_NAME    = "weeget"
-SCRIPT_AUTHOR  = "Sebastien Helleu <flashcode@flashtux.org>"
-SCRIPT_VERSION = "1.5"
-SCRIPT_LICENSE = "GPL3"
-SCRIPT_DESC    = "WeeChat scripts manager"
-
-SCRIPT_COMMAND = "weeget"
-
-import_ok = True
-
-try:
-    import weechat
-except ImportError:
-    print("This script must be run under WeeChat.")
-    print("Get WeeChat now at: http://www.weechat.org/")
-    import_ok = False
-
-try:
-    import sys, os, stat, time, gzip, hashlib, xml.dom.minidom
-except ImportError as message:
-    print("Missing package(s) for %s: %s" % (SCRIPT_NAME, message))
-    import_ok = False
-
-CONFIG_FILE_NAME = "wg"
-
-SCRIPT_EXTENSION = {
-    "perl"  : "pl",
-    "python": "py",
-    "ruby"  : "rb",
-    "lua"   : "lua",
-    "tcl"   : "tcl",
-}
-
-# timeout for download of plugins.xml.gz
-TIMEOUT_UPDATE = 60 * 1000
-
-# timeout for download of a script
-TIMEOUT_SCRIPT = 60 * 1000
-
-# config file and options
-wg_config_file            = ""
-wg_config_option          = {}
-
-# action (install, remove, ..) and arguments
-wg_action                 = ""
-wg_action_args            = ""
-
-# loaded scripts
-wg_loaded_scripts         = {}
-
-# hook process and stdout
-wg_hook_process           = { "update": "", "script": "" }
-wg_stdout                 = { "update": "", "script": "" }
-
-# scripts read from plugins.xml.gz
-wg_scripts                = {}
-
-# list of script to install, and script currently installing
-wg_scripts_to_install     = []
-wg_current_script_install = {}
-
-# =================================[ config ]=================================
-
-def wg_config_init():
-    """
-    Initialization of configuration file.
-    Sections: color, scripts.
-    """
-    global wg_config_file, wg_config_option
-    wg_config_file = weechat.config_new(CONFIG_FILE_NAME,
-                                        "wg_config_reload_cb", "")
-    if wg_config_file == "":
-        return
-
-    # section "color"
-    section_color = weechat.config_new_section(
-        wg_config_file, "color", 0, 0, "", "", "", "", "", "", "", "", "", "")
-    if section_color == "":
-        weechat.config_free(wg_config_file)
-        return
-    wg_config_option["color_script"] = weechat.config_new_option(
-        wg_config_file, section_color,
-        "script", "color", "Color for script names", "", 0, 0,
-        "cyan", "cyan", 0, "", "", "", "", "", "")
-    wg_config_option["color_installed"] = weechat.config_new_option(
-        wg_config_file, section_color,
-        "installed", "color", "Color for \"installed\" indicator", "", 0, 0,
-        "yellow", "yellow", 0, "", "", "", "", "", "")
-    wg_config_option["color_running"] = weechat.config_new_option(
-        wg_config_file, section_color,
-        "running", "color", "Color for \"running\" indicator", "", 0, 0,
-        "lightgreen", "lightgreen", 0, "", "", "", "", "", "")
-    wg_config_option["color_obsolete"] = weechat.config_new_option(
-        wg_config_file, section_color,
-        "obsolete", "color", "Color for \"obsolete\" indicator", "", 0, 0,
-        "lightmagenta", "lightmagenta", 0, "", "", "", "", "", "")
-    wg_config_option["color_unknown"] = weechat.config_new_option(
-        wg_config_file, section_color,
-        "unknown", "color", "Color for \"unknown status\" indicator", "", 0, 0,
-        "lightred", "lightred", 0, "", "", "", "", "", "")
-    wg_config_option["color_language"] = weechat.config_new_option(
-        wg_config_file, section_color,
-        "language", "color", "Color for language names", "", 0, 0,
-        "lightblue", "lightblue", 0, "", "", "", "", "", "")
-
-    # section "scripts"
-    section_scripts = weechat.config_new_section(
-        wg_config_file, "scripts", 0, 0, "", "", "", "", "", "", "", "", "", "")
-    if section_scripts == "":
-        weechat.config_free(wg_config_file)
-        return
-    wg_config_option["scripts_url"] = weechat.config_new_option(
-        wg_config_file, section_scripts,
-        "url", "string", "URL for file with list of plugins", "", 0, 0,
-        "http://www.weechat.org/files/plugins.xml.gz",
-        "http://www.weechat.org/files/plugins.xml.gz", 0, "", "", "", "", "", "")
-    wg_config_option["scripts_dir"] = weechat.config_new_option(
-        wg_config_file, section_scripts,
-        "dir", "string", "Local cache directory for" + SCRIPT_NAME, "", 0, 0,
-        "%h/" + SCRIPT_NAME, "%h/" + SCRIPT_NAME, 0, "", "", "", "", "", "")
-    wg_config_option["scripts_cache_expire"] = weechat.config_new_option(
-        wg_config_file, section_scripts,
-        "cache_expire", "integer", "Local cache expiration time, in minutes "
-        "(-1 = never expires, 0 = always expires)", "",
-        -1, 60*24*365, "60", "60", 0, "", "", "", "", "", "")
-
-def wg_config_reload_cb(data, config_file):
-    """ Reload configuration file. """
-    return weechat.config_read(config_file)
-
-def wg_config_read():
-    """ Read configuration file. """
-    global wg_config_file
-    return weechat.config_read(wg_config_file)
-
-def wg_config_write():
-    """ Write configuration file. """
-    global wg_config_file
-    return weechat.config_write(wg_config_file)
-
-def wg_config_color(color):
-    """ Get a color from configuration. """
-    global wg_config_option
-    option = wg_config_option.get("color_" + color, "")
-    if option == "":
-        return ""
-    return weechat.color(weechat.config_string(option))
-
-def wg_config_get_dir():
-    """ Return weeget directory, with expanded WeeChat home dir. """
-    global wg_config_option
-    return weechat.config_string(
-        wg_config_option["scripts_dir"]).replace("%h",
-                                                 weechat.info_get("weechat_dir", ""))
-
-def wg_config_create_dir():
-    """ Create weeget directory. """
-    dir = wg_config_get_dir()
-    if not os.path.isdir(dir):
-        os.makedirs(dir, mode=0o700)
-
-def wg_config_get_cache_filename():
-    """ Get local cache filename, based on URL. """
-    global wg_config_option
-    return wg_config_get_dir() + os.sep + \
-           os.path.basename(weechat.config_string(wg_config_option["scripts_url"]))
-
-# =============================[ download file ]==============================
-
-def wg_download_file(url, filename, timeout, callback, callback_data):
-    """Download a file with an URL. Return hook_process created."""
-    script = [ "import sys",
-               "try:",
-               "    if sys.version_info >= (3,):",
-               "        import urllib.request",
-               "        response = urllib.request.urlopen('%s')" % url,
-               "    else:",
-               "        import urllib2",
-               "        response = urllib2.urlopen(urllib2.Request('%s'))" % url,
-               "    f = open('%s', 'wb')" % filename,
-               "    f.write(response.read())",
-               "    response.close()",
-               "    f.close()",
-               "except Exception as e:",
-               "    print('error:' + str(e))" ]
-    return weechat.hook_process("python -c \"%s\"" % "\n".join(script),
-                                timeout,
-                                callback, callback_data)
-
-# ================================[ scripts ]=================================
-
-def wg_search_script_by_name(name):
-    """
-    Search a script in list by name.
-    Name can be short name ('weeget') or full name ('weeget.py').
-    """
-    global wg_scripts
-    for id, script in wg_scripts.items():
-        if script["name"] == name or script["full_name"] == name:
-            return script
-    return None
-
-def wg_get_loaded_scripts():
-    """
-    Get python dictionary with loaded scripts.
-    Keys are filenames and values are path to script, for example:
-      'weeget.py': '/home/xxx/.weechat/python/weeget.py'
-    """
-    global wg_loaded_scripts
-    wg_loaded_scripts = {}
-    for language in SCRIPT_EXTENSION.keys():
-        infolist = weechat.infolist_get(language + "_script", "", "")
-        while weechat.infolist_next(infolist):
-            filename = weechat.infolist_string(infolist, "filename")
-            if filename != "":
-                wg_loaded_scripts[os.path.basename(filename)] = filename
-        weechat.infolist_free(infolist)
-
-def wg_is_local_script_loaded(filename):
-    """ Check if a script filename (like 'python/weeget.py') is loaded. """
-    global wg_loaded_scripts
-    filename2 = filename
-    if filename2.startswith("autoload/"):
-        filename2 = filename2[9:]
-    for name, path in wg_loaded_scripts.items():
-        if path.endswith(filename) or path.endswith(filename2):
-            return True
-    return False
-
-def wg_get_local_script_status(script):
-    """
-    Check if a script is installed.
-    'script' is a dictionary retrieved from scripts xml list.
-    """
-    global wg_loaded_scripts
-    status = { "installed": "", "obsolete": "", "running": "" }
-    local_dir = weechat.info_get("weechat_dir", "") + os.sep + script["language"]
-    local_name = local_dir + os.sep + "autoload" + os.sep + script["full_name"]
-    if not os.path.isfile(local_name):
-        local_name = local_dir + os.sep + script["full_name"]
-    if os.path.isfile(local_name):
-        status["installed"] = "1"
-        f = open(local_name, "rb")
-        md5 = hashlib.md5()
-        md5.update(f.read())
-        f.close()
-        local_md5 = md5.hexdigest()
-        if local_md5 != script["md5sum"]:
-            status["obsolete"] = "1"
-    if script["full_name"] in wg_loaded_scripts.keys():
-        status["running"] = "1"
-    return status
-
-def wg_get_local_scripts():
-    """
-    Get list of all local scripts (in languages and autoload dirs).
-    Return a dictionary with language as key and list of paths as value,
-    with autoloaded scripts at beginning of list, for example:
-      { 'perl':   [ 'autoload/buffers.pl',
-                    'autoload/weetris.pl',
-                    'beep.pl',
-                    'launcher.pl' ],
-        'python': [ 'autoload/weeget.py',
-                    'go.py',
-                    'vdm.py' ]
-      }
-    """
-    files = {}
-    for language in SCRIPT_EXTENSION.keys():
-        files[language] = []
-        autoloaded_files = []
-        rootdir = weechat.info_get("weechat_dir", "") + os.sep + language
-        for root, dirs, listfiles in os.walk(rootdir):
-            if root == rootdir:
-                files[language] = listfiles
-            elif root == rootdir + os.sep + "autoload":
-                autoloaded_files = listfiles
-        for file in autoloaded_files:
-            if file in files[language]:
-                files[language].remove(file)
-            files[language].insert(0, "autoload" + os.sep + file)
-    return files
-
-def wg_get_local_scripts_status():
-    """
-    Return list of all local scripts with status (unknown/obsolete/running).
-    For example:
-      [ 'perl/weetris.pl':  { 'unknown': '', 'obsolete': '1', 'running': ''  },
-        'python/weeget.py': { 'unknown': '', 'obsolete': '',  'running': '1' }
-      ]
-    """
-    local_scripts_status = []
-    local_scripts = wg_get_local_scripts()
-    if len(local_scripts) > 0:
-        for language, files in local_scripts.items():
-            for file in files:
-                script_status = { "unknown": "", "obsolete": "", "running": "" }
-                name_with_ext = os.path.basename(file)
-                script = wg_search_script_by_name(os.path.basename(file))
-                if script == None:
-                    script_status["unknown"] = "1"
-                else:
-                    status = wg_get_local_script_status(script)
-                    if status["obsolete"]:
-                        script_status["obsolete"] = "1"
-                if wg_is_local_script_loaded(file):
-                    script_status["running"] = "1"
-                local_scripts_status.append((language + os.sep + file,
-                                             script_status))
-    return local_scripts_status
-
-def wg_search_scripts(search):
-    """ Search word in scripts, return list of matching scripts. """
-    global wg_scripts
-    if search == "":
-        return wg_scripts
-    scripts_matching = {}
-    for id, script in wg_scripts.items():
-        if script["name"].lower().find(search) >= 0 \
-           or script["language"].lower().find(search) >= 0 \
-           or script["desc_en"].lower().find(search) >= 0 \
-           or script["desc_fr"].lower().find(search) >= 0 \
-           or script["tags"].lower().find(search) >= 0:
-           scripts_matching[id] = script
-    return scripts_matching
-
-def wg_list_scripts(search, installed=False):
-    """
-    List all scripts (with optional search string).
-    If installed == True, then list only installed scripts.
-    For each script, display status (installed/running/new version available),
-    name of script, language and description.
-    For example:
-      ir  buffers        pl  Sidebar with list of buffers.
-      i N go             py  Quick jump to buffers.
-      i   weetris        pl  Tetris-like game.
-    """
-    global wg_scripts
-    search = search.strip().lower()
-    scripts_matching = wg_search_scripts(search)
-    if len(scripts_matching) == 0:
-        weechat.prnt("", "%s: no script found" % SCRIPT_NAME)
-    else:
-        weechat.prnt("", "")
-        if search != "":
-            if installed:
-                weechat.prnt("", "Scripts installed matching \"%s\":" % search)
-            else:
-                weechat.prnt("", "Scripts for WeeChat %s matching \"%s\":"
-                             % (weechat.info_get("version", ""),
-                                search))
-        else:
-            if installed:
-                weechat.prnt("", "Scripts installed:")
-            else:
-                weechat.prnt("", "Scripts for WeeChat %s:"
-                             % weechat.info_get("version", ""))
-        sorted_scripts = sorted(scripts_matching.items(),
-                                key=lambda s: s[1]["name"])
-        length_max_name = 0
-        for item in sorted_scripts:
-            length = len(item[1]["name"])
-            if length > length_max_name:
-                length_max_name = length
-        str_format = "%%s%%s%%s%%s%%s%%s%%s %%s%%-%ds %%s%%-3s %%s%%s" \
-                     % length_max_name
-        for item in sorted_scripts:
-            script = item[1]
-            str_installed = " "
-            str_running = " "
-            str_obsolete = " "
-            status = wg_get_local_script_status(script)
-            if installed and not status["installed"]:
-                continue
-            if status["installed"]:
-                str_installed = "i"
-            if status["running"]:
-                str_running = "r"
-            if status["obsolete"]:
-                str_obsolete = "N"
-            weechat.prnt("", str_format
-                         % (wg_config_color("installed"),
-                            str_installed,
-                            wg_config_color("running"),
-                            str_running,
-                            wg_config_color("obsolete"),
-                            str_obsolete,
-                            weechat.color("chat"),
-                            wg_config_color("script"),
-                            script["name"],
-                            wg_config_color("language"),
-                            SCRIPT_EXTENSION[script["language"]],
-                            weechat.color("chat"),
-                            script["desc_en"]))
-
-def wg_show_script(name):
-    """
-    Show detailed info about a script (in repository).
-    For example:
-        Script: weeget.py, version 0.7, license: GPL3
-        Author: Sebastien Helleu <flashcode [at] flashtux [dot] org>
-        Status: installed, running
-          Date: added: 2009-04-05, updated: 2009-09-07
-           URL: http://www.weechat.org/files/scripts/weeget.py
-           MD5: 4b0458dd5cc5c9a09ba8078f89830869
-          Desc: Scripts manager.
-          Tags: scripts
-      Requires: python 2.5
-           Min: 0.3.0
-    """
-    if len(wg_scripts) == 0:
-        return
-    script = wg_search_script_by_name(name)
-    if script == None:
-        weechat.prnt("", "%s: script \"%s%s%s\" not found"
-                     % (SCRIPT_NAME,
-                        wg_config_color("script"),
-                        name,
-                        weechat.color("chat")))
-    else:
-        weechat.prnt("", "")
-        weechat.prnt("", "  Script: %s%s%s, version %s, license: %s"
-                     % (wg_config_color("script"),
-                        script["full_name"],
-                        weechat.color("chat"),
-                        script["version"],
-                        script["license"]))
-        weechat.prnt("", "  Author: %s <%s>" % (script["author"], script["mail"]))
-        status = wg_get_local_script_status(script)
-        str_status = "not installed"
-        if status["installed"]:
-            str_status = "installed"
-            if status["running"]:
-                str_status += ", running"
-            else:
-                str_status += ", not running"
-        if status["obsolete"]:
-            str_status += " (new version available)"
-        weechat.prnt("",   "  Status: %s" % str_status)
-        date_added = script.get("added", "")[:10]
-        str_updated = script.get("updated", "")
-        if str_updated != "":
-            date_updated = script["updated"][:10]
-            if date_updated == "0000-00-00" or date_updated == date_added:
-                str_updated = ""
-        if str_updated != "":
-            weechat.prnt("", "    Date: added: %s, updated: %s"
-                         % (date_added, date_updated))
-        else:
-            weechat.prnt("", "    Date: added: %s" % date_added)
-        weechat.prnt("", "     URL: %s" % script.get("url", ""))
-        weechat.prnt("", "     MD5: %s" % script.get("md5sum", ""))
-        weechat.prnt("", "    Desc: %s" % script.get("desc_en", ""))
-        weechat.prnt("", "    Tags: %s" % script.get("tags", ""))
-        str_requires = script.get("requirements", "")
-        if str_requires == "":
-            str_requires = "(nothing)"
-        weechat.prnt("", "Requires: %s" % str_requires)
-        vmin = script.get("min_weechat", "")
-        vmax = script.get("max_weechat", "")
-        if vmin != "":
-            weechat.prnt("", "     Min: %s" % vmin)
-        if vmax != "":
-            weechat.prnt("", "     Max: %s" % vmax)
-
-def wg_install_next_script():
-    """
-    Install first script in list wg_scripts_to_install and remove it from
-    list.
-    """
-    global wg_scripts, wg_scripts_to_install, wg_current_script_install
-    global wg_hook_process
-    if len(wg_scripts) == 0:
-        return
-    # be sure weeget is ALWAYS last script to install/update
-    # otherwise we'll lose end of list when weeget is unloaded by WeeChat
-    if SCRIPT_NAME in wg_scripts_to_install:
-        wg_scripts_to_install.remove(SCRIPT_NAME)
-        wg_scripts_to_install.append(SCRIPT_NAME)
-    # loop until a script is installed, or end if list is empty
-    while len(wg_scripts_to_install) > 0:
-        name = wg_scripts_to_install.pop(0)
-        script = wg_search_script_by_name(name)
-        if script == None:
-            weechat.prnt("", "%s: script \"%s%s%s\" not found"
-                         % (SCRIPT_NAME,
-                            wg_config_color("script"),
-                            name,
-                            weechat.color("chat")))
-        else:
-            status = wg_get_local_script_status(script)
-            if status["installed"] and not status["obsolete"]:
-                weechat.prnt("",
-                             "%s: script \"%s%s%s\" is already "
-                             "installed and up to date"
-                             % (SCRIPT_NAME,
-                                wg_config_color("script"),
-                                script["full_name"],
-                                weechat.color("chat")))
-            else:
-                weechat.prnt("", "%s: downloading \"%s%s%s\"..."
-                             % (SCRIPT_NAME,
-                                wg_config_color("script"),
-                                script["full_name"],
-                                weechat.color("chat")))
-                if wg_hook_process["script"] != "":
-                    weechat.unhook(wg_hook_process["script"])
-                    wg_hook_process["script"] = ""
-                wg_current_script_install = script
-                filename = wg_config_get_dir() + os.sep + script["full_name"]
-                wg_hook_process["script"] = wg_download_file(script["url"], filename, TIMEOUT_SCRIPT,
-                                                             "wg_process_script_cb", "")
-                # this function will be called again when script will be
-                # downloaded
-                return
-
-def wg_install_scripts(names):
-    """ Install scripts. """
-    global wg_scripts_to_install
-    for name in names.split(" "):
-        wg_scripts_to_install.append(name)
-    wg_install_next_script()
-
-def wg_process_script_cb(data, command, rc, stdout, stderr):
-    """ Callback when reading a script from website. """
-    global wg_hook_process, wg_stdout, wg_current_script_install, wg_loaded_scripts
-    if stdout != "":
-        wg_stdout["script"] += stdout
-    if stderr != "":
-        wg_stdout["script"] += stderr
-    if int(rc) >= 0:
-        if wg_stdout["script"].startswith("error:"):
-            weechat.prnt("", "%s%s: error downloading script (%s)"
-                         % (weechat.prefix("error"), SCRIPT_NAME,
-                            wg_stdout["update"][6:].strip()))
-        else:
-            # ask C plugin to install/load script
-            weechat.hook_signal_send(wg_current_script_install["language"] + "_script_install",
-                                     weechat.WEECHAT_HOOK_SIGNAL_STRING,
-                                     wg_config_get_dir() + os.sep + wg_current_script_install["full_name"])
-        wg_hook_process["script"] = ""
-        wg_install_next_script()
-    return weechat.WEECHAT_RC_OK
-
-def wg_check_scripts():
-    """
-    Check status of local script(s).
-    For each script found, display status (unknown/running/new version available).
-    For example:
-       r   python/autoload/vdm.py
-      ?r   python/autoload/dummy.py
-       rN  python/shell.py
-           perl/buffers.pl
-    """
-    local_scripts_status = wg_get_local_scripts_status()
-    if len(local_scripts_status) == 0:
-        return
-    weechat.prnt("", "")
-    weechat.prnt("", "Local scripts:")
-    for file, status in local_scripts_status:
-        str_unknown = " "
-        str_running = " "
-        str_obsolete = " "
-        if status["unknown"]:
-            str_unknown = "?"
-        if status["running"]:
-            str_running = "r"
-        if status["obsolete"]:
-            str_obsolete = "N"
-        weechat.prnt("", "%s%s%s%s%s%s%s  %s%s%s%s"
-                     % (wg_config_color("unknown"), str_unknown,
-                        wg_config_color("running"), str_running,
-                        wg_config_color("obsolete"), str_obsolete,
-                        weechat.color("chat"),
-                        os.path.dirname(file),
-                        os.sep,
-                        wg_config_color("script"),
-                        os.path.basename(file)))
-
-def wg_upgrade_scripts():
-    """ Upgrade scripts. """
-    global wg_scripts, wg_scripts_to_install
-    if len(wg_scripts) == 0:
-        return
-    scripts_to_upgrade = []
-    for id, script in wg_scripts.items():
-        status = wg_get_local_script_status(script)
-        if status["installed"] and status["obsolete"]:
-            scripts_to_upgrade.append(script["name"])
-    if len(scripts_to_upgrade) == 0:
-        weechat.prnt("", "%s: all scripts are up to date" % SCRIPT_NAME)
-    else:
-        wg_scripts_to_install.extend(scripts_to_upgrade)
-        wg_install_next_script()
-
-def wg_remove_scripts(names):
-    """ Remove scripts. """
-    if len(wg_scripts) == 0:
-        return
-    list_names = names.split(" ")
-    scripts_to_remove = {}
-    for language in SCRIPT_EXTENSION.keys():
-        scripts_to_remove[language] = []
-    for name in list_names:
-        script = wg_search_script_by_name(name)
-        if script == None:
-            weechat.prnt("", "%s: script \"%s%s%s\" not found"
-                         % (SCRIPT_NAME,
-                            wg_config_color("script"),
-                            name,
-                            weechat.color("chat")))
-        else:
-            if script["full_name"] not in scripts_to_remove[script["language"]]:
-                scripts_to_remove[script["language"]].append(script["full_name"])
-    for language in SCRIPT_EXTENSION.keys():
-        if len(scripts_to_remove[language]) > 0:
-            # ask C plugin to remove script file(s)
-            weechat.hook_signal_send(language + "_script_remove",
-                                     weechat.WEECHAT_HOOK_SIGNAL_STRING,
-                                    ",".join(scripts_to_remove[language]))
-
-# ==================================[ xml ]===================================
-
-def wg_execute_action():
-    """ Execute action. """
-    global wg_action, wg_action_args, wg_loaded_scripts
-    if wg_action != "":
-        wg_get_loaded_scripts()
-        if wg_action == "list":
-            wg_list_scripts(wg_action_args)
-        elif wg_action == "listinstalled":
-            wg_list_scripts(wg_action_args, installed=True)
-        elif wg_action == "show":
-            wg_show_script(wg_action_args)
-        elif wg_action == "install":
-            wg_install_scripts(wg_action_args)
-        elif wg_action == "check":
-            wg_check_scripts()
-        elif wg_action == "upgrade":
-            wg_upgrade_scripts()
-        elif wg_action == "remove":
-            wg_remove_scripts(wg_action_args)
-        else:
-            weechat.prnt("", "%s%s: unknown action \"%s\""
-                         % (weechat.prefix("error"), SCRIPT_NAME, wg_action))
-
-    # reset action
-    wg_action = ""
-    wg_action_args = ""
-    wg_loaded_scripts = {}
-
-def wg_check_version(script):
-    """ Check if a script is designed for current running WeeChat version."""
-    version = weechat.info_get("version", "")
-    version = version.split("-", 1)[0]
-    vmin = script.get("min_weechat", "")
-    vmax = script.get("max_weechat", "")
-    if vmin != "" and version < vmin:
-        return False
-    if vmax != "" and version > vmax:
-        return False
-    return True
-
-def wg_parse_xml():
-    """
-    Parse XML scripts list and return dictionary with list, with key 'id'.
-    Example of item return in dictionary :
-      '119': { 'name'        : 'weeget',
-               'version'     : '0.1',
-               'url'         : 'http://www.weechat.org/files/scripts/weeget.py',
-               'language'    : 'python',
-               'license'     : 'GPL3',
-               'md5sum'      : 'd500714fc19b0e10cc4e339e70739e4ad500714fc19b0e10cc4e339e70739e4a',
-               'tags'        : 'scripts',
-               'desc_en'     : 'Scripts manager.',
-               'desc_fr'     : 'Gestionnaire de scripts.',
-               'requirements': 'python 2.5',
-               'min_weechat' : '0.3.0',
-               'max_weechat' : '',
-               'author'      : 'FlashCode',
-               'mail'        : 'flashcode [at] flashtux [dot] org',
-               'added'       : '2009-04-05 22:39:18',
-               'updated'     : '0000-00-00 00:00:00' }
-    """
-    global wg_scripts, wg_action, wg_action_args
-    wg_scripts = {}
-    try:
-        f = gzip.open(wg_config_get_cache_filename(), "rb")
-        string = f.read()
-        f.close()
-    except:
-        weechat.prnt("", "%s%s: unable to read xml file"
-                     % (weechat.prefix("error"), SCRIPT_NAME))
-    else:
-        try:
-            dom = xml.dom.minidom.parseString(string)
-        except:
-            weechat.prnt("",
-                         "%s%s: unable to parse xml list of scripts"
-                         % (weechat.prefix("error"), SCRIPT_NAME))
-            # discard action
-            wg_action = ""
-            wg_action_args = ""
-        else:
-            for scriptNode in dom.getElementsByTagName("plugin"):
-                id = scriptNode.getAttribute("id")
-                script = {}
-                for node in scriptNode.childNodes:
-                    if node.nodeType == node.ELEMENT_NODE:
-                        if node.firstChild != None:
-                            nodename = node.nodeName
-                            value = node.firstChild.data
-                            if sys.version_info < (3,):
-                                # python 2.x: convert unicode to str (in python 3.x, id and text are already strings)
-                                nodename = nodename.encode("utf-8")
-                                value = value.encode("utf-8")
-                            script[nodename] = value
-                if script["language"] in SCRIPT_EXTENSION:
-                    script["full_name"] = script["name"] + "." + SCRIPT_EXTENSION[script["language"]]