Browse Source

session_write(): error msg instead of exception

References #174.
Marco Hinz 10 years ago
parent
commit
7f76635fce
1 changed files with 21 additions and 17 deletions
  1. 21 17
      autoload/startify.vim

+ 21 - 17
autoload/startify.vim

@@ -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