From 90b070034d3f8094df405cf331367fde3e9c4e50 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Tue, 25 Jan 2022 08:07:29 +0100 Subject: [PATCH] rc diff: skip email quotes in diff-jump When reading and writing emails that contain patches (possibly email-quoted), it can be convenient to the jump to the source file. Allow this by making diff-jump (bound to in git-diff buffers) ignore leading email quotes ("> "). A line that starts with "> " should not occur in a unified diff, so this won't affect other use cases. Observe that diff-jump even works around interleaved replies; they will not affect the computed line numbers because we ignore lines that don't match ^(> )*[ +-]. --- rc/filetype/diff.kak | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rc/filetype/diff.kak b/rc/filetype/diff.kak index 586bb32c..6658bab0 100644 --- a/rc/filetype/diff.kak +++ b/rc/filetype/diff.kak @@ -32,7 +32,7 @@ Switches: set-register c %val{cursor_column} # If there is a "diff" line, we don't need to look further back. try %{ - execute-keys %{^diff\b} + execute-keys %{^(?:> )*diff\b} } catch %{ # A single file diff won't have a diff line. Start parsing from # the buffer start, so we can tell if +++/--- lines are headers @@ -73,6 +73,7 @@ Switches: $have_diff_line = 0; $state = "header"; while () { + s/^(> )*//g; $last_line = $_; if (m{^diff\b}) { $state = "header";