Commits

Woojong Koh  committed 815e83c

Update

* Add bin/parallel_zip.sh file

  • Participants
  • Parent commits c5d124c

Comments (0)

Files changed (26)

 hgext.graphlog =
 hgext.onsub = ~/.hgext/onsub/onsub.py
 hggit =
+hgsubversion = ~/.hgext/hgsubversion/hgsubversion
 mercurial_keyring =
 pager =
 progress =
 shelve =
 
 [hostfingerprints]
-bitbucket.org = 24:9c:45:8b:9c:aa:ba:55:4e:01:6d:58:ff:e4:28:7d:2a:14:ae:3b
+bitbucket.org = 67:b3:bf:9f:c5:38:0e:4c:dd:4e:8a:da:3d:11:1b:c2:a5:d1:6c:6b
 
 %include .hgrc_mac
 hgext.mercurial_keyring = ~/.hgext/mercurial_keyring/mercurial_keyring.py
 
 [hooks]
-commit = hg_commithook.sh
+#commit = hg_commithook.sh
 
 [extdiff]
 cmd.ksdiff = /usr/local/bin/ksdiff
 .oh-my-zsh = [git]https://github.com/robbyrussell/oh-my-zsh.git
 tmux-powerline = [git]https://github.com/erikw/tmux-powerline.git
 
+.hgext/hgsubversion = http://bitbucket.org/durin42/hgsubversion
 .hgext/onsub = https://bitbucket.org/lantiq/onsub
-2719a15b779eef0bfb1d11816c25192ae9ee99b9 .dircolors-solarized
+f5910a643c77b8fb2486fc17b7943a770d395388 .dircolors-solarized
+4a92eb1484ba054a67af8669d862ff720f0a5731 .hgext/hgsubversion
 30bdbd5f6173041fa3e8726195dc21f8fd6082ea .hgext/onsub
-d485044169c2ac18e9e8e7fe29f7d4d93864168a .oh-my-zsh
+ffc17b6b4d55f74b9d3786ba790b7340865e5014 .oh-my-zsh
 ca0ce8fcc49a09eca7eb8ff8003554de2f250901 .vim/bundle/DirDiff.vim
 06c1e16a4dcfd1b8b1764e96482af4b063ca7c8a .vim/bundle/MatlabFilesEdition
 341785bb1bfec38f62d210e2d01ae79f40028e86 .vim/bundle/OmniCppComplete
 2cbe946206ec622d9d8cf2c99317f204c4d41885 .vim/bundle/a.vim
 b5d3fe66a58a13d2ff8b6391f4387608496a030f .vim/bundle/ctrlp.vim
-35280c1444bf62d651f56ccaf03ad8db29c02383 .vim/bundle/delimitMate
+38487bbec8ba50834e257940b357de03991fa8f9 .vim/bundle/delimitMate
 852ddb0c6590bbc41c508d7f5d2fc17112492def .vim/bundle/grep.vim
 eb9fc8676b8959c3c2c95bf6b6e8f0f44317c5c0 .vim/bundle/gundo.vim
 da44ba4a92eef3860bdee2d96d755a7171889a70 .vim/bundle/neocomplcache.vim
 b0bb781fc73ef40365e4c996a16f04368d64fc9d .vim/bundle/nerdtree
 f5a75d075d3c005ebe69e3f5e56cf99516e8aa3b .vim/bundle/snipmate.vim
-ace45adc51d0e08d45761bb515a9ff23906cba65 .vim/bundle/tagbar
-7a1801e9c456d0a043167003afc439543538ef3b .vim/bundle/vim-airline
-a761d9f780b7fe29dc7f717d3852d35204147ab5 .vim/bundle/vim-buffergator
+b2c5f0b9284f85e92d98efc97c780ad01ba81e0c .vim/bundle/tagbar
+5a2daf6dfbd6e0df21612a20f95b4285ae8a2603 .vim/bundle/vim-airline
+c70ac5e3a0330987b8c479a700f0889a0632be2b .vim/bundle/vim-buffergator
 528a59f26d12278698bb946f8fb82a63711eec21 .vim/bundle/vim-colors-solarized
-a3ae0df1d9e13941e9e8086637055841ce93f7bd .vim/bundle/vim-commentary
-6a4d1933ad61ad94f2fa06905337a51cb0304ac1 .vim/bundle/vim-eunuch
-546a6bf2197529ed1bd402244cbf6e72ed62b2ca .vim/bundle/vim-fugitive
+07f79be068dece008c3f38476c93086bf733e165 .vim/bundle/vim-commentary
+e3f3b6f1be3084e0f0811f77a68be0d91a0b14b8 .vim/bundle/vim-eunuch
+3bfa0a27253d12a49331d0d9baa8d1210a816a8d .vim/bundle/vim-fugitive
 78fffa609b3e6b84ef01ee4c9aba6d7435d7b18e .vim/bundle/vim-indent-object
-16e873b2a4a8421fcbcf9a1b57ee0bbfe6bbe358 .vim/bundle/vim-lawrencium
-1270dceb1fe0ca35f8b292c7b41b45b42c5a0cc1 .vim/bundle/vim-pathogen
+a383a816d9759df14a8b964baaa5c321f18c69f1 .vim/bundle/vim-lawrencium
+099b9181413b81deb49e87d6c787d6cfe8b43ea5 .vim/bundle/vim-pathogen
 2a3c5f8e3c26a57b8eb4cfc4be79615a1c508ef6 .vim/bundle/vim-repeat
-159b171e4a72ed3c6813ce3c4ed416a9fe040658 .vim/bundle/vim-signify
+2b05c7fd04b248314841a0238bb81daa881582ee .vim/bundle/vim-signify
 15 .vim/bundle/web-indent
 19afd8812fc1ff8558b7223ce9fb19a28d15d2ff tmux-powerline
 "------------------------------------------------------------
 
 " Customization
-set textwidth=100
+set textwidth=90
 set infercase
 set shiftround
 set number

File .weechat/alias.conf

 #
-# alias.conf -- weechat v0.4.2
+# alias.conf -- weechat v0.4.3
 #
 
 [cmd]

File .weechat/aspell.conf

 #
-# aspell.conf -- weechat v0.4.2
+# aspell.conf -- weechat v0.4.3
 #
 
 [color]

File .weechat/buffers.conf

 #
-# buffers.conf -- weechat v0.4.2
+# buffers.conf -- weechat v0.4.3
 #
 
 [color]
 none_channel_fg = default
 number = lightgreen
 number_char = lightgreen
+prefix_bufname = default
 queries_default_bg = default
 queries_default_fg = default
 queries_highlight_bg = default
 queries_highlight_fg = default
 queries_message_bg = default
 queries_message_fg = default
+suffix_bufname = default
 whitelist_default_bg = default
 whitelist_default_fg = default
 whitelist_highlight_bg = default
 [look]
 core_to_front = off
 detach = 0
+detach_buffer_immediately = ""
+detach_display_window_number = off
+detach_displayed_buffers = on
 detach_free_content = off
 detach_query = off
 hide_merged_buffers = none
 indenting_number = on
 jump_prev_next_visited_buffer = off
 mark_inactive = off
+mouse_move_buffer = on
 name_crop_suffix = "+"
 name_size_max = 0
 number_char = "."
 prefix = off
+prefix_bufname = ""
 prefix_empty = on
+prefix_for_query = ""
 short_names = on
 show_lag = off
 show_number = on
 sort = number
+suffix_bufname = ""
+toogle_bar = on
 whitelist_buffers = ""

File .weechat/charset.conf

 #
-# charset.conf -- weechat v0.4.2
+# charset.conf -- weechat v0.4.3
 #
 
 [default]

File .weechat/logger.conf

 #
-# logger.conf -- weechat v0.4.2
+# logger.conf -- weechat v0.4.3
 #
 
 [look]

File .weechat/perl/buffers.pl

 #
-# Copyright (C) 2008-2012 Sebastien Helleu <flashcode@flashtux.org>
-# Copyright (C) 2011-2012 Nils G <weechatter@arcor.de>
+# Copyright (C) 2008-2014 Sebastien Helleu <flashcode@flashtux.org>
+# Copyright (C) 2011-2013 Nils G <weechatter@arcor.de>
 #
 # 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
 #
 # History:
 #
+# 2014-01-01, Sebastien Helleu <flashcode@flashtux.org>:
+#     v4.5: add option "mouse_move_buffer"
+# 2013-12-11, Sebastien Helleu <flashcode@flashtux.org>:
+#     v4.4: fix buffer number on drag to the end of list when option
+#           weechat.look.buffer_auto_renumber is off
+# 2013-12-10, nils_2@freenode.#weechat:
+#     v4.3: add options "prefix_bufname" and "suffix_bufname (idea by silverd)
+#         : fix hook_timer() for show_lag wasn't disabled
+#         : improved signal handling (less updating of buffers list)
+# 2013-11-07, Sebastien Helleu <flashcode@flashtux.org>:
+#     v4.2: use default filling "columns_vertical" when bar position is top/bottom
+# 2013-10-31, nils_2@freenode.#weechat:
+#     v4.1: add option "detach_buffer_immediately" (idea by farn)
+# 2013-10-20, nils_2@freenode.#weechat:
+#     v4.0: add options "detach_displayed_buffers", "detach_display_window_number"
+# 2013-09-27, nils_2@freenode.#weechat:
+#     v3.9: add option "toggle_bar" and option "show_prefix_query" (idea by IvarB)
+#         : fix problem with linefeed at end of list of buffers (reported by grawity)
 # 2012-10-18, nils_2@freenode.#weechat:
 #     v3.8: add option "mark_inactive", to mark buffers you are not in (idea by xrdodrx)
 #         : add wildcard "*" for immune_detach_buffers (idea by StarWeaver)
 use strict;
 use Encode qw( decode encode );
 # -------------------------------[ internal ]-------------------------------------
-my $version = "3.8";
+my $SCRIPT_NAME = "buffers";
+my $SCRIPT_VERSION = "4.5";
 
 my $BUFFERS_CONFIG_FILE_NAME = "buffers";
 my $buffers_config_file;
 my %hotlist_level       = (0 => "low", 1 => "message", 2 => "private", 3 => "highlight");
 my @whitelist_buffers   = ();
 my @immune_detach_buffers= ();
+my @detach_buffer_immediately= ();
 my @buffers_focus       = ();
 my %buffers_timer       = ();
 my %Hooks               = ();
 
 # --------------------------------[ init ]--------------------------------------
-weechat::register("buffers", "Sebastien Helleu <flashcode\@flashtux.org>", $version,
-                  "GPL3", "Sidebar with list of buffers", "", "");
+weechat::register($SCRIPT_NAME, "Sebastien Helleu <flashcode\@flashtux.org>", $SCRIPT_VERSION,
+                  "GPL3", "Sidebar with list of buffers", "shutdown_cb", "");
 my $weechat_version = weechat::info_get("version_number", "") || 0;
 
 buffers_config_init();
 buffers_config_read();
 
-weechat::bar_item_new("buffers", "build_buffers", "");
-weechat::bar_new("buffers", "0", "0", "root", "", "left", "horizontal",
+weechat::bar_item_new($SCRIPT_NAME, "build_buffers", "");
+weechat::bar_new($SCRIPT_NAME, "0", "0", "root", "", "left", "columns_vertical",
                  "vertical", "0", "0", "default", "default", "default", "1",
-                 "buffers");
-weechat::hook_signal("buffer_*", "buffers_signal_buffer", "");
+                 $SCRIPT_NAME);
+
+if ( check_bar_item() == 0 )
+{
+    weechat::command("","/bar show " . $SCRIPT_NAME) if ( weechat::config_boolean($options{"toggle_bar"}) eq 1 );
+}
+
+weechat::hook_signal("buffer_opened", "buffers_signal_buffer", "");
+weechat::hook_signal("buffer_closed", "buffers_signal_buffer", "");
+weechat::hook_signal("buffer_merged", "buffers_signal_buffer", "");
+weechat::hook_signal("buffer_unmerged", "buffers_signal_buffer", "");
+weechat::hook_signal("buffer_moved", "buffers_signal_buffer", "");
+weechat::hook_signal("buffer_renamed", "buffers_signal_buffer", "");
+weechat::hook_signal("buffer_switch", "buffers_signal_buffer", "");
+
 weechat::hook_signal("window_switch", "buffers_signal_buffer", "");
-weechat::hook_signal("hotlist_*", "buffers_signal_hotlist", "");
-weechat::hook_signal("window_switch", "buffers_signal_buffer", "");
+weechat::hook_signal("hotlist_changed", "buffers_signal_hotlist", "");
 #weechat::hook_command_run("/input switch_active_*", "buffers_signal_buffer", "");
-weechat::bar_item_update("buffers");
+weechat::bar_item_update($SCRIPT_NAME);
+
+
 if ($weechat_version >= 0x00030600)
 {
-    weechat::hook_focus("buffers", "buffers_focus_buffers", "");
+    weechat::hook_focus($SCRIPT_NAME, "buffers_focus_buffers", "");
     weechat::hook_hsignal("buffers_mouse", "buffers_hsignal_mouse", "");
     weechat::key_bind("mouse", \%mouse_keys);
 }
 if ($weechat_version >= 0x00030800)
 {
     weechat::hook_config("buffers.look.detach", "hook_timer_detach", "");
+    $Hooks{timer_detach} = weechat::hook_timer( weechat::config_integer( $options{"detach"}) * 1000, 60, 0, "buffers_signal_hotlist", "") if ( weechat::config_integer( $options{"detach"}) > 0 );
 }
 
     weechat::hook_config("buffers.look.show_lag", "hook_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", "") if ( weechat::config_boolean($options{"show_lag"}) );
+
 # -------------------------------- [ command ] --------------------------------
 sub buffers_cmd_whitelist
 {
 }
 sub buffers_cmd_detach
 {
-my ( $data, $buffer, $args ) = @_;
+    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(), "");
     }
     return weechat::WEECHAT_RC_OK;
 }
+
 sub create_whitelist
 {
     my @buffers_list = @{$_[0]};
     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", "");
+        $Hooks{timer_detach} = weechat::hook_timer( weechat::config_integer( $options{"detach"}) * 1000, 60, 0, "buffers_signal_hotlist", "");
     }
-    weechat::bar_item_update("buffers");
+    weechat::bar_item_update($SCRIPT_NAME);
     return weechat::WEECHAT_RC_OK;
 }
 
 sub hook_timer_lag
 {
     my $lag = $_[2];
-    if ( $lag eq 0 )
+    if ( $lag eq "off" )
     {
         weechat::unhook($Hooks{timer_lag}) if $Hooks{timer_lag};
         $Hooks{timer_lag} = "";
         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");
+    weechat::bar_item_update($SCRIPT_NAME);
     return weechat::WEECHAT_RC_OK;
 }
 
     return if ($buffers_config_file eq "");
 
 my %default_options_color =
-("color_current_fg" => ["current_fg", "color", "foreground color for current buffer", "", 0, 0,"lightcyan", "lightcyan", 0, "", "","buffers_signal_config", "", "", ""],
- "color_current_bg" => ["current_bg", "color", "background color for current buffer", "", 0, 0,"red", "red", 0, "", "","buffers_signal_config", "", "", ""],
- "color_default_fg" => ["default_fg", "color", "default foreground color for buffer name", "", 0, 0,"default", "default", 0, "", "","buffers_signal_config", "", "", ""],
- "color_default_bg" => ["default_bg", "color", "default background color for buffer name", "", 0, 0,"default", "default", 0, "", "","buffers_signal_config", "", "", ""],
- "color_hotlist_highlight_fg" => ["hotlist_highlight_fg", "color", "change foreground color of buffer name if a highlight messaged received","", 0, 0,"magenta", "magenta", 0, "", "","buffers_signal_config", "", "", ""],
- "color_hotlist_highlight_bg" => ["hotlist_highlight_bg", "color", "change background color of buffer name if a highlight messaged received", "", 0, 0,"default", "default", 0, "", "","buffers_signal_config", "", "", ""],
- "color_hotlist_low_fg" => ["hotlist_low_fg", "color", "change foreground color of buffer name if a low message received", "", 0, 0,"white", "white", 0, "", "","buffers_signal_config", "", "", ""],
+("color_current_fg" => ["current_fg", "color", "foreground color for current buffer", "", 0, 0, "lightcyan", "lightcyan", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_current_bg" => ["current_bg", "color", "background color for current buffer", "", 0, 0, "red", "red", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_default_fg" => ["default_fg", "color", "default foreground color for buffer name", "", 0, 0, "default", "default", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_default_bg" => ["default_bg", "color", "default background color for buffer name", "", 0, 0, "default", "default", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_hotlist_highlight_fg" => ["hotlist_highlight_fg", "color", "change foreground color of buffer name if a highlight messaged received", "", 0, 0, "magenta", "magenta", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_hotlist_highlight_bg" => ["hotlist_highlight_bg", "color", "change background color of buffer name if a highlight messaged received", "", 0, 0, "default", "default", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_hotlist_low_fg" => ["hotlist_low_fg", "color", "change foreground color of buffer name if a low message received", "", 0, 0, "white", "white", 0, "", "", "buffers_signal_config", "", "", ""],
  "color_hotlist_low_bg" => ["hotlist_low_bg", "color", "change background color of buffer name if a low message received", "", 0, 0,
-        "default", "default", 0, "", "","buffers_signal_config", "", "", ""],
- "color_hotlist_message_fg" => ["hotlist_message_fg", "color", "change foreground color of buffer name if a normal message received", "", 0, 0,"yellow", "yellow", 0, "", "","buffers_signal_config", "", "", ""],
- "color_hotlist_message_bg" => ["hotlist_message_bg", "color", "change background color of buffer name if a normal message received", "", 0, 0,"default", "default", 0, "", "","buffers_signal_config", "", "", ""],
- "color_hotlist_private_fg" => ["hotlist_private_fg", "color", "change foreground color of buffer name if a private message received", "", 0, 0,"lightgreen", "lightgreen", 0, "", "","buffers_signal_config", "", "", ""],
- "color_hotlist_private_bg" => ["hotlist_private_bg", "color", "change background color of buffer name if a private message received", "", 0, 0,"default", "default", 0, "", "","buffers_signal_config", "", "", ""],
- "color_number" => ["number", "color", "color for buffer number", "", 0, 0,"lightgreen", "lightgreen", 0, "", "","buffers_signal_config", "", "", ""],
- "color_number_char" => ["number_char", "color", "color for buffer number char", "", 0, 0,"lightgreen", "lightgreen", 0, "", "","buffers_signal_config", "", "", ""],
- "color_whitelist_default_fg" => ["whitelist_default_fg", "color", "default foreground color for whitelist buffer name", "", 0, 0,"", "", 0, "", "","buffers_signal_config", "", "", ""],
- "color_whitelist_default_bg" => ["whitelist_default_bg", "color", "default background color for whitelist buffer name", "", 0, 0,"", "", 0, "", "","buffers_signal_config", "", "", ""],
- "color_whitelist_low_fg" => ["whitelist_low_fg", "color", "low color of whitelist buffer name", "", 0, 0,"", "", 0, "", "","buffers_signal_config", "", "", ""],
- "color_whitelist_low_bg" => ["whitelist_low_bg", "color", "low color of whitelist buffer name", "", 0, 0,"", "", 0, "", "","buffers_signal_config", "", "", ""],
- "color_whitelist_message_fg" => ["whitelist_message_fg", "color", "message color of whitelist buffer name", "", 0, 0,"", "", 0, "", "","buffers_signal_config", "", "", ""],
- "color_whitelist_message_bg" => ["whitelist_message_bg", "color", "message color of whitelist buffer name", "", 0, 0,"", "", 0, "", "","buffers_signal_config", "", "", ""],
- "color_whitelist_private_fg" => ["whitelist_private_fg", "color", "private color of whitelist buffer name", "", 0, 0,"", "", 0, "", "","buffers_signal_config", "", "", ""],
- "color_whitelist_private_bg" => ["whitelist_private_bg", "color", "private color of whitelist buffer name", "", 0, 0,"", "", 0, "", "","buffers_signal_config", "", "", ""],
- "color_whitelist_highlight_fg" => ["whitelist_highlight_fg", "color", "highlight color of whitelist buffer name", "", 0, 0,"", "", 0, "", "","buffers_signal_config", "", "", ""],
- "color_whitelist_highlight_bg" => ["whitelist_highlight_bg", "color", "highlight color of whitelist buffer name", "", 0, 0,"", "", 0, "", "","buffers_signal_config", "", "", ""],
- "color_none_channel_fg" => ["none_channel_fg", "color", "foreground color for none channel buffer (e.g.: core/server/plugin buffer)", "", 0, 0,"default", "default", 0, "", "","buffers_signal_config", "", "", ""],
- "color_none_channel_bg" => ["none_channel_bg", "color", "background color for none channel buffer (e.g.: core/server/plugin buffer)", "", 0, 0,"default", "default", 0, "", "","buffers_signal_config", "", "", ""],
- "queries_default_fg" => ["queries_default_fg", "color", "foreground color for query buffer without message", "", 0, 0,"default", "default", 0, "", "","buffers_signal_config", "", "", ""],
- "queries_default_bg" => ["queries_default_bg", "color", "background color for query buffer without message", "", 0, 0,"default", "default", 0, "", "","buffers_signal_config", "", "", ""],
- "queries_message_fg" => ["queries_message_fg", "color", "foreground color for query buffer with unread message", "", 0, 0,"default", "default", 0, "", "","buffers_signal_config", "", "", ""],
- "queries_message_bg" => ["queries_message_bg", "color", "background color for query buffer with unread message", "", 0, 0,"default", "default", 0, "", "","buffers_signal_config", "", "", ""],
- "queries_highlight_fg" => ["queries_highlight_fg", "color", "foreground color for query buffer with unread highlight", "", 0, 0,"default", "default", 0, "", "","buffers_signal_config", "", "", ""],
- "queries_highlight_bg" => ["queries_highlight_bg", "color", "background color for query buffer with unread highlight", "", 0, 0,"default", "default", 0, "", "","buffers_signal_config", "", "", ""],
+        "default", "default", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_hotlist_message_fg" => ["hotlist_message_fg", "color", "change foreground color of buffer name if a normal message received", "", 0, 0, "yellow", "yellow", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_hotlist_message_bg" => ["hotlist_message_bg", "color", "change background color of buffer name if a normal message received", "", 0, 0, "default", "default", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_hotlist_private_fg" => ["hotlist_private_fg", "color", "change foreground color of buffer name if a private message received", "", 0, 0, "lightgreen", "lightgreen", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_hotlist_private_bg" => ["hotlist_private_bg", "color", "change background color of buffer name if a private message received", "", 0, 0, "default", "default", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_number" => ["number", "color", "color for buffer number", "", 0, 0, "lightgreen", "lightgreen", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_number_char" => ["number_char", "color", "color for buffer number char", "", 0, 0, "lightgreen", "lightgreen", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_whitelist_default_fg" => ["whitelist_default_fg", "color", "default foreground color for whitelist buffer name", "", 0, 0, "", "", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_whitelist_default_bg" => ["whitelist_default_bg", "color", "default background color for whitelist buffer name", "", 0, 0, "", "", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_whitelist_low_fg" => ["whitelist_low_fg", "color", "low color of whitelist buffer name", "", 0, 0, "", "", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_whitelist_low_bg" => ["whitelist_low_bg", "color", "low color of whitelist buffer name", "", 0, 0, "", "", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_whitelist_message_fg" => ["whitelist_message_fg", "color", "message color of whitelist buffer name", "", 0, 0, "", "", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_whitelist_message_bg" => ["whitelist_message_bg", "color", "message color of whitelist buffer name", "", 0, 0, "", "", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_whitelist_private_fg" => ["whitelist_private_fg", "color", "private color of whitelist buffer name", "", 0, 0, "", "", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_whitelist_private_bg" => ["whitelist_private_bg", "color", "private color of whitelist buffer name", "", 0, 0, "", "", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_whitelist_highlight_fg" => ["whitelist_highlight_fg", "color", "highlight color of whitelist buffer name", "", 0, 0, "", "", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_whitelist_highlight_bg" => ["whitelist_highlight_bg", "color", "highlight color of whitelist buffer name", "", 0, 0, "", "", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_none_channel_fg" => ["none_channel_fg", "color", "foreground color for none channel buffer (e.g.: core/server/plugin buffer)", "", 0, 0, "default", "default", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_none_channel_bg" => ["none_channel_bg", "color", "background color for none channel buffer (e.g.: core/server/plugin buffer)", "", 0, 0, "default", "default", 0, "", "", "buffers_signal_config", "", "", ""],
+ "queries_default_fg" => ["queries_default_fg", "color", "foreground color for query buffer without message", "", 0, 0, "default", "default", 0, "", "", "buffers_signal_config", "", "", ""],
+ "queries_default_bg" => ["queries_default_bg", "color", "background color for query buffer without message", "", 0, 0, "default", "default", 0, "", "", "buffers_signal_config", "", "", ""],
+ "queries_message_fg" => ["queries_message_fg", "color", "foreground color for query buffer with unread message", "", 0, 0, "default", "default", 0, "", "", "buffers_signal_config", "", "", ""],
+ "queries_message_bg" => ["queries_message_bg", "color", "background color for query buffer with unread message", "", 0, 0, "default", "default", 0, "", "", "buffers_signal_config", "", "", ""],
+ "queries_highlight_fg" => ["queries_highlight_fg", "color", "foreground color for query buffer with unread highlight", "", 0, 0, "default", "default", 0, "", "", "buffers_signal_config", "", "", ""],
+ "queries_highlight_bg" => ["queries_highlight_bg", "color", "background color for query buffer with unread highlight", "", 0, 0, "default", "default", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_prefix_bufname" => ["prefix_bufname", "color", "color for prefix of buffer name", "", 0, 0, "default", "default", 0, "", "", "buffers_signal_config", "", "", ""],
+ "color_suffix_bufname" => ["suffix_bufname", "color", "color for suffix of buffer name", "", 0, 0, "default", "default", 0, "", "", "buffers_signal_config", "", "", ""],
 );
 
 my %default_options_look =
 (
- "hotlist_counter"      =>      ["hotlist_counter","boolean","show number of message for the buffer (this option needs WeeChat >= 0.3.5). The relevant option for notification is \"weechat.look.buffer_notify_default\"","",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 seperated list of buffers to NOT automatically detatch. Allows \"*\" wildcard. Ex: \"BitlBee,freenode.*\"", "", 0, 0,"", "", 0, "", "", "buffers_signal_config_immune_detach_buffers", "", "", ""],
- "detach_query"         =>      ["detach_query", "boolean", "query buffer will be detachted", "", 0, 0,"off", "off", 0, "", "", "buffers_signal_config", "", "", ""],
- "detach_free_content"  =>      ["detach_free_content", "boolean", "buffers with free content will be detached (Ex: iset, chanmon)", "", 0, 0,"off", "off", 0, "", "", "buffers_signal_config", "", "", ""],
- "mark_inactive"        =>      ["mark_inactive", "boolean", "if option is \"on\", inactive buffers (those you are not in) will have parentesis around them. An inactive buffer will not be detached.", "", 0, 0,"off", "off", 0, "", "", "buffers_signal_config", "", "", ""],
+ "hotlist_counter" => ["hotlist_counter", "boolean", "show number of message for the buffer (this option needs WeeChat >= 0.3.5). The relevant option for notification is \"weechat.look.buffer_notify_default\"", "", 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 behind channel number", "", 0, 0, ".", ".", 0, "", "", "buffers_signal_config", "", "", ""],
+ "show_prefix_bufname" => ["prefix_bufname", "string", "prefix displayed in front of buffername", "", 0, 0, "", "", 0, "", "", "buffers_signal_config", "", "", ""],
+ "show_suffix_bufname" => ["suffix_bufname", "string", "suffix displayed at end of buffername", "", 0, 0, "", "", 0, "", "", "buffers_signal_config", "", "", ""],
+ "show_prefix" => ["prefix", "boolean", "displays your prefix for channel in front of buffername", "", 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", "", "", ""],
+ "show_prefix_query" => ["prefix_for_query", "string", "prefix displayed in front of query buffer", "", 0, 0, "", "", 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 means \"off\")", "", 0, 31536000, 0, "number", 0, "", "", "buffers_signal_config", "", "", ""],
+ "immune_detach_buffers" => ["immune_detach_buffers", "string", "comma separated list of buffers to NOT automatically detatch. Allows \"*\" wildcard. Ex: \"BitlBee,freenode.*\"", "", 0, 0, "", "", 0, "", "", "buffers_signal_config_immune_detach_buffers", "", "", ""],
+ "detach_query" => ["detach_query", "boolean", "query buffer will be detachted", "", 0, 0, "off", "off", 0, "", "", "buffers_signal_config", "", "", ""],
+ "detach_buffer_immediately" => ["detach_buffer_immediately", "string", "comma separated list of buffers to detach immediately. A query and highlight message will attach buffer again. Allows \"*\" wildcard. Ex: \"BitlBee,freenode.*\"", "", 0, 0, "", "", 0, "", "", "buffers_signal_config_detach_buffer_immediately", "", "", ""],
+ "detach_free_content" => ["detach_free_content", "boolean", "buffers with free content will be detached (Ex: iset, chanmon)", "", 0, 0, "off", "off", 0, "", "", "buffers_signal_config", "", "", ""],
+ "detach_displayed_buffers" => ["detach_displayed_buffers", "boolean", "buffers displayed in a (split) window will be detached", "", 0, 0, "on", "on", 0, "", "", "buffers_signal_config", "", "", ""],
+ "detach_display_window_number" => ["detach_display_window_number", "boolean", "window number will be add, behind buffer name (this option takes only effect with \"detach_displayed_buffers\" option)", "", 0, 0, "off", "off", 0, "", "", "buffers_signal_config", "", "", ""],
+ "mark_inactive" => ["mark_inactive", "boolean", "if option is \"on\", inactive buffers (those you are not in) will have parentesis around them. An inactive buffer will not be detached.", "", 0, 0, "off", "off", 0, "", "", "buffers_signal_config", "", "", ""],
+ "toggle_bar" => ["toogle_bar", "boolean", "if option is \"on\", buffers bar will hide/show when script is (un)loaded.", "", 0, 0, "on", "on", 0, "", "", "buffers_signal_config", "", "", ""],
+ "mouse_move_buffer" => ["mouse_move_buffer", "boolean", "if option is \"on\", mouse gestures (drag & drop) can move buffers in list.", "", 0, 0, "on", "on", 0, "", "", "buffers_signal_config", "", "", ""],
 );
     # section "color"
     my $section_color = weechat::config_new_section($buffers_config_file,"color", 0, 0, "", "", "", "", "", "", "", "", "", "");
         $default_options_look{$option}[3],$default_options_look{$option}[4],$default_options_look{$option}[5],
         $default_options_look{$option}[6],$default_options_look{$option}[7],$default_options_look{$option}[8],
         $default_options_look{$option}[9],$default_options_look{$option}[10],$default_options_look{$option}[11],
-        $default_options_look{$option}[12],$default_options_look{$option}[13],$default_options_look{$option}[14]);
+        $default_options_look{$option}[12],$default_options_look{$option}[13],$default_options_look{$option}[14],
+        $default_options_look{$option}[15]);
     }
 }
 
         $buffer->{"number"} = $number;
         $buffer->{"active"} = $active;
         $buffer->{"current_buffer"} = weechat::infolist_integer($infolist, "current_buffer");
+        $buffer->{"num_displayed"} = weechat::infolist_integer($infolist, "num_displayed");
         $buffer->{"plugin_name"} = weechat::infolist_string($infolist, "plugin_name");
         $buffer->{"name"} = weechat::infolist_string($infolist, "name");
         $buffer->{"short_name"} = weechat::infolist_string($infolist, "short_name");
         }
 
         my $result = check_immune_detached_buffers($buffer->{"name"});          # checking for wildcard 
+
+        next if ( check_detach_buffer_immediately($buffer->{"name"}) eq 1
+                 and $buffer->{"current_buffer"} eq 0
+                 and ( not exists $hotlist{$buffer->{"pointer"}} or $hotlist{$buffer->{"pointer"}} < 2) );          # checking for buffer to immediately detach
+
         unless ($result)
         {
             my $detach_time = weechat::config_integer( $options{"detach"});
                     push(@current1, $buffer);
                 }
             }
+            elsif ( $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)
+            {   # check for option detach_displayed_buffers and if buffer is displayed in a split window
+                if ( $buffer->{"num_displayed"} eq 1
+                    and weechat::config_boolean($options{"detach_displayed_buffers"}) eq 0 )
+                {
+                    my $infolist_window = weechat::infolist_get("window","","");
+                    while (weechat::infolist_next($infolist_window))
+                    {
+                        my $buffer_ptr = weechat::infolist_pointer($infolist_window, "buffer");
+                        if ($buffer_ptr eq $buffer->{"pointer"})
+                        {
+                            $buffer->{"window"} = weechat::infolist_integer($infolist_window, "number");
+                        }
+                    }
+                    weechat::infolist_free($infolist_window);
+
+                    push(@current2, $buffer);
+                }
+            }
         }
         else    # buffer in "immune_detach_buffers"
         {
         $color_bg = weechat::color(",".$bg) if ($bg ne "");
 
         # create channel number for output
+        if ( weechat::config_string( $options{"show_prefix_bufname"} ) ne "" )
+        {
+            $str .= $color_bg .
+                    weechat::color( weechat::config_color( $options{"color_prefix_bufname"} ) ).
+                    weechat::config_string( $options{"show_prefix_bufname"} ).
+                    weechat::color("default");
+        }
+
         if ( weechat::config_boolean( $options{"show_number"} ) eq 1 )   # on
         {
             if (( weechat::config_boolean( $options{"indenting_number"} ) eq 1)
                 }
             }
         }
+
+        $str .= weechat::config_string( $options{"show_prefix_query"}) if (weechat::config_string( $options{"show_prefix_query"} ) ne "" and  $buffer->{"type"} eq "private");
+
         if (weechat::config_boolean( $options{"show_prefix"} ) eq 1)
         {
             my $nickname = weechat::buffer_get_string($buffer->{"pointer"}, "localvar_nick");
                 my $infolist_nick = weechat::infolist_get("nicklist", $buffer->{"pointer"}, "nick_".$nickname);
                 if ($infolist_nick ne "")
                 {
-                    my $version = weechat::info_get("version_number", "");
-                    $version = 0 if ($version eq "");
                     while (weechat::infolist_next($infolist_nick))
                     {
                         if ((weechat::infolist_string($infolist_nick, "type") eq "nick")
                             if (($prefix ne " ") or (weechat::config_boolean( $options{"show_prefix_empty"} ) eq 1))
                             {
                                 # with version >= 0.3.5, it is now a color name (for older versions: option name with color)
-                                if (int($version) >= 0x00030500)
+                                if (int($weechat_version) >= 0x00030500)
                                 {
                                     $str .= weechat::color(weechat::infolist_string($infolist_nick, "prefix_color"));
                                 }
                 $str .= weechat::color("default") . " (" . weechat::color($color_lag) . $lag . weechat::color("default") . ")";
             }
         }
+        if (weechat::config_boolean($options{"detach_displayed_buffers"}) eq 0
+            and weechat::config_boolean($options{"detach_display_window_number"}) eq 1)
+        {
+            if ($buffer->{"window"})
+            {
+                $str .= weechat::color("default") . " (" . weechat::color(weechat::config_color( $options{"color_number"})) . $buffer->{"window"} . weechat::color("default") . ")";
+            }
+        }
+        $str .= weechat::color("default");
+
+        if ( weechat::config_string( $options{"show_suffix_bufname"} ) ne "" )
+        {
+            $str .= weechat::color( weechat::config_color( $options{"color_suffix_bufname"} ) ).
+                    weechat::config_string( $options{"show_suffix_bufname"} ).
+                    weechat::color("default");
+        }
+
         $str .= "\n";
         $old_number = $buffer->{"number"};
     }
 
+    # remove spaces and/or linefeed at the end
+    $str =~ s/\s+$//;
+    chomp($str);
     return $str;
 }
 
 
 sub buffers_signal_buffer
 {
-my ($data, $signal, $signal_data) = @_;
+    my ($data, $signal, $signal_data) = @_;
+
     # check for buffer_switch and set or remove detach time
     if ($weechat_version >= 0x00030800)
     {
             delete $buffers_timer{$signal_data};
         }
     }
-
-    weechat::bar_item_update("buffers");
+    weechat::bar_item_update($SCRIPT_NAME);
     return weechat::WEECHAT_RC_OK;
 }
 
 sub buffers_signal_hotlist
 {
-    weechat::bar_item_update("buffers");
+    weechat::bar_item_update($SCRIPT_NAME);
     return weechat::WEECHAT_RC_OK;
 }
 
 {
     @whitelist_buffers = ();
     @whitelist_buffers = split( /,/, weechat::config_string( $options{"look_whitelist_buffers"} ) );
-    weechat::bar_item_update("buffers");
+    weechat::bar_item_update($SCRIPT_NAME);
     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");
+    weechat::bar_item_update($SCRIPT_NAME);
+    return weechat::WEECHAT_RC_OK;
+}
+
+sub buffers_signal_config_detach_buffer_immediately
+{
+    @detach_buffer_immediately = ();
+    @detach_buffer_immediately = split( /,/, weechat::config_string( $options{"detach_buffer_immediately"} ) );
+    weechat::bar_item_update($SCRIPT_NAME);
     return weechat::WEECHAT_RC_OK;
 }
 
 sub buffers_signal_config
 {
-    weechat::bar_item_update("buffers");
+    weechat::bar_item_update($SCRIPT_NAME);
     return weechat::WEECHAT_RC_OK;
 }
 
     my %info = %{$_[1]};
     my $item_line = int($info{"_bar_item_line"});
     undef my $hash;
-    if (($info{"_bar_item_name"} eq "buffers") && ($item_line >= 0) && ($item_line <= $#buffers_focus))
+    if (($info{"_bar_item_name"} eq $SCRIPT_NAME) && ($item_line >= 0) && ($item_line <= $#buffers_focus))
     {
         $hash = $buffers_focus[$item_line];
     }
 
     if ( $hash{"_key"} eq "button1" )           # left mouse button
     {
-      if ($hash{"number"} eq $hash{"number2"})
+        if ($hash{"number"} eq $hash{"number2"})
         {
             if ( weechat::config_integer($options{"jump_prev_next_visited_buffer"}) eq 1 )
             {
         }
         else
         {
-            move_buffer(%hash);
+            move_buffer(%hash) if (weechat::config_boolean($options{"mouse_move_buffer"}));
         }
     }
     elsif ( ($hash{"_key"} eq "button2") && (weechat::config_integer($options{"jump_prev_next_visited_buffer"}) eq 1) )# right mouse button
         }
         else
         {
-            move_buffer(%hash);
+            move_buffer(%hash) if (weechat::config_boolean($options{"mouse_move_buffer"}));
         }
     }
 }
   {
       # if number 2 is not known (end of gesture outside buffers list), then set it
       # according to mouse gesture
-      $number2 = "999999";
-      $number2 = "1" if (($hash{"_key"} =~ /gesture-left/) || ($hash{"_key"} =~ /gesture-up/));
+      $number2 = "1";
+      if (($hash{"_key"} =~ /gesture-right/) || ($hash{"_key"} =~ /gesture-down/))
+      {
+          $number2 = "999999";
+          if ($weechat_version >= 0x00030600)
+          {
+              my $hdata_buffer = weechat::hdata_get("buffer");
+              my $last_gui_buffer = weechat::hdata_get_list($hdata_buffer, "last_gui_buffer");
+              if ($last_gui_buffer)
+              {
+                  $number2 = weechat::hdata_integer($hdata_buffer, $last_gui_buffer, "number") + 1;
+              }
+          }
+      }
   }
   my $ptrbuf = weechat::current_buffer();
   weechat::command($hash{"pointer"}, "/buffer move ".$number2);
     }
     return 0;
 }
+
+sub check_detach_buffer_immediately
+{
+    my ($buffername) = @_;
+    foreach ( @detach_buffer_immediately ){
+        my $detach_buffer = weechat::string_mask_to_regex($_);
+        if ($buffername =~ /^$detach_buffer$/i)
+        {
+            return 1;
+        }
+    }
+    return 0;
+}
+
+sub shutdown_cb
+{
+    weechat::command("","/bar hide " . $SCRIPT_NAME) if ( weechat::config_boolean($options{"toggle_bar"}) eq 1 );
+    return weechat::WEECHAT_RC_OK
+}
+
+sub check_bar_item
+{
+    my $item = 0;
+    my $infolist = weechat::infolist_get("bar", "", "");
+    while (weechat::infolist_next($infolist))
+    {
+        my $bar_items = weechat::infolist_string($infolist, "items");
+        if (index($bar_items,$SCRIPT_NAME) != -1)
+        {
+            my $name = weechat::infolist_string($infolist, "name");
+            if ($name ne $SCRIPT_NAME)
+            {
+                $item = 1;
+                last;
+            }
+        }
+    }
+    weechat::infolist_free($infolist);
+    return $item;
+}

File .weechat/perl/colorize_lines.pl

 #
 # Copyright (c) 2010-2013 by Nils Görs <weechatter@arcor.de>
+# Copyleft (ɔ) 2013 by oakkitten
 #
 # colors the channel text with nick color and also highlight the whole line
 # colorize_nicks.py script will be supported
 #
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#
-# for settings see help page
-#
+
+# with version 3.0 some options were renamed or have new possible values:
+# old:                  new:
+# avail_buffer          buffer
+# blacklist_channels    blacklist_buffers
+# highlight             new values
+
+# obsolete options:
+# buffer_autoset
+# hotlist_max_level_nicks_add
+# highlight_regex
+# highlight_words
+# shuffle
+# chat                  see option highlight
+
+# i recommend to remove all colorize_lines options, first:
+# /script unload colorize_lines
+# /unset plugins.var.perl.colorize_lines.*
+# /unset plugins.desc.perl.colorize_lines*
+# /script load colorize_lines.pl
+
 # history:
+# 3.2: minor logic fix
+# 3.1: fix: line wasn't colored with nick color, when highlight option was "off" (reported by rivarun)
+# 3.0: large part of script rewritten
+#      fix: works nicely with colors
+#      improved: highlight_regex and highlight_words work in a natural way
+#      removed: /colorize_lines
+#      removed: shuffle
+# 2.2: fix: regex with [tab] in message (patch by sqrrl)
+# 2.1: fix: changing highlight color did not apply messages already displayed (reported by rafi_)
+# 2.0: fix: debugging weechat::print() removed (thanks demure)
 # 1.9: fix: display bug with nick_mode
 # 1.8  add: option "use_irc_colors" (requested by Zertap)
 #      fix: empty char for nick_mode was used, even when "irc.look.nick_mode_empty" was OFF (reported by FlashCode)
 #    : clean up code
 # 0.8.1: fix: regex()
 # 0.8: added: option "avail_buffer" and "nicks" (please read help-page) (suggested by ldvx)
-#    : fix: blacklist_channels wasn't load at start
+#    : fix: blacklist_buffers 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: fix: bug when irc.look.nick_suffix was set (reported and beta-testing by: hw2) (>= weechat 0.3.4)
-#      blacklist_channels option supports servername
+#      blacklist_buffers option supports servername
 #      clean up code
 # 0.6: code optimazations.
 #      rename of script (rainbow_text.pl -> colorize_lines.pl) (suggested by xt and flashcode)
 # Development is currently hosted at
 # https://github.com/weechatter/weechat-scripts
 #
-# requirements: sunglasses ;-)
+
+#use Data::Dumper
+#$Data::Dumper::Useqq=1;
 
 use strict;
-my $prgname	= "colorize_lines";
-my $version	= "1.9";
-my $description	= "colors text in chat area with according nick color. Highlight messages will be fully highlighted in chat area";
+my $prgname     = "colorize_lines";
+my $version     = "3.2";
+my $description = "colors text in chat area with according nick color, including highlights";
 
-# default values
-my %default_options = ( "var_highlight"                         => "on",        # script options in weechat
-                        "var_avail_buffer"                      => "all",       # all, channel, query
-                        "var_chat"                              => "on",
-                        "var_shuffle"                           => "off",
-                        "var_buffer_autoset"                    => "off",
-                        "var_look_highlight"                    => "off",
-                        "var_look_highlight_regex"              => "off",
-                        "var_hotlist_max_level_nicks_add"	=> "off",
-                        "var_blacklist_channels"                => "",
-                        "var_nicks"                             => "",
-                        "var_own_lines"                         => "off",
-                        "var_use_irc_colors"                    => "off",
+my %config = ("buffers"             => "all",       # all, channel, query
+              "blacklist_buffers"   => "",          # "a,b,c"
+              "lines"               => "on",
+              "highlight"           => "on",        # on, off, nicks
+              "nicks"               => "",          # "d,e,f", "/file"
+              "own_lines"           => "on",        # on, off, only
 );
 
-my %help_desc = ( "avail_buffer"         => "messages will be colored in buffer (all = all buffers, channel = channel buffers, query = query buffers (default: all ",
-                  "blacklist_channels"   => "comma separated list with channelname. Channels in this list will be completely ignored. (e.g.: freenode.#weechat,freenode.#weechat-fr). This option has highest priority!",
-                  "shuffle"              => "toggle shuffle color mode for chat area (you don't want this, believe me!) (default: off)",
-                  "chat"                 => "colors text in chat area with according nick color (default: on)",
-                  "highlight"            => "highlight message will be fully highlighted in chat area (\"on\" = only messages from your buddies will be mind (using \"plugins.var.perl.".$prgname.".nicks\); \"off\" = message will not be highlighted; \"always\" = a highlight will always color the whole message (default: on)",
-                  "hotlist_max_level_nicks_add"         => "toggle highlight for hotlist (default: off)",
-                  "buffer_autoset"       => "toggle highlight color in chat area for value in \"buffer_autoset.*.highlight_words_add\" (default: off)",
-                  "look_highlight"       => "toggle highlight color in chat area for value in option \"weechat.look.highlight\" (default: off)",
-                  "look_highlight_regex" => "toggle highlight color in chat area for value in option \"weechat.look.highlight_regex\" (default: off)",
-                  "nicks"                => "comma separated list with nicknames. Only messages from nicks in this list will be colorized. (e.g.: freenode.nils_2,freenode.flashcode,freenode.weebot). You can use \"*\" as a wildcard (e.g.: *.nils_* to match all \"nils_\" on all servers). Also a file with nicks is allowed. The filename in option has to start with \"/\" (e.g.: /buddylist.txt). The format has to be, one nick each line with <servername>.<nickname>",
-                  "own_lines"            => "messages written by your own will be colored. color from \"weechat.color.chat_nick_self\" will be used. If you only want to color your lines, use value \"only\" (default: off)",
-                  "use_irc_colors"       => "if a message contains irc_color_codes, those color codes will be used instead of the nick color (default: off)",
+my %help_desc = ("buffers"             => "buffer type affected by the script (all/channel/query, default: all)",
+                 "blacklist_buffers"   => "comma-separated list of channels to be ignored (e.g. freenode.#weechat,*.#python)",
+                 "lines"               => "apply nickname color to the lines (off/on/nicks). the latter will limit highlighting to nicknames in option 'nicks'",
+                 "highlight"           => "apply highlight color to the highlighted lines (off/on/nicks). the latter will limit highlighting to nicknames in option 'nicks'",
+                 "nicks"               => "comma-separater list of nicks (e.g. freenode.cat,*.dog) OR file name starting with '/' (e.g. /file.txt). in the latter case, nicknames will get loaded from that file inside weechat folder (e.g. from ~/.weechat/file.txt). nicknames in file are newline-separated (e.g. freenode.dog\\n*.cat)",
+                 "own_lines"           => "apply nickname color to own lines (off/on/only). the latter turns off all other kinds of coloring altogether",
 );
 
-my $weechat_version;
-my $zahl = 0;
-my $get_prefix_action = "";
-my @var_blacklist_channels = "";
-my @nick_list = "";
-
-# standard colours.
-my %colours = ( 0 => "darkgray", 1 => "red", 2 => "lightred", 3 => "green",
-                4 => "lightgreen", 5 => "brown", 6 => "yellow", 7 => "blue",
-                8 => "lightblue", 9 => "magenta", 10 => "lightmagenta", 11 => "cyan",
-                12 => "lightcyan", 13 => "white");
+#################################################################################################### config
 
 # program starts here
 sub colorize_cb {
-my ( $data, $modifier, $modifier_data, $string ) = @_;
+    my ( $data, $modifier, $modifier_data, $string ) = @_;
 
-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;
-}
-
-if ( weechat::config_boolean(weechat::config_get("irc.network.colors_receive")) and $default_options{var_use_irc_colors} eq "on" )
-{
-    my $string2 = $string;
-    $string2 =~ s/\[cl_irc_color\]//g;
-    if ( $string2 ne $string )
-    {
-        return $string2;
-    }
-}
-
-if ($default_options{var_highlight} eq "off" and $default_options{var_chat} eq "off"){          # all options OFF
-  return $string;
-}
-
-$modifier_data =~ (m/(.*);(.*);/);
-my $plugin = $1;
-my $name = $2;
-my $buf_pointer = weechat::buffer_search($plugin,$name);
-return $string if ($buf_pointer eq "");                                                         # something went wrong!
-
-# 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
-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::buffer_get_string($buf_pointer, "localvar_nick");
-
-if ( grep /^$servername.$channel_name$/, @var_blacklist_channels ) {                            # check for blacklist_channels
-  return $string;
-}
-
-$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
-
-my $nick_wo_suffix = "";
-# check if modifier tag "nick_" exists in message.
-if ($modifier_data =~ m/(^|,)nick_/)
-{
-    # get the nick name from modifier_data (without "nick_mode" and color codes! Take care of tag "prefix_nick_ccc")
-    # and check for "nick_name" as last modifier_data
-    $modifier_data =~ m/(^|,)nick_([^,]*)/;
-    $nick_wo_suffix = $2;                                                                       # nickname without nick_suffix
-}else
-{
-    # This is a fallback solution!
-    $nick_wo_suffix = weechat::string_remove_color($nick,"");                                   # remove colour-codes from nick
-}
-return $string if ($nick_wo_suffix eq "");
-
-
-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
-    if ( substr($channel_name, 0, 1) eq "#" ){                                                  # get first chat of buffer.
-      return $string if ( $default_options{var_avail_buffer} ne "channel" );                    # channel? yes
-    }else{                                                                                      # query buffer?
-      return $string if ( $default_options{var_avail_buffer} ne "query" );                      # yes
-    }
-  }
-}
-
-# recreate irc.look.nick_suffix and irc.color.nick_suffix
-my $nick_suffix_with_color = "";
-my $nick_suffix = weechat::config_string( weechat::config_get("irc.look.nick_suffix"));
-if ( $nick_suffix ne "" ){
-  my $nick_suffix_color = weechat::color( weechat::config_color( weechat::config_get( "irc.color.nick_suffix" )));
-  $nick_suffix_with_color = $nick_suffix_color . $nick_suffix;
-}
-# recreate irc.look.nick_prefix and irc.color.nick_prefix
-my $nick_prefix_with_color = "";
-my $nick_prefix = weechat::config_string( weechat::config_get("irc.look.nick_prefix"));
-if ( $nick_prefix ne "" ){
-  my $nick_prefix_color = weechat::color( weechat::config_color( weechat::config_get( "irc.color.nick_prefix" )));
-  $nick_prefix_with_color = $nick_prefix_color . $nick_prefix;
-}
-
-# check for action (/me)
-my $prefix_action_with_color = "";
-if (index($modifier_data,"irc_action") >= 0){
-  my $prefix_action_color = weechat::color( weechat::config_color( weechat::config_get( "weechat.color.chat_prefix_action" )));
-  my $prefix_action = weechat::config_string( weechat::config_get("weechat.look.prefix_action"));
-  $prefix_action_with_color = $prefix_action_color . $prefix_action;
-}
-
-# check if look.nickmode is ON and no prefix and no query buffer
-my $nick_mode = "";
-my $nick_mode_value = 0;
-
-if (($weechat_version ne "") && ($weechat_version >= 0x00030900)){
-    # 0 = none, 1 = prefix, 2 = action, 3 = both
-    my $temp_nickmode_value = weechat::config_string(weechat::config_get("irc.look.nick_mode"));
-    $nick_mode_value = 1 if ($temp_nickmode_value eq "prefix" or $temp_nickmode_value eq "both");
-}
-else
-{
-    $nick_mode_value = weechat::config_boolean(weechat::config_get("weechat.look.nickmode"));
-}
-
-if ( $nick_mode_value ==  1 and ($nick ne $get_prefix_action) and (index($modifier_data,"notify_private")) == -1)
-{
-#   if ($nick  =~ m/^\@|^\%|^\+|^\~|^\*|^\&|^\!|^\-/) {                                                  # check for nick modes (@%+~*&!-) without color
-      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") );
-      if ( $nick_mode eq " ")
-      {
-        $nick_mode = "" if ( !weechat::config_boolean(weechat::config_get("irc.look.nick_mode_empty")) );
-      }
-      else
-      {
-        $nick_mode = $color_mode . $nick_mode;
-      }
-}
-
-# i wrote the message
-    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);
-	  $line = colorize_nicks($nick_color,$modifier_data,$line);
-
-          if (index($modifier_data,"irc_action") >= 0){                                                 # /me message?
-            $nick = $prefix_action_with_color;
-            $nick_mode = "";                                                                            # clear nick_mode for /me
-          }else{
-            $nick = $nick_prefix_with_color . $nick_color . $nick_wo_suffix . $nick_suffix_with_color;
-          }
-	  $line = $nick_mode . $nick_color . $nick . "\t" . $nick_color . $line . weechat::color('reset');
-	  return $line;
-      }else{
-	  return $string;
-      }
+    # quit if it's not a privmsg or ctcp
+    # or we are not supposed to
+    if ((index($modifier_data,"irc_privmsg") == -1) ||
+        (index($modifier_data,"irc_ctcp") >= 0)) {
+        return $string;
     }
 
+    # find buffer pointer
+    $modifier_data =~ m/([^;]*);([^;]*);/;
+    my $buffer = weechat::buffer_search($1, $2);
+    return $string if ($buffer eq "");
 
-# get nick color
-$nick = $nick_wo_suffix;
-#$nick = weechat::string_remove_color($nick_wo_suffix,"");                                      # remove color-codes from nick
-my $nick_color = weechat::info_get('irc_nick_color', $nick_wo_suffix);                          # get nick-color
+    # find buffer name, server name
+    # return if buffer is in a blacklist
+    my $buffername = weechat::buffer_get_string($buffer, "name");
+    return $string if weechat::string_has_highlight($buffername, $config{blacklist_buffers});
+    my $servername = weechat::buffer_get_string($buffer, "localvar_server");
 
-    my $var_hl_max_level_nicks_add = 0;
-# highlight message received?
-    if ( $default_options{var_highlight} eq "on" or $default_options{var_highlight} eq "always" ){# highlight_mode on?
-# this one check for other nick!!
+    # find stuff between \t
+    $string =~ m/^([^\t]*)\t(.*)/;
+    my $left = $1;
+    my $right = $2;
 
-      if ( $default_options{var_highlight} eq "on" ){
-        return $string if check_whitelist_nicks($servername, $my_nick, $nick_wo_suffix);        # check for whitelist
-      }
+    # find nick of the sender
+    # find out if we are doing an action
+    my $nick = ($modifier_data =~ m/(^|,)nick_([^,]*)/) ? $2 : weechat::string_remove_color($left, "");
+    my $action = ($modifier_data =~ m/\birc_action\b/) ? 1 : 0;
 
-      if ( $default_options{var_buffer_autoset} eq "on" || $default_options{var_look_highlight} eq "on" ){# buffer_autoset or look_highlight "on"?
-	  my $highlight_words = "";
+    ######################################## get color
 
-	  # get strings from buffer_autoset and/or weechat.look.highlight and weechat.look.highlight_regex
-	  if ($default_options{var_buffer_autoset} eq "on"){
-	    my $highlight_words_add = weechat::config_string(weechat::config_get("buffer_autoset.buffer.irc.".$servername.".".$channel_name.".highlight_words_add"));
-	    $highlight_words .= $highlight_words_add . ",";
-	  }
-
-	  if ($default_options{var_look_highlight} eq "on"){
-	    my $look_highlight = weechat::config_string( weechat::config_get("weechat.look.highlight") );
-	    $highlight_words .= $look_highlight;
-	  }
-	  if ( $default_options{var_hotlist_max_level_nicks_add} eq "on" and weechat::config_string(weechat::config_get("buffer_autoset.buffer.irc.".$servername.".".$channel_name.".hotlist_max_level_nicks_add")) =~ /$nick\:[0-2]/ ){
-	    $var_hl_max_level_nicks_add = 1;
-	  }
-
-            $/ = ",";                                                                           # kill "," at end of string
-
-	    chomp($highlight_words);
-
-	      foreach ( split( /,+/, $highlight_words ) ) {                                     # check for highlight_words
-		  if ($_ eq ""){next;}                                                          # ignore empty string
-		    my $search_string = shell2regex($_);
-
-		  if ($string =~ m/\b$search_string\b/gi){                                      # i (ignorecase)
-		    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){
-			    $line = colorize_nicks($high_color,$modifier_data,$line);
-                            $nick = $prefix_action_with_color;
-			    $line = $high_color . $nick . "\t" . $high_color . $line . weechat::color('reset');
-			    return $line;
-			  }
-		    $line = colorize_nicks($high_color,$modifier_data,$line);
-		    $line = $nick_mode . $high_color . $nick_prefix_with_color . $nick . $nick_suffix_with_color . "\t" . $high_color . $line . weechat::color('reset');
-		    return $line;
-		  }
-	      }
-      }
-	# buffer_autoset is off.
-        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)?
-                $line = colorize_nicks($high_color,$modifier_data,$line);
-                $nick = $prefix_action_with_color;
-                $line = $high_color . $nick . "\t" . $high_color . $line . weechat::color('reset');
-                return $line;
-	      }
-
-# highlight whole line
-	if ( $var_hl_max_level_nicks_add eq 0 ){
-	      $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');
-
-# TODO use of weechat_print_date_tags() to add "notify_highlight" to messages.
-#	      $modifier_data =~ s/,notify_message,/,notify_highlight,/gio;
-#	      weechat::print_date_tags($buf_pointer,0,$modifier_data,$line);
-#	      return "";
-	      return $line;
-	}
-	}
-    } # highlight area finished
-
-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
-    return $string if ( $default_options{var_avail_buffer} ne "channel" );
-  }elsif ( index($modifier_data,"notify_private") > -1){                                        # message is privat
-    return $string if ( $default_options{var_avail_buffer} ne "query" );
-  }
-}
-
-# simple channel message
-    if ($default_options{var_chat} eq "on"){                                                    # chat_mode on?
-	if ($default_options{var_shuffle} eq "on"){                                             # color_shuffle on?
-	  my $zahl2 = 0;
-	  my $my_color = weechat::config_color(weechat::config_get("weechat.color.chat_nick_self"));# get my own nick colour
-	    for (1){                                                                            # get a random colour but don't use
-	      redo if ( $zahl ==  ($zahl2 = int(rand(14))) or ($colours{$zahl2} eq $my_color) );# latest color nor own nick color
-	      $zahl = $zahl2;
-	    }
-	  $nick_color = weechat::color($colours{$zahl});                                        # get new random color
-	}
-
-# check for weechat version and use weechat.look.highlight_regex option
-       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');
-		return $line;
-	    }
-	  }
-        }
-        if (index($modifier_data,"irc_action") >= 0)
-        {
-#	  if ($default_options{prefix_action} eq $nick){
-                my $nick_color = weechat::info_get('irc_nick_color', $nick_wo_suffix);          # get nick-color
-                $line = colorize_nicks($nick_color,$modifier_data,$line);
-                $nick = $prefix_action_with_color;
-                $line = $nick . "\t" . $nick_color . $line . weechat::color('reset');
-                return $line;
-        }
-
-      $line = colorize_nicks($nick_color,$modifier_data,$line);
-      $line = $nick_prefix_with_color . $nick_mode . $nick_color . $nick . $nick_suffix_with_color .  "\t" . $nick_color . $line . weechat::color('reset');  # create new line nick_color+nick+separator+text
-      return $line;
-    }else{
-      return $string;                                                                           # return original string
-    }
-} # end of sub colorize_cb{}
-
-
-# check for irc color codes in message.
-# if exists, add "[cl_irc_color]" to message body
-# :nick!host PRIVMSG #channel : 02message
-sub irc_in_privmsg_cb
-{
-    my ( $data, $modifier, $modifier_data, $string ) = @_;
-
-    if ( weechat::config_boolean(weechat::config_get("irc.network.colors_receive")) and $default_options{var_use_irc_colors} eq "on" )
-    {
-        # search for color code in string!
-        if ( $string =~ /\03/ )
-        {
-            $string =~ m/^(.*) :(.*)/;
-            my $msg_part1 = $1;
-            weechat::print("","msg_part1: $msg_part1");
-            if (index($msg_part1,"PRIVMSG") == -1)
-            {                                             # its neither a channel nor a query buffer
-                return $string;
-            }
-            if (index($msg_part1,"NOTICE") >= 0)
-            {
-                return $string;
-            }
-            my $msg_part2 = "[cl_irc_color]" . $2;
-            $string = $msg_part1 . " :" . $msg_part2;
-        }
-    }
-    return $string;
-}
-# whitelist nicks : 0 = color, 1 = no color
-sub check_whitelist_nicks{
-my ( $servername, $my_nick, $nick_wo_suffix ) = @_;
-    if ( $default_options{var_own_lines} eq "only" ){                                           # color only my lines
-        if ( $nick_wo_suffix eq $my_nick){                                                      # my nick?
-            return 0;                                                                           # yes
-        }else{
-            return 1;                                                                           # another nick!
-        }
-    }elsif ( $default_options{var_nicks} ne "" and $default_options{var_own_lines} eq "off" ){   # nicks in option and own_lines = off
-        my $result = loop_whitelist_nicks($servername,$nick_wo_suffix);                         # check nicks in list
-        return 1 if ($result == 1);
-    }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!
-            my $result = loop_whitelist_nicks($servername,$nick_wo_suffix);                     # check nicks in list
-            return 1 if ($result == 1);
-        }
-    }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?
-            return 1;                                                                           # yes
-        }
-    }
-return 0;
-}
-sub loop_whitelist_nicks{
-    my ($servername, $nick) = @_;
-    foreach ( @nick_list ){
-        my ($server,$buddy) = split(/\./,$_);
-        $server = weechat::string_mask_to_regex($server);
-        $buddy = weechat::string_mask_to_regex($buddy);
-        if ($servername =~ /^$server$/i and $nick =~ /^$buddy$/i) {
-            return 0;
-        }
-    }
-    return 1;
-}
-# converts shell wildcard characters to regex
-sub shell2regex {
-    my $globstr = shift;
-    my %patmap = (
-        '*' => '.*',
-        '?' => '.',
-        '[' => '[',
-        ']' => ']',
-    );
-    $globstr =~ s{(.)} { $patmap{$1} || "\Q$1" }ge;
-    return $globstr;
-}
-
-# check for colorize_nicks script an set colour before and after nick name 
-sub colorize_nicks{
-my ( $nick_color, $mf_data, $line ) = @_;
-
-my $pyth_ptn = weechat::infolist_get("python_script","","colorize_nicks");
-weechat::infolist_next($pyth_ptn);
-
-if ( "colorize_nicks" eq weechat::infolist_string($pyth_ptn,"name") ){                          # does colorize_nicks is installed?
-	$line = weechat::hook_modifier_exec( "colorize_nicks",$mf_data,$line);                  # call colorize_nicks function and color the nick(s)
-	my @array = "";
-	my $color_code_reset = weechat::color('reset');
-	@array=split(/$color_code_reset/,$line);
-	my $new_line = "";
-	foreach (@array){
-	  $new_line .=  $nick_color . $_ . weechat::color('reset');
-	}
-	$new_line =~ s/\s+$//g;                                                                 # remove space at end
-	$line = $new_line;
-}
-weechat::infolist_free($pyth_ptn);
-
-return $line;
-}
-
-# -----------------------------[ config ]-----------------------------------
-sub init_config{
-    foreach my $option ( keys %default_options ){
-        $option = substr($option,4,length($option)-4);
-        if (!weechat::config_is_set_plugin($option)){
-            weechat::config_set_plugin($option, $default_options{"var_" . $option});
-        }else{
-            $default_options{"var_" . $option} = lc( weechat::config_get_plugin($option) );
+    my $color = "";
+    my $my_nick = weechat::buffer_get_string($buffer, "localvar_nick");
+    if ($my_nick eq $nick) {
+        # it's our own line
+        # process only if own_lines is "on" or "only" (i.e. not "off")
+        return $string if ($config{own_lines} eq "off");
+        $color = weechat::color("chat_nick_self");
+    } else {
+        # it's someone else's line
+        # don't process is own_lines are "only"
+        # in order to get correct matching, remove colors from the string
+        return $string if ($config{own_lines} eq "only");
+        my $right_nocolor = weechat::string_remove_color($right, "");
+        if ((
+            # if configuration wants us to highlight
+            $config{highlight} eq "on" ||
+            ($config{highlight} eq "nicks" && weechat::string_has_highlight("$servername.$nick", $config{nicks}))
+           ) && (
+            # ..and if we have anything to highlight
+            weechat::string_has_highlight($right_nocolor, weechat::buffer_string_replace_local_var($buffer, weechat::buffer_get_string($buffer, "highlight_words"))) ||
+            weechat::string_has_highlight($right_nocolor, weechat::config_string(weechat::config_get("weechat.look.highlight"))) ||
+            weechat::string_has_highlight_regex($right_nocolor, weechat::config_string(weechat::config_get("weechat.look.highlight_regex"))) ||
+            weechat::string_has_highlight_regex($right_nocolor, weechat::buffer_get_string($buffer, "highlight_regex"))
+           )) {
+            # that's definitely a highlight! get a hilight color
+            # and replace the first occurance of coloring, that'd be nick color
+            $color = weechat::color('chat_highlight');
+            $right =~ s/\31[^\31 ]+?\Q$nick/$color$nick/ if ($action);
+        } elsif (
+            # now that's not a highlight OR highlight is off OR current nick is not in the list
+            # let's see if configuration wants us to highlight lines
+            $config{lines} eq "on" ||
+            ($config{lines} eq "nicks" && weechat::string_has_highlight("$servername.$nick", $config{nicks}))
+           ) {
+            $color = weechat::info_get('irc_nick_color', $nick);
+        } else {
+            # oh well
+            return $string;
         }
     }
 
-    if ( ($weechat_version ne "") && (weechat::info_get("version_number", "") >= 0x00030500) ) {    # v0.3.5
-        description_options();
+    ######################################## inject colors and go!
+
+    my $out = "";
+    if ($action) {
+        # remove the first color reset - after * nick
+        # make other resets reset to our color
+        $right =~ s/\34//;
+        $right =~ s/\34/\34$color/g;
+        $out = $left . "\t" . $right . "\34"
+    } else {
+        # make other resets reset to our color
+        $right =~ s/\34/\34$color/g;
+        $out = $left . "\t" . $color . $right . "\34"
     }
-
-    if ( $default_options{"var_blacklist_channels"} ne "" ){
-        @var_blacklist_channels = "";
-        @var_blacklist_channels = split( /,/, $default_options{"var_blacklist_channels"} );
-    }
-    if ( $default_options{var_nicks} ne "" ){
-      undef (@nick_list);
-      if ( substr($default_options{var_nicks}, 0, 1) eq "/" ){                                # get first chat of nicks "/" ?
-          nicklist_read();                                                                      # read nicks from file
-      }else{
-          @nick_list = split( /,/, $default_options{var_nicks} );                             # use nicks from option
-      }
-    }
-
+    #weechat::print("", ""); weechat::print("", "\$str " . Dumper($string)); weechat::print("", "\$out " . Dumper($out));
+    return $out;
 }
 
-sub toggle_config_by_set{
-my ( $pointer, $name, $value ) = @_;
-    $name = substr($name,length("plugins.var.perl.$prgname."),length($name));
-    $default_options{"var_" . $name} = lc($value);
+#################################################################################################### config
 
-    if ( $name eq "blacklist_channels" ){
-      @var_blacklist_channels = "";
-      @var_blacklist_channels = split( /,/, $default_options{"var_" . $name} );
+# read nicknames if $conf{nisks} starts with /
+# after this, $conf{nisks} is of form a,b,c,d
+# if it doesnt start with /, assume it's already a,b,c,d
+sub nicklist_read {
+    return if (substr($config{nicks}, 0, 1) ne "/");
+    my $file = weechat::info_get("weechat_dir", "") . $config{nicks};
+    return unless -e $file;
+    my $nili = "";
+    open (WL, "<", $file) || DEBUG("$file: $!");
+    while (<WL>) {
+        chomp;                                                         # kill LF
+        $nili .= $_ . ",";
     }
-    if ( $name eq "nicks" ){
-      undef (@nick_list);
-      if ( $default_options{"var_".$name} eq "" ){                                              # no nicks given
-          undef (@nick_list);
-#          count_nicks();
-      }elsif ( substr($default_options{var_nicks}, 0, 1) eq "/" ){                             # get first chat of nicks "/" ?
-          nicklist_read();                                                                      # read nicks from file
-#          count_nicks();
-      }else{
-          @nick_list = split( /,/, $default_options{"var_" . $name} );
-#          count_nicks();
-      }
-    }
-
-$default_options{var_avail_buffer} = "all" if ( $default_options{var_avail_buffer} eq "" );
-
-return weechat::WEECHAT_RC_OK ;
+    close WL;
+    chop $nili;                                                        # remove last ","
+    $config{nicks} = $nili;
 }
 
-# create description options for script...
-sub description_options{
-    foreach my $option ( keys %help_desc ){
-        weechat::config_set_desc_plugin( $option,$help_desc{$option} );
-    }
+# called when a config option ha been changed
+# $name = plugins.var.perl.$prgname.nicks etc
+sub toggle_config_by_set {
+    my ($pointer, $name, $value) = @_;
+    $name = substr($name,length("plugins.var.perl.$prgname."),length($name));
+    $config{$name} = lc($value);
+    nicklist_read() if ($name eq "nicks");
 }
 
-# toggle functions on/off with command line
-sub change_settings{
-my $getarg = lc($_[2]); # switch to lower-case
-
-    foreach my $option ( keys %default_options ){
-      $option = substr($option,4,length($option)-4);            # remove "var_" from option
-      if ( $getarg eq $option ){
-        if ( $default_options{"var_" . $option} eq "on" ){
-          weechat::config_set_plugin( $option, "off" );
-        }else{
-          weechat::config_set_plugin( $option, "on" );
+# read configuration from weechat OR
+#   set default options and
+#   set dectription if weechat >= 0.3.5
+# after done, read nicklist from file if needed
+sub init_config {
+    my $weechat_version = weechat::info_get('version_number', '') || 0;
+    foreach my $option (keys %config){
+        if (!weechat::config_is_set_plugin($option)) {
+            weechat::config_set_plugin($option, $config{$option});
+            weechat::config_set_desc_plugin($option, $help_desc{$option}) if ($weechat_version >= 0x00030500); # v0.3.5
+        } else {
+            $config{$option} = lc(weechat::config_get_plugin($option));
         }
-      }
     }
-return weechat::WEECHAT_RC_OK;
+    nicklist_read();
 }
 
-sub nicklist_read {
-        undef (@nick_list);
-        my $weechat_dir = weechat::info_get( "weechat_dir", "" );
-        my $nicklist = weechat::config_get_plugin("nicks");
-        $nicklist = $weechat_dir.$nicklist;
-        $default_options{var_nicks} = "" unless -e $nicklist;
-        return unless -e $nicklist;
-        open (WL, "<", $nicklist) || DEBUG("$nicklist: $!");
-        while (<WL>) {
-                chomp;                                                          # kill LF
-                        my ( $servername, $nickname ) = split /\./;           # servername,nickname (seperator could be "," or ".")
-                        if (not defined $nickname){
-                                close WL;
-                                weechat::print("",weechat::prefix("error")."$prgname: $nicklist is not valid format (<servername>.<nickname>).");
-                                return;
-                        }
-              push @nick_list,($servername.".".$nickname."," );                 # servername.nickname+","
-        }
-        close WL;
-        chop @nick_list;                                                        # remove last ","
-}
+#################################################################################################### start
 
-# debug....
-sub count_nicks{
-  my $anzahl=@nick_list;
-  weechat::print("","anzahl: $anzahl");
-
-  foreach (@nick_list){
-      weechat::print ("","$_");
-  }
-}
-# -------------------------------[ init ]-------------------------------------
-# first function called by a WeeChat-script.
-weechat::register($prgname, "Nils Görs <weechatter\@arcor.de>", $version,
-                  "GPL3", $description, "", "");
-# check weechat version
-  $weechat_version = weechat::info_get("version_number", "");
-  if (( $weechat_version eq "" ) or ( $weechat_version < 0x00030400 )){
-    weechat::print("",weechat::prefix("error")."$prgname: needs WeeChat >= 0.3.4. Please upgrade: http://www.weechat.org/");
-    weechat::command("","/wait 1ms /perl unload $prgname");
-  }
-
-
+weechat::register($prgname, "Nils Görs <weechatter\@arcor.de>", $version, "GPL3", $description, "", "");
+weechat::hook_modifier("500|weechat_print","colorize_cb", "");
 init_config();
-
-
-$get_prefix_action = weechat::config_string(weechat::config_get("weechat.look.prefix_action"));
-weechat::hook_modifier("1000|irc_in_privmsg","irc_in_privmsg_cb", "");          # use higher prio than "weechat_print"!
-weechat::hook_modifier("weechat_print","colorize_cb", "");
-weechat::hook_modifier("colorize_lines","colorize_cb", "");
-
-  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 "" ) {
-        my @array = split(/,/,$colours_buf);
-        my $i = 0;
-        foreach (@array){
-          $colours{$i++} = $_;
-        }
-      undef $colours_buf;
-      undef @array;
-    }
-  }
-
-weechat::hook_command($prgname, $description,
-
-        "<highlight> || <chat> || <shuffle> || <autoset> || <look_highlight> || <look_highlight_regex> || <hotlist> || <own_lines>",
-
-        "<highlight>            toggle highlight color in chat area (on/off)\n".
-        "<chat>                 colors the text in chat area with according nick color (on/off)\n".
-        "<shuffle>              toggle shuffle color mode on/off\n".
-        "<autoset>              toggle highlight color mode for buffer_autoset on/off\n".
-        "<look_highlight>       toggle highlight color mode for weechat.look.highlight on/off\n".
-        "<look_highlight_regex> toggle highlight color in chat area for option weechat.look.highlight_regex on/off\n".
-        "<hotlist>              toggle hotlist_max_level_nicks_add on/off\n".
-        "<own_lines>            toggle coloring of own lines on/off\n".
-        "\n".
-        "Options (script):\n".
-        "   'plugins.var.perl.$prgname.highlight'                   : $help_desc{highlight}\n".
-        "   'plugins.var.perl.$prgname.hotlist_max_level_nicks_add' : $help_desc{hotlist_max_level_nicks_add}\n".
-        "   'plugins.var.perl.$prgname.buffer_autoset'              : $help_desc{buffer_autoset}\n".
-        "   'plugins.var.perl.$prgname.look_highlight'              : $help_desc{look_highlight}\n".
-        "   'plugins.var.perl.$prgname.look_highlight_regex'        : $help_desc{look_highlight_regex}\n".
-        "   'plugins.var.perl.$prgname.chat'                        : $help_desc{chat}\n".
-        "   'plugins.var.perl.$prgname.shuffle'                     : $help_desc{shuffle}\n".
-        "   'plugins.var.perl.$prgname.blacklist_channels'          : $help_desc{blacklist_channels}\n".
-        "   'plugins.var.perl.$prgname.avail_buffer'                : $help_desc{avail_buffer}\n".
-        "   'plugins.var.perl.$prgname.nicks'                       : $help_desc{nicks}\n".
-        "   'plugins.var.perl.$prgname.own_lines'                   : $help_desc{own_lines}\n".
-        "\n".
-        "Options (global):\n".
-        "   'weechat.color.chat_highlight'                      : highlight color\n".
-        "   'weechat.color.chat_highlight_bg'                   : highlight background color\n".
-        "   'weechat.color.chat_nick*'                          : colors for nicks\n\n".
-        "To use options \"buffer_autoset\" and/or \"hotlist_max_level_nicks_add\" install buffer_autoset script from: http://www.weechat.org/scripts/\n",
-        "highlight|chat|shuffle|autoset|look_highlight|look_highlight_regex|hotlist|own_lines %-", "change_settings", "");
-
-weechat::hook_config( "plugins.var.perl.$prgname.*", "toggle_config_by_set", "" );
+weechat::hook_config("plugins.var.perl.$prgname.*", "toggle_config_by_set", "");

File .weechat/plugins.conf

 #
-# plugins.conf -- weechat v0.4.2
+# plugins.conf -- weechat v0.4.3
 #
 
 [var]
 fifo.fifo = "on"
 perl.check_license = "on"
 perl.colorize_lines.avail_buffer = "all"
+perl.colorize_lines.blacklist_buffers = ""
 perl.colorize_lines.blacklist_channels = ""
 perl.colorize_lines.buffer_autoset = "off"
+perl.colorize_lines.buffers = "all"
 perl.colorize_lines.chat = "on"
 perl.colorize_lines.highlight = "on"
 perl.colorize_lines.hotlist_max_level_nicks_add = "off"
+perl.colorize_lines.lines = "on"
 perl.colorize_lines.look_highlight = "off"
 perl.colorize_lines.look_highlight_regex = "off"
 perl.colorize_lines.nicks = ""
 python.screen_away.command_on_attach = ""
 python.screen_away.command_on_detach = ""
 python.screen_away.ignore = ""
+python.screen_away.ignore_relays = "off"
 python.screen_away.interval = "5"
 python.screen_away.message = "Detached from screen"
+python.screen_away.set_away = "on"
 tcl.check_license = "on"
 
 [desc]
 perl.colorize_lines.avail_buffer = "messages will be colored in buffer (all = all buffers, channel = channel buffers, query = query buffers (default: all "
+perl.colorize_lines.blacklist_buffers = "comma-separated list of channels to be ignored (e.g. freenode.#weechat,*.#python)"
 perl.colorize_lines.blacklist_channels = "comma separated list with channelname. Channels in this list will be completely ignored. (e.g.: freenode.#weechat,freenode.#weechat-fr). This option has highest priority!"
 perl.colorize_lines.buffer_autoset = "toggle highlight color in chat area for value in "buffer_autoset.*.highlight_words_add" (default: off)"
+perl.colorize_lines.buffers = "buffer type affected by the script (all/channel/query, default: all)"
 perl.colorize_lines.chat = "colors text in chat area with according nick color (default: on)"
 perl.colorize_lines.highlight = "highlight message will be fully highlighted in chat area ("on" = only messages from your buddies will be mind (using "plugins.var.perl.colorize_lines.nicks); "off" = message will not be highlighted; "always" = a highlight will always color the whole message (default: on)"
 perl.colorize_lines.hotlist_max_level_nicks_add = "toggle highlight for hotlist (default: off)"
+perl.colorize_lines.lines = "apply nickname color to the lines (off/on/nicks). the latter will limit highlighting to nicknames in option 'nicks'"
 perl.colorize_lines.look_highlight = "toggle highlight color in chat area for value in option "weechat.look.highlight" (default: off)"
 perl.colorize_lines.look_highlight_regex = "toggle highlight color in chat area for value in option "weechat.look.highlight_regex" (default: off)"
 perl.colorize_lines.nicks = "comma separated list with nicknames. Only messages from nicks in this list will be colorized. (e.g.: freenode.nils_2,freenode.flashcode,freenode.weebot). You can use "*" as a wildcard (e.g.: *.nils_* to match all "nils_" on all servers). Also a file with nicks is allowed. The filename in option has to start with "/" (e.g.: /buddylist.txt). The format has to be, one nick each line with <servername>.<nickname>"
 perl.colorize_lines.shuffle = "toggle shuffle color mode for chat area (you don't want this, believe me!) (default: off)"
 perl.colorize_lines.use_irc_colors = "if a message contains irc_color_codes, those color codes will be used instead of the nick color (default: off)"
 python.screen_away.away_suffix = "What to append to your nick when you're away."
-python.screen_away.command_on_attach = "Command to execute on attach"
-python.screen_away.command_on_detach = "Command to execute on detach"
+python.screen_away.command_on_attach = "Commands to execute on attach, separated by semicolon"
+python.screen_away.command_on_detach = "Commands to execute on detach, separated by semicolon"
 python.screen_away.ignore = "Comma-separated list of servers to ignore."
+python.screen_away.ignore_relays = "Only check screen status and ignore relay interfaces"
 python.screen_away.interval = "How often in seconds to check screen status"
 python.screen_away.message = "Away mesage"
+python.screen_away.set_away = "Set user as away."

File .weechat/python/screen_away.py

 # (this script requires WeeChat 0.3.0 or newer)
 #
 # History:
+# 2014-01-12, Phyks (Lucas Verney) <phyks@phyks.me>
+#  version 0.12: Added an option to check status of relays to set unaway in
+#                   case of a connected relay.
+# 2013-08-30, Anders Einar Hilden <hildenae@gmail.com>
+#  version: 0.11: Fix reading of set_away
+# 2013-06-16, Renato Botelho <rbgarga@gmail.com>
+#  version 0.10: add option to don't set away, only change nick
+#                   allow multiple commands on attach/dettach
+#                   do not add suffix if nick already have it
 # 2012-12-29, David Flatz <david@upcs.at>
 #  version 0.9: add option to ignore servers and don't set away status for them
 #               add descriptions to config options
 
 SCRIPT_NAME    = "screen_away"
 SCRIPT_AUTHOR  = "xt <xt@bash.no>"
-SCRIPT_VERSION = "0.9"
+SCRIPT_VERSION = "0.12"
 SCRIPT_LICENSE = "GPL3"
 SCRIPT_DESC    = "Set away status on screen detach"
 
         'message': ('Detached from screen', 'Away mesage'),
         'interval': ('5', 'How often in seconds to check screen status'),
         'away_suffix': ('', 'What to append to your nick when you\'re away.'),
-        'command_on_attach': ('', 'Command to execute on attach'),
-        'command_on_detach': ('', 'Command to execute on detach'),
+        'command_on_attach': ('', 'Commands to execute on attach, separated by semicolon'),
+        'command_on_detach': ('', 'Commands to execute on detach, separated by semicolon'),
         'ignore': ('', 'Comma-separated list of servers to ignore.'),
+        'set_away': ('on', 'Set user as away.'),
+        'ignore_relays': ('off', 'Only check screen status and ignore relay interfaces'),
 }
 
 TIMER = None
 SOCK = None
 AWAY = False
+CONNECTED_RELAY = False
 
 def set_timer():
     '''Update timer hook with new interval'''
         if not w.infolist_integer(infolist, 'is_connected') == 1 or \
                w.infolist_string(infolist, 'name') in ignores:
             continue
-        if not w.infolist_integer(infolist, 'is_away') or \
-               w.infolist_string(infolist, 'away_message') == \
-               w.config_get_plugin('message'):
+        if not w.config_string_to_boolean(w.config_get_plugin('set_away')) or \
+                not w.infolist_integer(infolist, 'is_away') or \
+                    w.infolist_string(infolist, 'away_message') == \
+                    w.config_get_plugin('message'):
             buffers.append((w.infolist_pointer(infolist, 'buffer'),
                 w.infolist_string(infolist, 'nick')))
     w.infolist_free(infolist)
 def screen_away_timer_cb(buffer, args):
     '''Check if screen is attached, update awayness'''
 
-    global AWAY, SOCK
+    global AWAY, SOCK, CONNECTED_RELAY
 
+    set_away = w.config_string_to_boolean(w.config_get_plugin('set_away'))
+    check_relays = not w.config_string_to_boolean(w.config_get_plugin('ignore_relays'))
     suffix = w.config_get_plugin('away_suffix')
     attached = os.access(SOCK, os.X_OK) # X bit indicates attached
 
-    if attached and AWAY:
+    # Check wether a client is connected on relay or not
+    CONNECTED_RELAY = False
+    if check_relays:
+        infolist = w.infolist_get('relay', '', '')
+        if infolist:
+            while w.infolist_next(infolist):
+                status = w.infolist_string(infolist, 'status_string')
+                if status == 'connected':
+                    CONNECTED_RELAY = True
+                    break
+            w.infolist_free(infolist)
+
+    if (attached and AWAY) or (check_relays and CONNECTED_RELAY and not attached and AWAY):
         w.prnt('', '%s: Screen attached. Clearing away status' % SCRIPT_NAME)
         for server, nick in get_servers():
-            w.command(server,  "/away")
+            if set_away:
+                w.command(server,  "/away")
             if suffix and nick.endswith(suffix):
                 nick = nick[:-len(suffix)]
                 w.command(server,  "/nick %s" % nick)
         AWAY = False
-        if w.config_get_plugin("command_on_attach"):
-            w.command("", w.config_get_plugin("command_on_attach"))
+        for cmd in w.config_get_plugin("command_on_attach").split(";"):
+            w.command("", cmd)
 
     elif not attached and not AWAY:
-        w.prnt('', '%s: Screen detached. Setting away status' % SCRIPT_NAME)
-        for server, nick in get_servers():
-            if suffix:
-                w.command(server, "/nick %s%s" % (nick, suffix));
-            w.command(server, "/away %s" % w.config_get_plugin('message'));
-        AWAY = True
-        if w.config_get_plugin("command_on_detach"):
-            w.command("", w.config_get_plugin("command_on_detach"))
+        if not CONNECTED_RELAY:
+            w.prnt('', '%s: Screen detached. Setting away status' % SCRIPT_NAME)
+            for server, nick in get_servers():
+                if suffix and not nick.endswith(suffix):
+                    w.command(server, "/nick %s%s" % (nick, suffix));
+                if set_away:
+                    w.command(server, "/away %s" % w.config_get_plugin('message'));
+            AWAY = True
+            for cmd in w.config_get_plugin("command_on_detach").split(";"):
+                w.command("", cmd)
 
     return w.WEECHAT_RC_OK
 

File .weechat/relay.conf

 #
-# relay.conf -- weechat v0.4.2
+# relay.conf -- weechat v0.4.3
 #
 
 [look]

File .weechat/rmodifier.conf

 #
-# rmodifier.conf -- weechat v0.4.2
+# rmodifier.conf -- weechat v0.4.3
 #
 
 [look]

File .weechat/script.conf

 #
-# script.conf -- weechat v0.4.2
+# script.conf -- weechat v0.4.3
 #
 
 [look]

File .weechat/sec.conf

 #
-# sec.conf -- weechat v0.4.2
+# sec.conf -- weechat v0.4.3
 #
 
 [crypt]

File .weechat/weechat.conf

 #
-# weechat.conf -- weechat v0.4.2
+# weechat.conf -- weechat v0.4.3
 #
 
 [debug]
 bar_more_left = "◀"
 bar_more_right = "▶"
 bar_more_up = "▲"
+buffer_auto_renumber = on
 buffer_notify_default = all
+buffer_position = end
+buffer_search_case_sensitive = off
+buffer_search_force_default = off
+buffer_search_regex = off
+buffer_search_where = message
 buffer_time_format = "%H:%M:%S"
 color_basic_force_bold = off
 color_inactive_buffer = off
 input_share_overwrite = off
 input_undo_max = 32
 item_buffer_filter = "•"
+item_buffer_zoom = "!"
 item_time_format = "%H:%M"
 jump_current_to_previous_buffer = on
 jump_previous_buffer_when_closing = on
 search_text_not_found_alert = on
 separator_horizontal = "-"
 separator_vertical = ""
-set_title = on
+tab_width = 1
 time_format = "%a, %d %b %Y %T"
+window_auto_zoom = off
 window_separator_horizontal = on
 window_separator_vertical = on
+window_title = "WeeChat ${info:version}"
 
 [palette]
 
 buffers.conditions = ""
 buffers.filling_left_right = vertical
 buffers.filling_top_bottom = horizontal
-buffers.hidden = off
+buffers.hidden = on
 buffers.items = "buffers"
 buffers.position = left
 buffers.priority = 0

File .weechat/xfer.conf

 #
-# xfer.conf -- weechat v0.4.2
+# xfer.conf -- weechat v0.4.3
 #
 
 [look]
 auto_accept_chats = off
 auto_accept_files = off
 auto_accept_nicks = ""
+auto_check_crc32 = off
 auto_rename = on
 auto_resume = on
 convert_spaces = on
 typeset -U path
-path=($HOME/anaconda/bin /Applications/MacVim.app/Contents/MacOS $HOME/bin /opt/local/bin /opt/local/sbin $path)
+path=(/Applications/MacVim.app/Contents/MacOS $HOME/bin /opt/local/bin /opt/local/sbin $path)
 
 export EDITOR=vim
 export VISUAL=vim
 # My Dotfiles
+* Author: Woojong Koh
 
 ## How to Install
 1. Run `bootstrap_{mac|linux}.sh` in the `bin` directory

File bin/bootstrap_linux.sh

 $APT_GET install wget || exit
 $APT_GET install zsh || exit
 $APT_GET install swig || exit  # for SciPy