From 38bb9fc3a864ffc7cec686e6232333fb7390d5d9 Mon Sep 17 00:00:00 2001 From: Frank LENORMAND Date: Mon, 3 Aug 2015 21:46:46 +0300 Subject: [PATCH] Modify the name and attribute of three grep commands Add the "grep" prefix to the "jump", "next" and "prev" commands for homogeneity with other kak scripts, and prevent the "grep-jump" command from raising errors by enclosing it into a try{} scope. --- rc/grep.kak | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/rc/grep.kak b/rc/grep.kak index a009dad2..15a70332 100644 --- a/rc/grep.kak +++ b/rc/grep.kak @@ -34,14 +34,16 @@ hook global WinSetOption filetype=(?!grep).* %{ rmhl grep; rmhooks buffer grep-h decl str jumpclient -def jump %{ - exec 'xs^((?:\w:)?[^:]+):(\d+):(\d+)?' - set buffer _grep_current_line %val{cursor_line} - eval -try-client %opt{jumpclient} edit -existing %reg{1} %reg{2} %reg{3} - try %{ focus %opt{jumpclient} } +def grep-jump %{ + try %{ + exec 'xs^((?:\w:)?[^:]+):(\d+):(\d+)?' + set buffer _grep_current_line %val{cursor_line} + eval -try-client %opt{jumpclient} edit -existing %reg{1} %reg{2} %reg{3} + try %{ focus %opt{jumpclient} } + } } -def next -docstring 'Jump to next grep match' %{ +def grep-next -docstring 'Jump to next grep match' %{ eval -try-client %opt{jumpclient} %{ buffer '*grep*' exec "%opt{_grep_current_line}g/^[^:]+:\d+:" @@ -49,7 +51,7 @@ def next -docstring 'Jump to next grep match' %{ } } -def prev -docstring 'Jump to previous grep match' %{ +def grep-prev -docstring 'Jump to previous grep match' %{ eval -try-client %opt{jumpclient} %{ buffer '*grep*' exec "%opt{_grep_current_line}g^[^:]+:\d+:"