Add :SDelete!

This commit is contained in:
Marco Hinz 2016-02-02 14:54:58 +01:00
parent ec24c42b5c
commit 7994cae378
4 changed files with 19 additions and 11 deletions

View file

@ -309,7 +309,7 @@ function! startify#session_write(spath)
endfunction
" Function: #session_delete {{{1
function! startify#session_delete(...) abort
function! startify#session_delete(bang, ...) abort
if !isdirectory(s:session_dir)
echo 'The session directory does not exist: '. s:session_dir
return
@ -326,7 +326,7 @@ function! startify#session_delete(...) abort
call inputrestore()
echo 'Really delete '. spath .'? [y/n]' | redraw
if (nr2char(getchar()) == 'y')
if a:bang || nr2char(getchar()) == 'y'
if delete(spath) == 0
echo 'Deleted session '. spath .'!'
else
@ -338,14 +338,20 @@ function! startify#session_delete(...) abort
endfunction
" Function: #session_delete_buffers {{{1
function! startify#session_delete_buffers() abort
function! startify#session_delete_buffers()
if !s:delete_buffers
return
endif
let n = 1
while n <= bufnr('$')
if buflisted(n)
silent execute 'bdelete' n
try
silent execute 'bdelete' n
catch
echohl ErrorMsg
echomsg v:exception
echohl NONE
endtry
endif
let n += 1
endwhile

View file

@ -76,10 +76,12 @@ Startify basically provides two things:
2) It eases handling of loading and saving sessions by only working with a
certain directory. These commands are used for convenience:
:SLoad load a session
:SSave save a session
:SDelete delete a session
:SClose close a session
:SLoad load a session
:SSave save a session
:SDelete[!] delete a session
:SClose close a session
If ! is given, you won't get prompted.
==============================================================================
OPTIONS *startify-options*

View file

@ -55,7 +55,7 @@ endfunction
command! -nargs=? -bar -complete=customlist,startify#session_list SSave call startify#session_save(<f-args>)
command! -nargs=? -bar -complete=customlist,startify#session_list SLoad call startify#session_load(<f-args>)
command! -nargs=? -bar -complete=customlist,startify#session_list SDelete call startify#session_delete(<f-args>)
command! -nargs=? -bar -bang -complete=customlist,startify#session_list SDelete call startify#session_delete(<bang>0, <f-args>)
command! -nargs=0 -bar SClose call startify#session_close()
command! -nargs=0 -bar Startify enew | call startify#insane_in_the_membrane()
command! -nargs=0 -bar StartifyDebug call startify#debug()

View file

@ -12,7 +12,7 @@ Expect:
This is just a simple test file.
Foo, bar, quux.
Execute (Session: :SDelete foo):
Execute (Session: :SDelete! foo):
Assert 1 == filereadable(g:startify_session_dir.'/foo')
SDelete foo
SDelete! foo
Assert 0 == filereadable(g:startify_session_dir.'/foo')