Collapse jumps in grep.kak and make.kak

This commit is contained in:
Maxime Coste 2016-03-20 16:37:58 +00:00
parent 38f146d849
commit 3499d440de
2 changed files with 24 additions and 20 deletions

View File

@ -35,16 +35,18 @@ hook global WinSetOption filetype=(?!grep).* %{ rmhl grep; rmhooks buffer grep-h
decl str jumpclient decl str jumpclient
def grep-jump %{ def grep-jump %{
try %{ eval -collapse-jumps %{
exec 'xs^((?:\w:)?[^:]+):(\d+):(\d+)?<ret>' try %{
set buffer _grep_current_line %val{cursor_line} exec 'xs^((?:\w:)?[^:]+):(\d+):(\d+)?<ret>'
eval -try-client %opt{jumpclient} edit -existing %reg{1} %reg{2} %reg{3} set buffer _grep_current_line %val{cursor_line}
try %{ focus %opt{jumpclient} } eval -try-client %opt{jumpclient} edit -existing %reg{1} %reg{2} %reg{3}
try %{ focus %opt{jumpclient} }
}
} }
} }
def grep-next -docstring 'Jump to next grep match' %{ def grep-next -docstring 'Jump to next grep match' %{
eval -try-client %opt{jumpclient} %{ eval -collapse-jumps -try-client %opt{jumpclient} %{
buffer '*grep*' buffer '*grep*'
exec "%opt{_grep_current_line}g<a-l>/^[^:]+:\d+:<ret>" exec "%opt{_grep_current_line}g<a-l>/^[^:]+:\d+:<ret>"
grep-jump grep-jump
@ -53,7 +55,7 @@ def grep-next -docstring 'Jump to next grep match' %{
} }
def grep-prev -docstring 'Jump to previous grep match' %{ def grep-prev -docstring 'Jump to previous grep match' %{
eval -try-client %opt{jumpclient} %{ eval -collapse-jumps -try-client %opt{jumpclient} %{
buffer '*grep*' buffer '*grep*'
exec "%opt{_grep_current_line}g<a-/>^[^:]+:\d+:<ret>" exec "%opt{_grep_current_line}g<a-/>^[^:]+:\d+:<ret>"
grep-jump grep-jump

View File

@ -32,22 +32,24 @@ hook global WinSetOption filetype=(?!make).* %{ rmhl make; rmhooks buffer make-h
decl str jumpclient decl str jumpclient
def make-jump -docstring 'Jump to error location' %{ def make-jump -docstring 'Jump to error location' %{
try %{ eval -collapse-jumps %{
exec gl<a-?> "Entering directory" <ret> try %{
exec s "Entering directory '([^']+)'.*\n([^:]+):(\d+):(?:(\d+):)?([^\n]+)\'" <ret>l exec gl<a-?> "Entering directory" <ret>
set buffer _make_current_error_line %val{cursor_line} exec s "Entering directory '([^']+)'.*\n([^:]+):(\d+):(?:(\d+):)?([^\n]+)\'" <ret>l
eval -try-client %opt{jumpclient} "edit -existing %reg{1}/%reg{2} %reg{3} %reg{4}; echo -color Information %{%reg{5}}" set buffer _make_current_error_line %val{cursor_line}
try %{ focus %opt{jumpclient} } eval -try-client %opt{jumpclient} "edit -existing %reg{1}/%reg{2} %reg{3} %reg{4}; echo -color Information %{%reg{5}}"
} catch %{ try %{ focus %opt{jumpclient} }
exec <a-h><a-l> s "((?:\w:)?[^:]+):(\d+):(?:(\d+):)?([^\n]+)\'" <ret>l } catch %{
set buffer _make_current_error_line %val{cursor_line} exec <a-h><a-l> s "((?:\w:)?[^:]+):(\d+):(?:(\d+):)?([^\n]+)\'" <ret>l
eval -try-client %opt{jumpclient} "edit -existing %reg{1} %reg{2} %reg{3}; echo -color Information %{%reg{4}}" set buffer _make_current_error_line %val{cursor_line}
try %{ focus %opt{jumpclient} } eval -try-client %opt{jumpclient} "edit -existing %reg{1} %reg{2} %reg{3}; echo -color Information %{%reg{4}}"
try %{ focus %opt{jumpclient} }
}
} }
} }
def make-next -docstring 'Jump to next error' %{ def make-next -docstring 'Jump to next error' %{
eval -try-client %opt{jumpclient} %{ eval -collapse-jumps -try-client %opt{jumpclient} %{
buffer '*make*' buffer '*make*'
exec "%opt{_make_current_error_line}g<a-l>/[0-9]+: (?:fatal )?error:<ret>" exec "%opt{_make_current_error_line}g<a-l>/[0-9]+: (?:fatal )?error:<ret>"
make-jump make-jump
@ -56,7 +58,7 @@ def make-next -docstring 'Jump to next error' %{
} }
def make-prev -docstring 'Jump to previous error' %{ def make-prev -docstring 'Jump to previous error' %{
eval -try-client %opt{jumpclient} %{ eval -collapse-jumps -try-client %opt{jumpclient} %{
buffer '*make*' buffer '*make*'
exec "%opt{_make_current_error_line}g<a-h><a-/>[0-9]+: (?:fatal )?error:<ret>" exec "%opt{_make_current_error_line}g<a-h><a-/>[0-9]+: (?:fatal )?error:<ret>"
make-jump make-jump