rc tools patch: figure out path to patch-range.pl without double-parsing

We double-parse a command definition to figure out the location of
a support script at load time. This feels a bit dangerous and is not
really necessary, so use %val{runtime}/rc/tools/... instead.

Reference: https://lists.sr.ht/~mawww/kakoune/%3CZbOSCK2JjJvo-RTt@gmail.com%3E
This commit is contained in:
Johannes Altmanninger 2024-02-01 10:14:51 +01:00 committed by Maxime Coste
parent 582c3c56b2
commit c2c978907f

View File

@ -10,10 +10,8 @@ define-command patch -params .. -docstring %{
is applied (unless the cursor is inside a diff header, in which case
the entire diff is applied).
To revert changes, <arguments> must contain "--reverse" or "-R".
} %exp{
evaluate-commands -draft -itersel -save-regs aefs|^ %%{
set-register f %val{source}
%{
} %{
evaluate-commands -draft -itersel -save-regs aes|^ %{
try %{
execute-keys <a-k>\n<ret>
} catch %{
@ -54,13 +52,12 @@ define-command patch -params .. -docstring %{
# a shell where it expands to nothing.
eval set -- "$kak_quoted_reg_a"
perl "${kak_reg_f%/*}/patch-range.pl" $min_line $max_line "$@" ||
perl "${kak_runtime}"/rc/tools/patch-range.pl $min_line $max_line "$@" ||
echo >$kak_command_fifo "set-register e fail 'patch: failed to apply selections, see *debug* buffer'"
}
execute-keys |<ret>
%reg{e}
}
}
}
provide-module patch %§§