Vasco Almeida <[email protected]> writes:
> - print colored $prompt_color, $patch_mode_flavour{VERB},
> - ($hunk[$ix]{TYPE} eq 'mode' ? ' mode change' :
> - $hunk[$ix]{TYPE} eq 'deletion' ? ' deletion' :
> - ' this hunk'),
> - $patch_mode_flavour{TARGET},
> - " [y,n,q,a,d,/$other,?]? ";
I hate to say this but expanding this single-liner into if/elsif/
cascade of uncountable number of arms is simply a disaster.
> + if ($patch_mode eq 'stage') {
> + if ($hunk[$ix]{TYPE} eq 'mode') {
> + print colored $prompt_color,
> + sprintf(__("Stage mode change [y,n,q,a,d,/%s,?]?
> "), $other);
> + } elsif ($hunk[$ix]{TYPE} eq 'deletion') {
> + print colored $prompt_color,
> + sprintf(__("Stage deletion [y,n,q,a,d,/%s,?]? "),
> $other);
> + } else {
> + print colored $prompt_color,
> + sprintf(__("Stage this hunk [y,n,q,a,d,/%s,?]? "),
> $other);
> + }
> + } elsif ($patch_mode eq 'stash') {
> + ...
> + }
> + }
I wonder if you can make a simple helper function so that the caller
here can still be a single-liner:
print_colored $prompt_color,
sprintf(patch_update_prompt_string($patch_mode, $hunk[$ix]{TYPE}),
$other);
where the patch_update_prompt_string helper function would look up
these messages from a table that is looked up by patch-mode and TYPE
and the run __() on it, or something?