]> git.99rst.org Git - irssi-scripts.irssi.org.git/commitdiff
chanact: allow case-insensitive aliases, silence extraneous /window_alias error message
authorTrevor Slocum <redacted>
Tue, 26 Apr 2016 01:46:30 +0000 (18:46 -0700)
committerTrevor Slocum <redacted>
Tue, 26 Apr 2016 01:46:30 +0000 (18:46 -0700)
scripts/chanact.pl

index c3fb3e0458a35f30d4733121288b1bf88802839d..ee6ef3ca2fbb23bf8af7cae769bd97594c3b0b44 100644 (file)
@@ -5,7 +5,7 @@ use Irssi::TextUI;
 
 use vars qw($VERSION %IRSSI);
 
-$VERSION = "0.5.14";
+$VERSION = "0.5.15";
 %IRSSI = (
     authors     => 'BC-bd, Veli',
     contact     => 'bd@bc-bd.org, veli@piipiip.net',
@@ -34,6 +34,7 @@ $VERSION = "0.5.14";
 #                     chanact_filter_windowlist basis
 # Jan 'jast' Krueger <jast@heapsort.de>, 2004-06-22
 # Ivo Timmermans <ivo@o2w.nl>  win->{hilight} patch
+# Trevor 'tee' Slocum <tslocum@gmail.com> Case-insensitive aliases, bugfix
 # 
 #########
 # USAGE
@@ -108,6 +109,12 @@ $VERSION = "0.5.14";
 #
 #                  with '3:+.' highlighted and the channel name printed in regular color
 #
+# /set chanact_case_sensitive <ON|OFF>
+#              * ON  : Aliases are case-sensitive
+#              * OFF : Aliases are case-insensitive
+#
+#              Existing aliases must be reapplied after switching to case-insensitive.
+#
 # /set chanact_display_alias <string>
 #   as 'chanact_display' but is used if the window has an alias and
 #   'chanact_show_alias' is set to on.
@@ -424,9 +431,9 @@ sub setup_changed {
 
 # Remove alias
 sub cmd_window_unalias {
-       my ($data, $server, $witem) = @_;
+       my ($data, $server, $witem, $internal) = @_;
 
-       if ($data ne '') {
+       if ($data ne '' && !$internal) {
                Irssi::print("chanact: /window_unalias does not take any ".
                        "parameters, Run it in the window you want to unalias");
                return;
@@ -443,8 +450,13 @@ sub cmd_window_unalias {
        # haven't the name was not set by chanact, so we won't blindly unset
        # stuff
        if (length($key) == 1) {
-               $server->command("/bind -delete meta-$key");
-       } else {
+               if (Irssi::settings_get_bool('chanact_case_sensitive')) {
+                       $server->command("/bind -delete meta-$data");
+               } else {
+                       $server->command("/bind -delete meta-" . lc($data));
+                       $server->command("/bind -delete meta-" . uc($data));
+               }
+       } elsif (!$internal) {
                Irssi::print("chanact: could not determine keybinding. ".
                        "Won't unbind anything");
        }
@@ -496,7 +508,7 @@ sub cmd_window_alias {
                $winname = $window->{name};
        }
 
-       cmd_window_unalias($data, $server, $witem);
+       cmd_window_unalias($data, $server, $witem, 1);
 
        my $winnum = $window->{refnum};
        
@@ -519,7 +531,12 @@ sub cmd_window_alias {
        my $name = "$data:$winhandle";
 
        $window->set_name($name);
-       $server->command("/bind meta-$data change_window $name");
+       if (Irssi::settings_get_bool('chanact_case_sensitive')) {
+               $server->command("/bind meta-$data change_window $name");
+       } else {
+               $server->command("/bind meta-" . lc($data) . " change_window $name");
+               $server->command("/bind meta-" . uc($data) . " change_window $name");
+       }
        Irssi::print("Window $winhandle is now accessible with meta-$data");
 }
 
@@ -533,6 +550,7 @@ Irssi::command_bind('window_unalias','cmd_window_unalias');
 Irssi::settings_add_str('chanact', 'chanact_display', '$H$N:$M$C$S');
 Irssi::settings_add_str('chanact', 'chanact_display_alias', '$H$N$M$S');
 Irssi::settings_add_int('chanact', 'chanact_abbreviate_names', 0);
+Irssi::settings_add_bool('chanact', 'chanact_case_sensitive', 1);
 Irssi::settings_add_bool('chanact', 'chanact_show_alias', 1);
 Irssi::settings_add_str('chanact', 'chanact_separator', " ");
 Irssi::settings_add_bool('chanact', 'chanact_autorenumber', 0);
@@ -569,6 +587,10 @@ Irssi::signal_add('nick mode changed', 'chanactHasChanged');
 #
 # Changelog
 #
+# 0.5.15
+#      - fixed unbind error when aliasing a previously un-aliased window
+#      - added setting to allow case-insensitive window aliases
+#
 # 0.5.14
 #      - fix itemless window handling, thx Bazerka
 #      - fix /window_alias for itemless windows
git clone https://git.99rst.org/PROJECT