summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Altmanninger <aclopte@gmail.com>2022-01-25 08:07:29 +0100
committerJohannes Altmanninger <aclopte@gmail.com>2022-01-25 14:15:01 +0100
commit90b070034d3f8094df405cf331367fde3e9c4e50 (patch)
tree5577d8736cba9e49c686b4a8616d0270f9be1322
parentbf239ba77afee503f5b9bd9cf392ca2ad0fd4f8f (diff)
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 <ret> 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 ^(> )*[ +-].
-rw-r--r--rc/filetype/diff.kak3
1 files changed, 2 insertions, 1 deletions
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 %{<a-l><semicolon><a-?>^diff\b<ret><a-x>}
+ execute-keys %{<a-l><semicolon><a-?>^(?:> )*diff\b<ret><a-x>}
} 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 (<STDIN>) {
+ s/^(> )*//g;
$last_line = $_;
if (m{^diff\b}) {
$state = "header";