Implement :Gwq

This commit is contained in:
Tim Pope
2011-02-27 13:58:05 -05:00
parent 3933bfdc57
commit 2e4c9236d6
2 changed files with 22 additions and 0 deletions

View File

@@ -903,6 +903,8 @@ call s:command("-bar -bang -nargs=? -count -complete=customlist,s:EditComplete G
" Gwrite, Gwq {{{1
call s:command("-bar -bang -nargs=? -complete=customlist,s:EditComplete Gwrite :execute s:Write(<bang>0,<f-args>)")
call s:command("-bar -bang -nargs=? -complete=customlist,s:EditComplete Gw :execute s:Write(<bang>0,<f-args>)")
call s:command("-bar -bang -nargs=? -complete=customlist,s:EditComplete Gwq :execute s:Wq(<bang>0,<f-args>)")
function! s:Write(force,...) abort
if exists('b:fugitive_commit_arguments')
@@ -1022,6 +1024,19 @@ function! s:Write(force,...) abort
return 'checktime'
endfunction
function! s:Wq(force,...) abort
let bang = a:force ? '!' : ''
if exists('b:fugitive_commit_arguments')
return 'wq'.bang
endif
let result = call(s:function('s:Write'),[a:force]+a:000)
if result =~# '^\%(write\|wq\|echoerr\)'
return s:sub(result,'^write','wq')
else
return result.'|quit'.bang
endif
endfunction
" }}}1
" Gdiff {{{1