}
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;
}