Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port AgBuffer to AckBuffer #272

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions autoload/ack.vim
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@ function! ack#AckHelp(cmd, args) "{{{
call ack#Ack(a:cmd, args)
endfunction "}}}

function! ack#AckBuffer(cmd, args) "{{{
let l:bufs = filter(range(1, bufnr('$')), 'buflisted(v:val)')
let l:files = []
for buf in l:bufs
let l:file = shellescape(fnamemodify(bufname(buf), ':p'))
if !isdirectory(l:file)
call add(l:files, l:file)
endif
endfor
call ack#Ack(a:cmd, a:args . ' ' . join(l:files, ' '))
endfunction "}}}

function! ack#AckWindow(cmd, args) "{{{
let files = tabpagebuflist()

Expand Down
11 changes: 11 additions & 0 deletions doc/ack.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ shows the results in a split window.
will open the |Quickfix| window for you. If [!] is not given the first
occurrence is jumped to.

:AckBuffer[!] [options] {pattern} *:AckBuffer*

Search for {pattern} in all open buffers. Behaves just like the |:grep|
command, but will open the |QuickFix| window for you. If [!] is not given
the first error is jumped to.

:AckAdd [options] {pattern} [{directory}] *:AckAdd*

Just like |:Ack|, but instead of making a new list, the matches are
Expand All @@ -36,6 +42,11 @@ shows the results in a split window.
Just like |:Ack| but instead of the |quickfix| list, matches are placed in
the current |location-list|.

:LAckBuffer [options] {pattern} [{directory}] *:LAckBuffer*

Just like |:AckBuffer| but instead of the |quickfix| list, matches are
added to the current |location-list|

:LAckAdd [options] {pattern} [{directory}] *:LAckAdd*

Just like |:AckAdd| but instead of the |quickfix| list, matches are added
Expand Down
2 changes: 2 additions & 0 deletions plugin/ack.vim
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ if !exists("g:ack_use_cword_for_empty_search")
endif

command! -bang -nargs=* -complete=file Ack call ack#Ack('grep<bang>', <q-args>)
command! -bang -nargs=* -complete=file AckBuffer call ack#AckBuffer('grep<bang>', <q-args>)
command! -bang -nargs=* -complete=file AckAdd call ack#Ack('grepadd<bang>', <q-args>)
command! -bang -nargs=* -complete=file AckFromSearch call ack#AckFromSearch('grep<bang>', <q-args>)
command! -bang -nargs=* -complete=file LAck call ack#Ack('lgrep<bang>', <q-args>)
command! -bang -nargs=* -complete=file LAckBuffer call ack#AckBuffer('lgrep<bang>', <q-args>)
command! -bang -nargs=* -complete=file LAckAdd call ack#Ack('lgrepadd<bang>', <q-args>)
command! -bang -nargs=* -complete=file AckFile call ack#Ack('grep<bang> -g', <q-args>)
command! -bang -nargs=* -complete=help AckHelp call ack#AckHelp('grep<bang>', <q-args>)
Expand Down