]> git.rmz.io Git - dotfiles.git/commitdiff
weechat: update plugins
authorSamir Benmendil <samir.benmendil@gmail.com>
Fri, 31 Jan 2014 01:21:12 +0000 (02:21 +0100)
committerSamir Benmendil <samir.benmendil@gmail.com>
Fri, 31 Jan 2014 01:21:12 +0000 (02:21 +0100)
weechat/buffer_autoset.conf [new file with mode: 0644]
weechat/buffers.conf
weechat/perl/buffers.pl
weechat/perl/highmon.pl
weechat/perl/iset.pl
weechat/python/autoload/buffer_autoset.py [new symlink]
weechat/python/buffer_autoset.py [new file with mode: 0644]
weechat/script.conf

diff --git a/weechat/buffer_autoset.conf b/weechat/buffer_autoset.conf
new file mode 100644 (file)
index 0000000..1773cb1
--- /dev/null
@@ -0,0 +1,6 @@
+#
+# buffer_autoset.conf -- weechat v0.4.2
+#
+
+[buffer]
+perl.highmon.number = "100"
index 83d0c5bdd2c679345db90e00681462560666c05c..0a224798381d026e376f028940879bc7e8c7989f 100644 (file)
@@ -19,12 +19,14 @@ none_channel_bg = default
 none_channel_fg = default
 number = lightgreen
 number_char = 245
+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
@@ -44,22 +46,25 @@ detach_display_window_number = off
 detach_displayed_buffers = on
 detach_free_content = off
 detach_query = off
-hide_merged_buffers = none
+hide_merged_buffers = keepserver
 hotlist_counter = off
 immune_detach_buffers = ""
 indenting = off
 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 = ""
index 922415c3e553796d4062bea0ee637da92753c852..d4d17c2fa7c98a18b43eed88edbe04048b7de5c2 100644 (file)
@@ -1,5 +1,5 @@
 #
-# Copyright (C) 2008-2013 Sebastien Helleu <flashcode@flashtux.org>
+# 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
 # Display sidebar with list of buffers.
 #
 # 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
+#     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)
+#     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"
+#     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)
+#     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)
@@ -143,7 +153,7 @@ use strict;
 use Encode qw( decode encode );
 # -------------------------------[ internal ]-------------------------------------
 my $SCRIPT_NAME = "buffers";
-my $version = "4.2";
+my $SCRIPT_VERSION = "4.5";
 
 my $BUFFERS_CONFIG_FILE_NAME = "buffers";
 my $buffers_config_file;
@@ -162,7 +172,7 @@ my %buffers_timer       = ();
 my %Hooks               = ();
 
 # --------------------------------[ init ]--------------------------------------
-weechat::register($SCRIPT_NAME, "Sebastien Helleu <flashcode\@flashtux.org>", $version,
+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;
 
@@ -179,9 +189,16 @@ if ( check_bar_item() == 0 )
     weechat::command("","/bar show " . $SCRIPT_NAME) if ( weechat::config_boolean($options{"toggle_bar"}) eq 1 );
 }
 
-weechat::hook_signal("buffer_*", "buffers_signal_buffer", "");
+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("hotlist_changed", "buffers_signal_hotlist", "");
 #weechat::hook_command_run("/input switch_active_*", "buffers_signal_buffer", "");
 weechat::bar_item_update($SCRIPT_NAME);
 
@@ -223,7 +240,7 @@ weechat::hook_command(  $cmd_buffers_detach,
 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_buffer", "") if ( weechat::config_integer( $options{"detach"}) > 0 );
+    $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", "");
@@ -333,7 +350,7 @@ sub hook_timer_detach
     else
     {
         weechat::unhook($Hooks{timer_detach}) if $Hooks{timer_detach};
-        $Hooks{timer_detach} = weechat::hook_timer( weechat::config_integer( $options{"detach"}) * 1000, 60, 0, "buffers_signal_buffer", "");
+        $Hooks{timer_detach} = weechat::hook_timer( weechat::config_integer( $options{"detach"}) * 1000, 60, 0, "buffers_signal_hotlist", "");
     }
     weechat::bar_item_update($SCRIPT_NAME);
     return weechat::WEECHAT_RC_OK;
@@ -342,7 +359,7 @@ sub hook_timer_detach
 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} = "";
@@ -375,69 +392,74 @@ sub buffers_config_init
     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 behind channel number", "", 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", "", "", ""],
+ "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, "", "", "", "", "", "", "", "", "", "");
@@ -839,6 +861,14 @@ sub build_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)
@@ -903,8 +933,6 @@ sub build_buffers
                 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")
@@ -914,7 +942,7 @@ sub build_buffers
                             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"));
                                 }
@@ -994,6 +1022,15 @@ sub build_buffers
                 $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"};
     }
@@ -1096,7 +1133,8 @@ 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)
     {
@@ -1196,7 +1234,7 @@ sub buffers_hsignal_mouse
 
     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 )
             {
@@ -1216,7 +1254,7 @@ sub buffers_hsignal_mouse
         }
         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
@@ -1245,7 +1283,7 @@ sub buffers_hsignal_mouse
         }
         else
         {
-            move_buffer(%hash);
+            move_buffer(%hash) if (weechat::config_boolean($options{"mouse_move_buffer"}));
         }
     }
 }
@@ -1258,8 +1296,20 @@ sub 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);
index 967f973d7d16e48f9c0358b3f44e38e64e47bcd2..2aeb1de5c57080f632538c64f717c676c5f3a6b1 100644 (file)
@@ -1,6 +1,6 @@
 #
 # highmon.pl - Highlight Monitoring for weechat 0.3.0
-# Version 2.3.3.2
+# Version 2.4
 #
 # Add 'Highlight Monitor' buffer/bar to log all highlights in one spot
 #
@@ -66,6 +66,8 @@
 # Bugs and feature requests at: https://github.com/KenjiE20/highmon
 
 # History:
+# 2013-12-04, KenjiE20 <longbow@longbowslair.co.uk>:
+#      v2.4:   -add: Support for eval style colour codes in time format used for bar output
 # 2013-10-22, KenjiE20 <longbow@longbowslair.co.uk>:
 #      v2.3.3.2:       -fix: Typo in fix command
 # 2013-10-10, KenjiE20 <longbow@longbowslair.co.uk>:
@@ -852,13 +854,14 @@ sub highmon_print
                use POSIX qw(strftime);
                $time = strftime(weechat::config_string(weechat::config_get("weechat.look.buffer_time_format")), localtime);
                # Colourise
-               if ($time =~ /\$\{\w+\}/) # Coloured string
+               if ($time =~ /\$\{(?:color:)?[\w,]+\}/) # Coloured string
                {
-                       while ($time =~ /\$\{(\w+)\}/)
+                       while ($time =~ /\$\{(?:color:)?([\w,]+)\}/)
                        {
                                $color = weechat::color($1);
-                               $time =~ s/\$\{\w+\}/$color/;
+                               $time =~ s/\$\{(?:color:)?[\w,]+\}/$color/;
                        }
+                       $time .= weechat::color("reset");
                }
                else # Default string
                {
@@ -1068,7 +1071,7 @@ sub format_buffer_name
 }
 
 # Check result of register, and attempt to behave in a sane manner
-if (!weechat::register("highmon", "KenjiE20", "2.3.3.2", "GPL3", "Highlight Monitor", "", ""))
+if (!weechat::register("highmon", "KenjiE20", "2.4", "GPL3", "Highlight Monitor", "", ""))
 {
        # Double load
        weechat::print ("", "\tHighmon is already loaded");
index 7d7284735764ad8965ba29721960788a9c5ec372..377b7c3608b4324eb7f06e49f0872d75acd45107 100644 (file)
@@ -19,6 +19,9 @@
 #
 # History:
 #
+# 2014-01-16, luz <ne.tetewi@gmail.com>:
+#     version 3.3: fix bug with column alignment in iset buffer when option
+#                  name contains unicode characters
 # 2013-08-03, Sebastien Helleu <flashcode@flashtux.org>:
 #     version 3.2: allow "q" as input in iset buffer to close it
 # 2013-07-14, Sebastien Helleu <flashcode@flashtux.org>:
 use strict;
 
 my $PRGNAME = "iset";
-my $VERSION = "3.2";
+my $VERSION = "3.3";
 my $DESCR   = "Interactive Set for configuration options";
 my $AUTHOR  = "Sebastien Helleu <flashcode\@flashtux.org>";
 my $LICENSE = "GPL3";
@@ -452,7 +455,16 @@ sub iset_refresh_line
         if ($y <= $#options_names)
         {
             return if (! defined($options_types[$y]));
-            my $format = sprintf("%%s%%-%ds %%s %%-7s %%s %%s%%s%%s", $option_max_length);
+            my $format = sprintf("%%s%%s%%s %%s %%-7s %%s %%s%%s%%s");
+            my $padding;
+            if ($wee_version_number >= 0x00040200)
+            {
+                $padding = " " x ($option_max_length - weechat::strlen_screen($options_names[$y]));
+            }
+            else
+            {
+                $padding = " " x ($option_max_length - length($options_names[$y]));
+            }
             my $around = "";
             $around = "\"" if ((!$options_is_null[$y]) && ($options_types[$y] eq "string"));
 
@@ -483,7 +495,7 @@ sub iset_refresh_line
             my $value = $options_values[$y];
             $value = "(undef)" if ($options_is_null[$y]);
             my $strline = sprintf($format,
-                                  $color1, $options_names[$y],
+                                  $color1, $options_names[$y], $padding,
                                   $color2, $options_types[$y],
                                   $color3, $around, $value, $around);
             weechat::print_y($iset_buffer, $y, $strline);
diff --git a/weechat/python/autoload/buffer_autoset.py b/weechat/python/autoload/buffer_autoset.py
new file mode 120000 (symlink)
index 0000000..cdcf0db
--- /dev/null
@@ -0,0 +1 @@
+../buffer_autoset.py
\ No newline at end of file
diff --git a/weechat/python/buffer_autoset.py b/weechat/python/buffer_autoset.py
new file mode 100644 (file)
index 0000000..a130909
--- /dev/null
@@ -0,0 +1,226 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2010-2012 Sebastien Helleu <flashcode@flashtux.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+#
+# Auto-set buffer properties when a buffer is opened.
+# (this script requires WeeChat 0.3.2 or newer)
+#
+# History:
+#
+# 2012-12-09, Nils Görs <freenode@#weechat>:
+#     version 0.6: add support of core buffer
+# 2012-03-09, Sebastien Helleu <flashcode@flashtux.org>:
+#     version 0.5: fix reload of config file
+# 2012-01-03, Sebastien Helleu <flashcode@flashtux.org>:
+#     version 0.4: make script compatible with Python 3.x
+# 2010-12-02, Sebastien Helleu <flashcode@flashtux.org>:
+#     version 0.3: "no_highlight_nicks" replaced by "hotlist_max_level_nicks"
+# 2010-10-11, Sebastien Helleu <flashcode@flashtux.org>:
+#     version 0.2: add example in /help autosetbuffer with new buffer
+#                  property "no_highlight_nicks"
+# 2010-04-19, Sebastien Helleu <flashcode@flashtux.org>:
+#     version 0.1: initial release
+#
+
+SCRIPT_NAME    = "buffer_autoset"
+SCRIPT_AUTHOR  = "Sebastien Helleu <flashcode@flashtux.org>"
+SCRIPT_VERSION = "0.6"
+SCRIPT_LICENSE = "GPL3"
+SCRIPT_DESC    = "Auto-set buffer properties when a buffer is opened"
+
+SCRIPT_COMMAND = "autosetbuffer"
+
+import_ok = True
+
+try:
+    import weechat
+except ImportError:
+    print("This script must be run under WeeChat.")
+    print("Get WeeChat now at: http://www.weechat.org/")
+    import_ok = False
+
+CONFIG_FILE_NAME = "buffer_autoset"
+
+# config file
+bas_config_file = ""
+
+# =================================[ config ]=================================
+
+def bas_config_init():
+    """
+    Initialization of configuration file.
+    Sections: buffer.
+    """
+    global bas_config_file
+    bas_config_file = weechat.config_new(CONFIG_FILE_NAME,
+                                         "bas_config_reload_cb", "")
+    if bas_config_file == "":
+        return
+
+    # section "buffer"
+    section_buffer = weechat.config_new_section(
+        bas_config_file, "buffer", 1, 1, "", "", "", "", "", "",
+        "bas_config_buffer_create_option_cb", "", "", "")
+    if section_buffer == "":
+        weechat.config_free(bas_config_file)
+        return
+
+def bas_config_buffer_create_option_cb(data, config_file, section, option_name, value):
+    option = weechat.config_search_option(config_file, section, option_name)
+    if option:
+        return weechat.config_option_set (option, value, 1)
+    else:
+        option = weechat.config_new_option (config_file, section, option_name, "string",
+                                            "", "", 0, 0, "", value, 0,
+                                            "", "", "", "", "", "")
+        if not option:
+            return weechat.WEECHAT_CONFIG_OPTION_SET_ERROR
+        return weechat.WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE
+
+def bas_config_reload_cb(data, config_file):
+    """ Reload configuration file. """
+    return weechat.config_reload(config_file)
+
+def bas_config_read():
+    """ Read configuration file. """
+    global bas_config_file
+    return weechat.config_read(bas_config_file)
+
+def bas_config_write():
+    """ Write configuration file. """
+    global bas_config_file
+    return weechat.config_write(bas_config_file)
+
+# ================================[ command ]=================================
+
+def bas_cmd(data, buffer, args):
+    """ Callback for /autosetbuffer command. """
+    args = args.strip()
+    if args == "":
+        weechat.command("", "/set %s.buffer.*" % CONFIG_FILE_NAME)
+        return weechat.WEECHAT_RC_OK
+    argv = args.split(None, 3)
+    if len(argv) > 0:
+        if argv[0] == "add":
+            if len(argv) < 4:
+                weechat.command("", "/help %s" % SCRIPT_COMMAND)
+                return weechat.WEECHAT_RC_OK
+            weechat.command("", "/set %s.buffer.%s.%s \"%s\""
+                            % (CONFIG_FILE_NAME, argv[1], argv[2], argv[3]))
+        elif argv[0] == "del":
+            if len(argv) < 2:
+                weechat.command("", "/help %s" % SCRIPT_COMMAND)
+                return weechat.WEECHAT_RC_OK
+            weechat.command("", "/unset %s.buffer.%s"
+                            % (CONFIG_FILE_NAME, argv[1]))
+        else:
+            weechat.command("", "/help %s" % SCRIPT_COMMAND)
+            return weechat.WEECHAT_RC_OK
+    return weechat.WEECHAT_RC_OK
+
+def bas_completion_current_buffer_cb(data, completion_item, buffer, completion):
+    """ Complete with current buffer name (plugin.name), for command '/autosetbuffer'. """
+    name = "%s.%s" % (weechat.buffer_get_string(buffer, "plugin"),
+                      weechat.buffer_get_string(buffer, "name"))
+    weechat.hook_completion_list_add(completion, name,
+                                     0, weechat.WEECHAT_LIST_POS_BEGINNING)
+    return weechat.WEECHAT_RC_OK
+
+def bas_completion_options_cb(data, completion_item, buffer, completion):
+    """ Complete with config options, for command '/autosetbuffer'. """
+    options = weechat.infolist_get("option", "", "%s.buffer.*" % CONFIG_FILE_NAME)
+    if options:
+        while weechat.infolist_next(options):
+            weechat.hook_completion_list_add(completion,
+                                             weechat.infolist_string(options, "option_name"),
+                                             0, weechat.WEECHAT_LIST_POS_SORT)
+        weechat.infolist_free(options)
+    return weechat.WEECHAT_RC_OK
+
+# =================================[ signal ]=================================
+
+def bas_signal_buffer_opened_cb(data, signal, signal_data):
+    buffer = signal_data
+    name = "%s.%s" % (weechat.buffer_get_string(buffer, "plugin"),
+                      weechat.buffer_get_string(buffer, "name"))
+    options = weechat.infolist_get("option", "", "%s.buffer.*" % CONFIG_FILE_NAME)
+    if options:
+        while weechat.infolist_next(options):
+            option = weechat.infolist_string(options, "option_name")
+            value = weechat.infolist_string(options, "value")
+            if option:
+                pos = option.rfind(".")
+                if pos > 0:
+                    buffer_mask = option[0:pos]
+                    property = option[pos+1:]
+                    if buffer_mask and property:
+                        if weechat.string_match(name, buffer_mask, 1):
+                            weechat.buffer_set(buffer, property, value)
+        weechat.infolist_free(options)
+    return weechat.WEECHAT_RC_OK
+
+# ==================================[ main ]==================================
+
+if __name__ == "__main__" and import_ok:
+    if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE,
+                        SCRIPT_DESC, "bas_unload_script", ""):
+        version = weechat.info_get("version_number", "") or 0
+        if int(version) < 0x00030200:
+            weechat.prnt("", "%s%s: WeeChat 0.3.2 is required for this script."
+                         % (weechat.prefix("error"), SCRIPT_NAME))
+        else:
+            bas_config_init()
+            bas_config_read()
+            weechat.hook_command(SCRIPT_COMMAND,
+                                 "Auto-set buffer properties when a buffer is opened",
+                                 "[add buffer property value] | [del option]",
+                                 "     add: add a buffer/property/value in configuration file\n"
+                                 "     del: delete an option from configuration file\n"
+                                 "  buffer: name of a buffer (can start or end with \"*\" as wildcard)\n"
+                                 "property: buffer property\n"
+                                 "   value: value for property\n"
+                                 "  option: name of option from configuration file\n\n"
+                                 "Examples:\n"
+                                 "  disable timestamp on channel #weechat:\n"
+                                 "    /" + SCRIPT_COMMAND + " add irc.freenode.#weechat time_for_each_line 0\n"
+                                 "  add word \"weechat\" in highlight list on channel #savannah:\n"
+                                 "    /" + SCRIPT_COMMAND + " add irc.freenode.#savannah highlight_words_add weechat\n"
+                                 "  disable highlights from nick \"mike\" on freenode server, channel #weechat (requires WeeChat >= 0.3.4):\n"
+                                 "    /" + SCRIPT_COMMAND + " add irc.freenode.#weechat hotlist_max_level_nicks_add mike:2\n"
+                                 "  disable hotlist changes for nick \"bot\" on freenode server (all channels) (requires WeeChat >= 0.3.4):\n"
+                                 "    /" + SCRIPT_COMMAND + " add irc.freenode.* hotlist_max_level_nicks_add bot:-1",
+                                 "add %(buffers_plugins_names)|%(buffer_autoset_current_buffer) %(buffer_properties_set)"
+                                 " || del %(buffer_autoset_options)",
+                                 "bas_cmd", "")
+            weechat.hook_completion("buffer_autoset_current_buffer", "current buffer name for buffer_autoset",
+                                    "bas_completion_current_buffer_cb", "")
+            weechat.hook_completion("buffer_autoset_options", "list of options for buffer_autoset",
+                                    "bas_completion_options_cb", "")
+            weechat.hook_signal("buffer_opened", "bas_signal_buffer_opened_cb", "")
+
+            # core buffer is already open on script startup, check manually!
+            bas_signal_buffer_opened_cb("", "", weechat.buffer_search_main())
+# ==================================[ end ]===================================
+
+def bas_unload_script():
+    """ Function called when script is unloaded. """
+    global bas_config_file
+
+    if bas_config_file:
+        bas_config_write()
+    return weechat.WEECHAT_RC_OK
index e2a69e545e41a1520c0472dc47461f51a6b4831a..d29e7e24ceab1c13b52e4eb3316f95c8c9521bf3 100644 (file)
@@ -8,7 +8,7 @@ diff_color = on
 diff_command = "auto"
 display_source = on
 quiet_actions = on
-sort = "p,n"
+sort = "i,p,n"
 translate_description = on
 use_keys = on