From eecb272ee61ad60d634b8bfe78094e5e2ecb4939 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sun, 24 Jan 2016 00:40:04 +0100 Subject: [PATCH] replace $match->{url} with $match->{value} which is used in handlers $match->{string} is the matched string from the input. $match->{value} is used in handlers and defaults to $match->{string} but may be overwritten. --- bin/fcscs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/bin/fcscs b/bin/fcscs index 675b7f2..ade298a 100755 --- a/bin/fcscs +++ b/bin/fcscs @@ -673,7 +673,7 @@ sub handler_yank { # Use a temporary file to prevent leaking the yanked data to other users # with the command line, e.g. ps aux or top. my ($fh, $tmp) = File::Temp::tempfile(); # dies on its own - print $fh $screen->encode($match->{string}); + print $fh $screen->encode($match->{value}); close $fh or die $!; if ($config->{setting}{multiplexer} eq 'screen') { @@ -732,13 +732,9 @@ sub handler_url { debug $config, 'handler_url', 'started'; run_in_background($config, sub { - my $url = defined $match->{url} - ? $match->{url} - : $match->{string}; - my @cmd = map { $screen->encode($_) } ( @{$config->{setting}{browser}}, - $url, + $match->{value}, ); run_command($config, \@cmd); }); @@ -990,10 +986,9 @@ Example: $config{handler}{url} = sub { my ($screen, $config, $match) = @_; - my $url = defined $match->{url} ? $match->{url} : $match->{string}; - if ($url =~ m{^https://www.youtube.com/}) { + if ($match->{value} =~ m{^https://www.youtube.com/}) { return run_in_background($config, sub { - run_command($config, ['youtube-dl-wrapper', $url]); + run_command($config, ['youtube-dl-wrapper', $match->{value}]); }); } handler_url(@_); @@ -1211,6 +1206,10 @@ RESULT: goto RESULT; # reprocess special entries in result } if (defined $result->{match}) { + if (not defined $result->{match}->{value}) { + $result->{match}->{value} = $result->{match}->{string}; + } + debug \%config, 'input', 'running handler'; my $handler = $config{state}{handler}; # set by user $handler = $result->{handler} unless defined $handler; # set by mapping -- 2.43.2