summaryrefslogtreecommitdiff
path: root/rc
diff options
context:
space:
mode:
authorJohannes Altmanninger <aclopte@gmail.com>2024-09-14 12:25:00 +0200
committerMaxime Coste <mawww@kakoune.org>2024-09-16 15:23:18 +1000
commit4f5001b4d315404697d2324a400ebfd124626d49 (patch)
tree7078ea17f2e96ef870cebebc28652d129f0bdde1 /rc
parented4729a265bad1569e377e39454be6c6436ba7e3 (diff)
diff-parse.pl: don't force error message into register
A following patch wants to use this script without wrapping it in an "evaluate-commands -save-regs e %{ ... }", so simply print the raw error message and set the register to the caller. This interface is a bit weird because the error is printed quoted but for now that just makes things a bit more convenient.
Diffstat (limited to 'rc')
-rwxr-xr-xrc/filetype/diff-parse.pl4
-rw-r--r--rc/filetype/diff.kak6
-rw-r--r--rc/tools/git.kak3
3 files changed, 9 insertions, 4 deletions
diff --git a/rc/filetype/diff-parse.pl b/rc/filetype/diff-parse.pl
index 203e9b19..7453b2b3 100755
--- a/rc/filetype/diff-parse.pl
+++ b/rc/filetype/diff-parse.pl
@@ -9,8 +9,8 @@ sub quote {
}
sub fail {
my $reason = shift;
- print "set-register e fail " . quote("diff-parse.pl: $reason");
- exit;
+ print quote("diff-parse.pl: $reason");
+ exit 1;
}
my $begin;
diff --git a/rc/filetype/diff.kak b/rc/filetype/diff.kak
index 1898268a..bd24c6d9 100644
--- a/rc/filetype/diff.kak
+++ b/rc/filetype/diff.kak
@@ -98,7 +98,11 @@ define-command -hidden diff-parse -params 2.. %{
set-register e nop
set-register | %{
eval set -- "$kak_quoted_reg_a"
- perl "${kak_runtime}/rc/filetype/diff-parse.pl" "$@" >"$kak_command_fifo"
+ if ! result=$(perl "${kak_runtime}/rc/filetype/diff-parse.pl" "$@"); then
+ printf 'set-register e %s\n' "fail $result"
+ else
+ printf '%s\n' "$result"
+ fi >"$kak_command_fifo"
}
execute-keys <a-|><ret>
%reg{e}
diff --git a/rc/tools/git.kak b/rc/tools/git.kak
index 38fa2839..0d837c8d 100644
--- a/rc/tools/git.kak
+++ b/rc/tools/git.kak
@@ -555,7 +555,8 @@ define-command -params 1.. \
$version = "-";
} END %{
if ($diff_line_text !~ m{^[ -]}) {
- print "set-register e fail git blame-jump: recursive blame only works on context or deleted lines";
+ print quote "git blame-jump: recursive blame only works on context or deleted lines";
+ exit 1;
} else {
if (not defined $commit) {
$commit = "HEAD";