repo: rxvt-unicode-sixel
action: commit
revision: 
path_from: 
revision_from: 3c7928ef765702733562cf78061abd0f05f4ac59:
path_to: 
revision_to: 
git.thebackupbox.net
rxvt-unicode-sixel
git clone git://git.thebackupbox.net/rxvt-unicode-sixel
commit 3c7928ef765702733562cf78061abd0f05f4ac59
Author: Marc Lehmann 
Date:   Sun Jun 10 13:58:06 2012 +0000

    *** empty log message ***

diff --git a/src/perl/background b/src/perl/background
index 3c744fe527ad2c5aed2955dda61d84bfab304762..
index ..a5d7315e66e70991a5dd6aac8c74dcc75c42027b 100644
--- a/src/perl/background
+++ b/src/perl/background
@@ -858,13 +858,13 @@ sub recalculate {
 sub on_start {
    my ($self) = @_;

-   my $expr = $self->x_resource ("background.expr")
+   my $expr = $self->x_resource ("%.expr")
       or return;

    $self->set_expr (parse_expr $expr);
-   $self->{border} = $self->x_resource_boolean ("background.border");
+   $self->{border} = $self->x_resource_boolean ("%.border");

-   $MIN_INTERVAL = $self->x_resource ("background.interval");
+   $MIN_INTERVAL = $self->x_resource ("%.interval");

    ()
 }
diff --git a/src/perl/matcher b/src/perl/matcher
index 9dfb909b92ced2d230a039580a2c3699c80f355b..
index ..0b3d00aaeef9be388f2b6a33377730aca71bcb07 100644
--- a/src/perl/matcher
+++ b/src/perl/matcher
@@ -130,8 +130,7 @@ sub most_recent {
 }

 sub my_resource {
-   my $self = shift;
-   $self->x_resource ("$self->{name}.$_[0]");
+   $_[0]->x_resource ("%.$_[1]")
 }

 # turn a rendition spec in the resource into a sub that implements it on $_
@@ -152,8 +151,6 @@ sub parse_rend {
 sub on_start {
    my ($self) = @_;

-   ($self->{name} = __PACKAGE__) =~ s/.*:://;
-   $self->{name} =~ tr/_/-/;
    $self->{launcher} = $self->my_resource ("launcher") || $self->x_resource("url-launcher") || "sensible-browser";

    $self->{urls} = [];
@@ -172,7 +169,7 @@ sub on_start {
          } elsif($mod eq "M") {
             $self->{state} |= $self->ModMetaMask;
          } elsif($mod ne "-" && $mod ne " ") {
-            warn("$mod is invalid in $self->{name}<$self->{argv}[0]>\n");
+            warn("$mod is invalid in $self->{_name}<$self->{argv}[0]>\n");
          }
       }
    }
diff --git a/src/perl/remote-clipboard b/src/perl/remote-clipboard
index 439bd6774925cdf7411b07e3866234c235b45cc0..
index ..433b4ce87d69bd2b4c294a9492619b97d7f5ec96 100644
--- a/src/perl/remote-clipboard
+++ b/src/perl/remote-clipboard
@@ -87,10 +87,10 @@ sub fetch {
 sub on_start {
    my ($self) = @_;

-   $self->{store_cmd} = $self->x_resource ("remote-selection.store")
+   $self->{store_cmd} = $self->x_resource ("%.store")
                         || "rsh ruth 'cat >/tmp/distributed-selection'";

-   $self->{fetch_cmd} = $self->x_resource ("remote-selection.fetch")
+   $self->{fetch_cmd} = $self->x_resource ("%.fetch")
                         || "rsh ruth 'cat /tmp/distributed-selection'";

    push @{ $self->{term}{selection_popup_hook} }, sub {
diff --git a/src/perl/searchable-scrollback b/src/perl/searchable-scrollback
index 0fc1c08d1467f6c28aa319941383848d6bb22238..
index ..51262b00266d6afcdd8fcfed55998d6e09687ce5 100644
--- a/src/perl/searchable-scrollback
+++ b/src/perl/searchable-scrollback
@@ -8,7 +8,7 @@ sub on_init {
    my ($self) = @_;

    my $hotkey = $self->{argv}[0]
-                || $self->x_resource ("searchable-scrollback")
+                || $self->x_resource ("%")
                 || "M-s";

    $self->parse_keysym ($hotkey, "perl:searchable-scrollback:start")
diff --git a/src/perl/selection-autotransform b/src/perl/selection-autotransform
index 410e33e4ed4dd17a3a5a646aed1b2fdff2799499..
index ..352b0f38ee4b37a6356fd59dca271ef4292e982f 100644
--- a/src/perl/selection-autotransform
+++ b/src/perl/selection-autotransform
@@ -16,7 +16,7 @@ sub msg {
 sub on_init {
    my ($self) = @_;

-   for (my $idx = 0; defined (my $res = $self->x_resource ("selection-autotransform.$idx")); $idx++) {
+   for (my $idx = 0; defined (my $res = $self->x_resource ("%.$idx")); $idx++) {
       $res = $self->locale_decode ($res);
       my $transform = eval "sub { $res }";

diff --git a/src/perl/selection-pastebin b/src/perl/selection-pastebin
index f6086752fee130e883ab6ea1d02e57de5ad1ac2d..
index ..e53764a0e502b8ed9ccb85c8214a86c3cf494626 100644
--- a/src/perl/selection-pastebin
+++ b/src/perl/selection-pastebin
@@ -62,10 +62,10 @@ sub upload_paste {
 sub on_start {
    my ($self) = @_;

-   $self->{pastebin_cmd} = $self->x_resource ("selection-pastebin.cmd")
+   $self->{pastebin_cmd} = $self->x_resource ("%.cmd")
                            || "rcp -p % ruth:/var/www/www.ta-sa.org/files/txt/";

-   $self->{pastebin_url} = $self->x_resource ("selection-pastebin.url")
+   $self->{pastebin_url} = $self->x_resource ("%.url")
                            || "http://www.ta-sa.org/files/txt/%";

    push @{ $self->{term}{selection_popup_hook} }, sub {
diff --git a/src/urxvt.pm b/src/urxvt.pm
index 56fd2b9a50528ec9f64373dbe2d74ecad9ad93e9..
index ..c0fdc3379a1642fcf639a164c170ad73e2ae1aa9 100644
--- a/src/urxvt.pm
+++ b/src/urxvt.pm
@@ -1026,6 +1026,8 @@ sub extension_package($) {

       verbose 3, "loading extension '$path' into package '$pkg'";

+      (${"$pkg\::_NAME"} = $path) =~ s/^.*[\\\/]//; # hackish
+
       open my $fh, "<:raw", $path
          or die "$path: $!";

@@ -1152,8 +1154,6 @@ sub rend2mask {
    ($mask, @color{qw(fg bg)}, \@failed)
 }

-# urxvt::term::extension
-
 package urxvt::term::extension;

 sub enable {
@@ -1217,6 +1217,18 @@ sub urxvt::destroy_hook(&) {
    bless \shift, urxvt::destroy_hook::
 }

+sub x_resource {
+   my ($self, $name) = @_;
+   $name =~ s/^%(\.|$)/$_[0]{_name}$1/;
+   $self->{term}->x_resource ($name)
+}
+
+sub x_resource_boolean {
+   my ($self, $name) = @_;
+   $name =~ s/^%(\.|$)/$_[0]{_name}$1/;
+   $self->{term}->x_resource_boolean ($name)
+}
+
 package urxvt::anyevent;

 =head2 The C Class
@@ -1321,8 +1333,9 @@ sub register_package {
    @{"$pkg\::ISA"} = urxvt::term::extension::;

    my $proxy = bless {
-      _pkg => $pkg,
-      argv => $argv,
+      _pkg  => $pkg,
+      _name => ${"$pkg\::_NAME"}, # hackish
+      argv  => $argv,
    }, $pkg;
    Scalar::Util::weaken ($proxy->{term} = $self);

@@ -1504,6 +1517,16 @@ class name, i.e.  C<< $term->x_resource ("boldFont") >> should return the
 same value as used by this instance of rxvt-unicode. Returns C if no
 resource with that pattern exists.

+Extensions that define extra resource or command line arguments also need
+to call this method to access their values.
+
+If the method is called on an extension object (basically, from an
+extension), then the special prefix C<%.> will be replaced by the name of
+the extension and a dot, and the lone string C<%> will be replcaed by the
+extension name itself. This makes it possible to code extensions so you
+can rename them and get a new set of commandline switches and resources
+without having to change the actual code.
+
 This method should only be called during the C hook, as there is
 only one resource database per display, and later invocations might return
 the wrong resources.

-----END OF PAGE-----