|
|
@@ -235,27 +235,31 @@ endfunction
|
|
|
|
|
|
" Function: #session_write {{{1
|
|
|
function! startify#session_write(spath)
|
|
|
+ " if this function is called while being in the Startify buffer
|
|
|
+ " (by loading another session or running :SSave/:SLoad directly)
|
|
|
+ " switch back to the previous buffer before saving the session
|
|
|
+ if &filetype == 'startify'
|
|
|
+ let callingbuffer = bufnr('#')
|
|
|
+ if callingbuffer > 0
|
|
|
+ execute 'buffer' callingbuffer
|
|
|
+ endif
|
|
|
+ endif
|
|
|
+ " prevent saving already deleted buffers that were in the arglist
|
|
|
+ for arg in argv()
|
|
|
+ if !buflisted(arg)
|
|
|
+ execute 'silent! argdelete' fnameescape(arg)
|
|
|
+ endif
|
|
|
+ endfor
|
|
|
+
|
|
|
let ssop = &sessionoptions
|
|
|
+ set sessionoptions-=options
|
|
|
try
|
|
|
- " if this function is called while being in the Startify buffer
|
|
|
- " (by loading another session or running :SSave/:SLoad directly)
|
|
|
- " switch back to the previous buffer before saving the session
|
|
|
- if &filetype == 'startify'
|
|
|
- let callingbuffer = bufnr('#')
|
|
|
- if callingbuffer > 0
|
|
|
- execute 'buffer' callingbuffer
|
|
|
- endif
|
|
|
- endif
|
|
|
- " prevent saving already deleted buffers that were in the arglist
|
|
|
- for arg in argv()
|
|
|
- if !buflisted(arg)
|
|
|
- execute 'argdelete' fnameescape(arg)
|
|
|
- endif
|
|
|
- endfor
|
|
|
- set sessionoptions-=options
|
|
|
execute 'mksession!' a:spath
|
|
|
catch
|
|
|
- execute 'echoerr' string(v:exception)
|
|
|
+ echohl ErrorMsg
|
|
|
+ echomsg v:exception
|
|
|
+ echohl NONE
|
|
|
+ return
|
|
|
finally
|
|
|
let &sessionoptions = ssop
|
|
|
endtry
|