summaryrefslogtreecommitdiff
path: root/rc/filetype/diff.kak
AgeCommit message (Collapse)Author
2024-09-16diff-parse.pl: don't force error message into registerJohannes Altmanninger
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.
2024-09-16rc filetype diff: diff-jump to use location at main selection, not the last oneJohannes Altmanninger
The jump command does the same.
2024-02-26rc diff: plug register leakJohannes Altmanninger
Commit 36efbf4cb (rc filetype diff: extract diff parsing from diff-jump, 2024-02-03) moved the "set-register |" command but failed to move the "-save-regs |". This surfaces as register leakage in "git blame-jump". Fix that.
2024-02-05rc filetype diff: extract diff parsing from diff-jumpJohannes Altmanninger
Most diff consumers we've written only care about the "final" state after parsing through a diff. Let's extract the diff parsing part, for reuse in several new commands. In future we should try to use this (or better, a diff-parsing library) for patch-range.pl. We'd add a callback argument that is invoked once perl hunk (or line). Unfortunately I haven't found that library for Perl yet.
2024-01-26rc patch.kak: fix quotingJohannes Altmanninger
I learned that $ foo="'1 2'" $ echo $foo '1 2' Quote some variables to avoid this double unescaping.
2022-08-01Remove unnecessary leading space in prompt from mappingsJohannes Altmanninger
We often use the pattern «map global normal ": foo"». The space after the colon is unnecessary since execution of the mapping won't add to history anyway, since 217dd6a1d (Disable history when executing maps, 2015-11-10). With the parent commit, the space is no longer necessary for user mappings, so there is no reason to continue the cargo-cult. Remove the space from mappings to set a good example.
2022-07-05Make `x` just select the full linesMaxime Coste
`x` is often criticized as hard to predict due to its slightly complex behaviour of selecting next line if the current one is fully selected. Change `x` to use the previous `<a-x>` behaviour, and change `<a-x>` to trim to fully selected lines as `<a-X>` did. Adapt existing indentation script to the new behaviour
2022-06-11If trailing whitespace was introduced in git diff, show it with red backgroundSidharth Kshatriya
2022-03-08rc diff: pass diff to diff-jump via stdin instead of envJohannes Altmanninger
Passing large diff buffers via the environment can quickly result in the error "execve failed: Argument list too long". Use a pipe like in format.kak When running | (or <a-|>), Kakoune does not use %arg{@} to populate "$@" (missing feature?). Work around this by moving %arg{@} to a temporary register. Apparently $kak_quoted_reg_a will never be an empty list, so work around that too. When diff parsing fails, we take care to run "fail" in the calling client, unlike :format (probably a bug in format.kak). (This patch is best viewed while ignoring whitespace changes (diff -w))
2022-03-06rc diff: support absolute paths in diff-jumpJohannes Altmanninger
Quick repro: diff /dev/null $PWD/README.asciidoc -u | kak -e 'set-option buffer filetype diff' Fixes #4531
2022-03-06rc diff: bind diff-jump in all filetype=diff buffers, not just *.diff or ↵Johannes Altmanninger
*.patch files Mapping in the filetype hook matches others like grep.kak and man.kak. Since we map in buffer scope, git diff buffers will override diff-jump with git-diff-goto-source. This means that the diff-jump binding applies here: diff -u "$1" "$2" | kak -e 'set buffer filetype diff' Reported in: https://github.com/mawww/kakoune/issues/153#issuecomment-1030643854
2022-03-06rc diff: fix styleJohannes Altmanninger
This line was unindented by accident (I was rushing..)
2022-03-06Add a complete-command command to configure command completionMaxime Coste
This makes it possible to change command completion in hooks and paves the way to more flexibility in how custom commands can be completed
2022-02-02rc diff: evaluate diff-highlight hook before loading moduleJohannes Altmanninger
A recent commit wrapped diff.kak into a module. The module includes the hook that adds diff highlighting to filetype=diff buffers. This means that the hook is only loaded after opening the first diff buffer in a Kakoune session, so it only actually fires for the second diff buffer. Fix this by moving the hook out of the module. Fixes #4525
2022-01-25rc diff: skip email quotes in diff-jumpJohannes Altmanninger
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 ^(> )*[ +-].
2022-01-25rc diff: introduce diff-jump, replacing git-diff-goto-sourceJohannes Altmanninger
git-diff-goto-source is specific to diffs produced by Git. This patch generalizes the logic and moves it to a new diff-jump in diff.kak. The main differences are: - diff-jump handles plain file diffs (i.e. without the -r option). These have no "diff" line. This means that it needs to parse +++/--- instead. - diff-jump can go to the old file, not just the new one. - diff-jump allows to override the base directory and the number of directory components to strip. git-diff-goto-source was implemented with several nested try/catch blocks. Implementing the extra features would have added more nesting, redundancy or hidden options. To avoid that, I ported the parsing logic to Perl (which git.kak already depends on). Maybe it's possible to do the same in awk. Potential concerns: - We could move diff-jump to a new rc/tools/diff.kak but then it's not obvious where the "diff" module belongs to. - Should diff "diff-jump -1" be spelled "diff-jump -p1"? In future, the diff parser could be reused to implement a vimdiff-style feature: given a diff and the "old" line number, we can compute the corresponding "new" line number. Perhaps diff-jump should get a -client argument.
2022-01-25rc diff: make it a moduleJohannes Altmanninger
We want to move git-diff-goto-source from rc/tools/git.kak to rc/filetype/diff.kak (or should we could create rc/tools/diff.kak?). Either way, create the diff module so we can formalize this dependency. Currently this module only provides highlighters, so require it wherever we reference them. Keep the diff-select-{file,hunk} commands outside the module because people might already use them in git buffers.
2020-04-03diff.kak: add diff file and diff hunk text objectsJason Felice
2019-03-21Add categories in rc/Alex Leferry 2
Closes #2783