From 7994cae37828c0c1cf16e795b5d181e46d585797 Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Tue, 2 Feb 2016 14:54:58 +0100 Subject: [PATCH] Add :SDelete! --- autoload/startify.vim | 14 ++++++++++---- doc/startify.txt | 10 ++++++---- plugin/startify.vim | 2 +- test/feature/session.vader | 4 ++-- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/autoload/startify.vim b/autoload/startify.vim index 2ea7eef..9cd8c99 100644 --- a/autoload/startify.vim +++ b/autoload/startify.vim @@ -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 diff --git a/doc/startify.txt b/doc/startify.txt index f832257..c6799e0 100644 --- a/doc/startify.txt +++ b/doc/startify.txt @@ -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* diff --git a/plugin/startify.vim b/plugin/startify.vim index c834166..a331f81 100644 --- a/plugin/startify.vim +++ b/plugin/startify.vim @@ -55,7 +55,7 @@ endfunction command! -nargs=? -bar -complete=customlist,startify#session_list SSave call startify#session_save() command! -nargs=? -bar -complete=customlist,startify#session_list SLoad call startify#session_load() -command! -nargs=? -bar -complete=customlist,startify#session_list SDelete call startify#session_delete() +command! -nargs=? -bar -bang -complete=customlist,startify#session_list SDelete call startify#session_delete(0, ) 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() diff --git a/test/feature/session.vader b/test/feature/session.vader index 16f2aa8..674e9c6 100644 --- a/test/feature/session.vader +++ b/test/feature/session.vader @@ -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')