From: Simon Ruderich Date: Sun, 24 Jan 2016 00:06:27 +0000 (+0100) Subject: cleanup handler selection X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=14126138d777250aac6d90b43f1a271bba91a820;p=fcscs%2Ffcscs.git cleanup handler selection --- diff --git a/bin/fcscs b/bin/fcscs index 9c33fe9..8a040f8 100755 --- a/bin/fcscs +++ b/bin/fcscs @@ -1211,11 +1211,20 @@ RESULT: } debug \%config, 'input', 'running handler'; - my $handler = $config{state}{handler}; # set by user - $handler = $result->{match}->{handler} unless defined $handler; # set by match - $handler = $result->{handler} unless defined $handler; # set by mapping - $handler = $config{handler}{yank} unless defined $handler; # fallback - $handler->($screen, \%config, $result->{match}); + + # Choose handler with falling priority. + my @handlers = ( + $config{state}{handler}, # set by user + $result->{match}->{handler}, # set by match + $result->{handler}, # set by mapping + $config{handler}{yank}, # fallback + ); + foreach my $handler (@handlers) { + next unless defined $handler; + + $handler->($screen, \%config, $result->{match}); + last; + } last; }