--- rxvt-unicode/src/urxvt.pm 2014/12/26 19:19:30 1.247 +++ rxvt-unicode/src/urxvt.pm 2014/12/26 21:49:11 1.250 @@ -47,11 +47,10 @@ Extensions may add additional resources and C, i.e., methods which can be bound to a key and invoked by the user. An extension can -define the resources it support and also default bindings for one or -more actions it provides using so called META comments, described -below. Similarly to builtin resources, extension resources can also be -specified on the command line as long options (with C<.> replaced by -C<->), in which case the corresponding extension is loaded +define the resources it support using so called META comments, +described below. Similarly to builtin resources, extension resources +can also be specified on the command line as long options (with C<.> +replaced by C<->), in which case the corresponding extension is loaded automatically. For this to work the extension B define META comments for its resources. @@ -120,7 +119,7 @@ Rxvt-unicode recognizes special meta comments in extensions that define different types of metadata. -Currently, it recxognises only one such comment: +Currently, it recognises only one such comment: =over 4 @@ -717,9 +716,7 @@ if ($_ eq "default") { $ext_arg{$_} = [] - for - qw(selection option-popup selection-popup readline searchable-scrollback), - map $_->[0], values %{ $TERM->{meta}{binding} }; + for qw(selection option-popup selection-popup readline searchable-scrollback); for ($TERM->_keysym_resources) { next if /^(?:string|command|builtin|builtin-string|perl)/; @@ -741,13 +738,6 @@ } } - # now register default key bindings - for my $ext (sort keys %ext_arg) { - while (my ($k, $v) = each %{ $TERM->{meta}{ext}{$ext}{binding} }) { - $TERM->bind_action ($k, "$v->[0]:$v->[1]"); - } - } - for my $ext (sort keys %ext_arg) { my @files = grep -f $_, map "$_/$ext", @dirs; @@ -1145,20 +1135,30 @@ return if exists $self->{meta}; - my @libdirs = perl_libdirs $self; - -# return if $self->{meta_libdirs} eq join "\x00", @libdirs;#d# + my @urxvtdirs = perl_libdirs $self; + my @cpandirs = grep -d, map "$_/URxvt/Ext", @INC; -# $self->{meta_libdirs} = join "\x00", @libdirs;#d# $self->{meta} = \my %meta; # first gather extensions - for my $dir (reverse @libdirs) { + + my $gather = sub { + my ($dir, $core) = @_; + opendir my $fh, $dir - or next; + or return; + for my $ext (readdir $fh) { $ext !~ /^\./ - and open my $fh, "<", "$dir/$ext" + or next; + + open my $fh, "<", "$dir/$ext" + or next; + + -f $fh + or next; + + $ext =~ s/\.uext$// or $core or next; my %ext = (dir => $dir); @@ -1172,9 +1172,6 @@ } else { $ext{resource}{$pattern} = [$ext, $type, $desc]; } - } elsif (/^#:META:BINDING:(.*)/) { - my ($keysym, $action) = split /:/, $1; - $ext{binding}{$keysym} = [$ext, $action]; } elsif (/^\s*(?:#|$)/) { # skip other comments and empty lines } else { @@ -1184,13 +1181,15 @@ $meta{ext}{$ext} = \%ext; } - } + }; + + $gather->($_, 0) for @cpandirs; + $gather->($_, 1) for @urxvtdirs; - # and now merge resources and bindings + # and now merge resources while (my ($k, $v) = each %{ $meta{ext} }) { #TODO: should check for extensions overriding each other %{ $meta{resource} } = (%{ $meta{resource} }, %{ $v->{resource} }); - %{ $meta{binding} } = (%{ $meta{binding} }, %{ $v->{binding} }); } } @@ -1351,9 +1350,9 @@ Adds a key binding exactly as specified via a C resource. See the C resource in the urxvt(1) manpage. -To add default bindings for an extension, the extension should call C<< -->bind_action >> on it's C hook for every such binding. Doing it -in the C hook allows users the override or remove the the binding +To add default bindings for actions, an extension should call C<< +->bind_action >> in its C hook for every such binding. Doing it +in the C hook allows users to override or remove the binding again. Example: the C by default binds itself