diff --git a/rc/tools/jump.kak b/rc/tools/jump.kak index 60d777d455..4159364b7b 100644 --- a/rc/tools/jump.kak +++ b/rc/tools/jump.kak @@ -5,6 +5,7 @@ declare-option -docstring "name of the client in which utilities display informa provide-module jump %{ +declare-option -hidden str jump_current_buffer '' declare-option -hidden int jump_current_line 0 define-command -hidden jump %{ @@ -14,6 +15,7 @@ define-command -hidden jump %{ execute-keys ',xs^([^:\n]+):(\d+):(\d+)?' set-register a %reg{1} %reg{2} %reg{3} } + set-option global jump_current_buffer %val{bufname} set-option buffer jump_current_line %val{cursor_line} evaluate-commands -try-client %opt{jumpclient} -verbatim -- edit -existing -- %reg{a} try %{ focus %opt{jumpclient} } @@ -21,17 +23,17 @@ define-command -hidden jump %{ } } -define-command jump-next -params 1.. -docstring %{ +define-command jump-next -params .. -docstring %{ jump-next : jump to next location listed in the given *grep*-like location list buffer. } %{ - evaluate-commands -try-client %opt{jumpclient} -save-regs / %{ - buffer %arg{@} - jump-select-next - jump + evaluate-commands -try-client %opt{jumpclient} -save-regs / %sh{ + args='%arg{@}' + [ "$#" -eq 0 ] && args='%opt{jump_current_buffer}' + printf %s\\n "buffer $args" jump-select-next jump } try %{ evaluate-commands -client %opt{toolsclient} %{ - buffer %arg{@} + buffer %opt{jump_current_buffer} execute-keys gg %opt{jump_current_line}g } } @@ -44,17 +46,17 @@ define-command -hidden jump-select-next %{ execute-keys ge %opt{jump_current_line}g /^[^:\n]+:\d+: } -define-command jump-previous -params 1.. -docstring %{ +define-command jump-previous -params .. -docstring %{ jump-previous : jump to previous location listed in the given *grep*-like location list buffer. } %{ - evaluate-commands -try-client %opt{jumpclient} -save-regs / %{ - buffer %arg{@} - jump-select-previous - jump + evaluate-commands -try-client %opt{jumpclient} -save-regs / %sh{ + args='%arg{@}' + [ "$#" -eq 0 ] && args='%opt{jump_current_buffer}' + printf %s\\n "buffer $args" jump-select-previous jump } try %{ evaluate-commands -client %opt{toolsclient} %{ - buffer %arg{@} + buffer %opt{jump_current_buffer} execute-keys gg %opt{jump_current_line}g } }