Browse Source

add :SDelete

Marco Hinz 12 years ago
parent
commit
d671a0957c
4 changed files with 27 additions and 2 deletions
  1. 1 0
      README.md
  2. 21 0
      autoload/startify.vim
  3. 2 0
      doc/startify.txt
  4. 3 2
      plugin/startify.vim

+ 1 - 0
README.md

@@ -27,6 +27,7 @@ _2)_ It eases handling of loading and saving sessions by only working with a
 
       :SLoad    load a session
       :SSave    save a session
+      :SDelete  delete a session
 
 _NOTE_: Both commands can also take session names directly as an argument. You can
 also make use of completion via `<c-u>` and `<tab>`.

+ 21 - 0
autoload/startify.vim

@@ -32,6 +32,27 @@ function! startify#is_in_skiplist(arg) abort
   endfor
 endfunction
 
+function! startify#delete_session(...) abort
+  if !isdirectory(g:startify_session_dir)
+    echo 'The session directory does not exist: '. g:startify_session_dir
+    return
+  endif
+  let spath = g:startify_session_dir . startify#get_separator() . (exists('a:1')
+        \ ? a:1
+        \ : input('Delete this session: ', '', 'custom,startify#get_session_names_as_string'))
+        \ | redraw
+  echo 'Really delete '. spath .'? [y/n]' | redraw
+  if (nr2char(getchar()) == 'y')
+    if delete(spath) == 0
+      echo 'Deleted session '. spath .'!'
+    else
+      echo 'Deletion failed!'
+    endif
+  else
+    echo 'Deletion aborted!'
+  endif
+endfunction
+
 function! startify#save_session(...) abort
   if !isdirectory(g:startify_session_dir)
     if exists('*mkdir')

+ 2 - 0
doc/startify.txt

@@ -62,6 +62,7 @@ Startify basically provides two things:
 
       :SLoad    load a session
       :SSave    save a session
+      :SDelete  delete a session
 
 The default settings are pretty sane, so it should work without any
 configuration.
@@ -189,6 +190,7 @@ Don't show <empty buffer> and <quit>.
 
     :SLoad    load a session
     :SSave    save a session
+    :SDelete  delete a session
 
 These take either 0 or 1 argument. If you don't specify the session name as an
 argument, they will just ask for it.

+ 3 - 2
plugin/startify.vim

@@ -29,8 +29,9 @@ augroup startify
         \ endif
 augroup END
 
-command! -nargs=? -bar -complete=customlist,startify#get_session_names SSave call startify#save_session(<f-args>)
-command! -nargs=? -bar -complete=customlist,startify#get_session_names SLoad call startify#load_session(<f-args>)
+command! -nargs=? -bar -complete=customlist,startify#get_session_names SSave   call startify#save_session(<f-args>)
+command! -nargs=? -bar -complete=customlist,startify#get_session_names SLoad   call startify#load_session(<f-args>)
+command! -nargs=? -bar -complete=customlist,startify#get_session_names SDelete call startify#delete_session(<f-args>)
 command! -nargs=0 -bar Startify enew | call s:insane_in_the_membrane()
 
 " Function: s:insane_in_the_membrane {{{1