Make :Glog and :Ggrep global

This commit is contained in:
Tim Pope
2019-09-04 00:50:31 -04:00
parent 804957a3e6
commit 68da9a2be3
2 changed files with 13 additions and 11 deletions

View File

@@ -3659,11 +3659,11 @@ if !exists('g:fugitive_summary_format')
let g:fugitive_summary_format = '%s'
endif
function! s:GrepComplete(A, L, P) abort
function! fugitive#GrepComplete(A, L, P) abort
return s:CompleteSub('grep', a:A, a:L, a:P)
endfunction
function! s:LogComplete(A, L, P) abort
function! fugitive#LogComplete(A, L, P) abort
return s:CompleteSub('log', a:A, a:L, a:P)
endfunction
@@ -3806,7 +3806,7 @@ function! s:LogParse(state, dir, line) abort
return []
endfunction
function! s:Log(type, bang, line1, count, args, legacy) abort
function! fugitive#LogCommand(line1, count, range, bang, mods, args, type) abort
let dir = s:Dir()
exe s:DirCheck(dir)
let listnr = a:type =~# '^l' ? 0 : -1
@@ -3877,19 +3877,12 @@ function! s:Log(type, bang, line1, count, args, legacy) abort
\ args + paths + extra)
let state.target = path
let title = (listnr < 0 ? ':Gclog ' : ':Gllog ') . s:fnameescape(args + paths)
if empty(paths + extra) && a:legacy && len(s:Relative('/'))
if empty(paths + extra) && empty(a:type) && len(s:Relative('/'))
let after = '|echohl WarningMsg|echo ' . string('Use :0Glog or :0Gclog for old behavior of targeting current file') . '|echohl NONE' . after
endif
return s:QuickfixStream(listnr, title, s:UserCommandList(dir) + cmd, !a:bang, s:function('s:LogParse'), state, dir) . after
endfunction
call s:command("-bang -nargs=? -range=-1 -addr=windows -complete=customlist,s:GrepComplete Ggrep", "grep")
call s:command("-bang -nargs=? -complete=customlist,s:GrepComplete Gcgrep :execute s:GrepSubcommand(-1, -1, 0, <bang>0, '<mods>', <q-args>)")
call s:command("-bang -nargs=? -complete=customlist,s:GrepComplete Glgrep :execute s:GrepSubcommand(0, 0, 0, <bang>0, '<mods>', <q-args>)")
call s:command("-bang -nargs=? -range=-1 -addr=other -complete=customlist,s:LogComplete Glog :exe s:Log('c',<bang>0,<line1>,<count>,<q-args>, 1)")
call s:command("-bang -nargs=? -range=-1 -addr=other -complete=customlist,s:LogComplete Gclog :exe s:Log('c',<bang>0,<line1>,<count>,<q-args>, 0)")
call s:command("-bang -nargs=? -range=-1 -addr=other -complete=customlist,s:LogComplete Gllog :exe s:Log('l',<bang>0,<line1>,<count>,<q-args>, 0)")
" Section: :Gedit, :Gpedit, :Gsplit, :Gvsplit, :Gtabedit, :Gread
function! s:UsableWin(nr) abort