Skip to content

Commit 989bae8

Browse files
committed
Make the :jump-next and :jump-previous commands remember the last used jump buffer
1 parent e6d2866 commit 989bae8

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

rc/tools/jump.kak

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ declare-option -docstring "name of the client in which utilities display informa
55

66
provide-module jump %{
77

8+
declare-option -hidden str jump_current_buffer ''
89
declare-option -hidden int jump_current_line 0
910

1011
define-command -hidden jump %{
@@ -14,24 +15,27 @@ define-command -hidden jump %{
1415
execute-keys ',xs^([^:\n]+):(\d+):(\d+)?<ret>'
1516
set-register a %reg{1} %reg{2} %reg{3}
1617
}
18+
set-option global jump_current_buffer %val{bufname}
1719
set-option buffer jump_current_line %val{cursor_line}
1820
evaluate-commands -try-client %opt{jumpclient} -verbatim -- edit -existing -- %reg{a}
1921
try %{ focus %opt{jumpclient} }
2022
}
2123
}
2224
}
2325

24-
define-command jump-next -params 1.. -docstring %{
26+
define-command -hidden jump-buffer -params 1.. %{ buffer %arg{1} }
27+
28+
define-command jump-next -params ..1 -docstring %{
2529
jump-next <bufname>: jump to next location listed in the given *grep*-like location list buffer.
2630
} %{
2731
evaluate-commands -try-client %opt{jumpclient} -save-regs / %{
28-
buffer %arg{@}
32+
jump-buffer %arg{@} %opt{jump_current_buffer}
2933
jump-select-next
3034
jump
3135
}
3236
try %{
3337
evaluate-commands -client %opt{toolsclient} %{
34-
buffer %arg{@}
38+
buffer %opt{jump_current_buffer}
3539
execute-keys gg %opt{jump_current_line}g
3640
}
3741
}
@@ -44,17 +48,17 @@ define-command -hidden jump-select-next %{
4448
execute-keys ge %opt{jump_current_line}g<a-l> /^[^:\n]+:\d+:<ret>
4549
}
4650

47-
define-command jump-previous -params 1.. -docstring %{
51+
define-command jump-previous -params ..1 -docstring %{
4852
jump-previous <bufname>: jump to previous location listed in the given *grep*-like location list buffer.
4953
} %{
5054
evaluate-commands -try-client %opt{jumpclient} -save-regs / %{
51-
buffer %arg{@}
55+
jump-buffer %arg{@} %opt{jump_current_buffer}
5256
jump-select-previous
5357
jump
5458
}
5559
try %{
5660
evaluate-commands -client %opt{toolsclient} %{
57-
buffer %arg{@}
61+
buffer %opt{jump_current_buffer}
5862
execute-keys gg %opt{jump_current_line}g
5963
}
6064
}

0 commit comments

Comments
 (0)