--- rxvt-unicode/src/perl/matcher 2014/07/30 15:22:51 1.32 +++ rxvt-unicode/src/perl/matcher 2014/10/14 09:00:43 1.34 @@ -2,9 +2,10 @@ # Author: Tim Pope # Bob Farrell +# Emanuele Giaquinta #:META:RESOURCE:%.launcher:string:default launcher command -#:META:RESOURCE:%.button:string:the button, yeah +#:META:RESOURCE:%.button:string:the mouse button used to activate a match #:META:RESOURCE:%.pattern.:string:extra pattern to match #:META:RESOURCE:%.launcher.:string:custom launcher for pattern #:META:RESOURCE:%.rend.:string:custom rendition for pattern @@ -115,15 +116,15 @@ sub on_user_command { my ($self, $cmd) = @_; - if ($cmd =~ s/^matcher:list\b//) { + if ($cmd eq "matcher:list") { $self->matchlist; - } else { - if ($cmd =~ s/^matcher:last\b//) { - $self->most_recent; - } elsif ($cmd =~ s/^matcher\b//) { - # for backward compatibility - $self->most_recent; - } + } elsif ($cmd eq "matcher:last") { + $self->most_recent; + } elsif ($cmd eq "matcher:select") { + $self->select_enter; + } elsif ($cmd eq "matcher") { + # for backward compatibility + $self->most_recent; } () @@ -268,22 +269,23 @@ # fetch the line that has changed my $line = $self->line ($row); my $text = $line->t; + my $rend; # find all urls (if any) for my $matcher (@{$self->{matchers}}) { while ($text =~ /$matcher->[0]/g) { #print "$&\n"; - my $rend = $line->r; + $rend ||= $line->r; # mark all characters as underlined. we _must_ not toggle underline, # as we might get called on an already-marked url. &{$matcher->[2]} for @{$rend}[$-[0] .. $+[0] - 1]; - - $line->r ($rend); } } + $line->r ($rend) if $rend; + () }