From 88fe6c52473022678e265ef81f5b68d2f5f624ac Mon Sep 17 00:00:00 2001 From: albfan Date: Wed, 9 Sep 2015 01:49:16 +0200 Subject: [PATCH] delete results resolves #9 --- autoload/ag.vim | 27 +++++++++++++++++++++------ doc/ag.txt | 1 + 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/autoload/ag.vim b/autoload/ag.vim index c7b19dd9..d5e2d653 100644 --- a/autoload/ag.vim +++ b/autoload/ag.vim @@ -191,12 +191,27 @@ function! ag#AgGroup(ncontext, visualmode, fileregexp, args) setlocal foldcolumn=2 1 setlocal nomodifiable - map o zaj - map :call NextFold() - map O :call ToggleEntireFold() - map :call OpenFile(0) - map s :call OpenFile(1) - map S :call OpenFile(2) + noremap o zaj + noremap :call NextFold() + noremap O :call ToggleEntireFold() + noremap :call OpenFile(0) + noremap s :call OpenFile(1) + noremap S :call OpenFile(2) + noremap d :call DeleteFold() +endfunction + +function DeleteFold() + if foldlevel(".") == 0 + return + endif + setlocal modifiable + if foldclosed(".") != -1 + normal zo + endif + "normal stops if command fails. On cursor at beginning of fold motion fails + normal! [z + normal! kVj]zD + setlocal nomodifiable endfunction " Find next fold or go back to first one diff --git a/doc/ag.txt b/doc/ag.txt index 422196d1..8ae06662 100644 --- a/doc/ag.txt +++ b/doc/ag.txt @@ -31,6 +31,7 @@ the results in a split window. Open next fold search (cyclic) s Goto selected file:line:col splitting horizontal above S Goto selected file:line:col splitting vertical above + d Delete result :AgBuffer[!] [options] {pattern} *:AgBuffer*