Skip to content

Commit 46d6c02

Browse files
committed
auto_save_to option added
1 parent a55318b commit 46d6c02

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

autoload/xolox/session.vim

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -442,12 +442,17 @@ function! xolox#session#auto_save() " {{{2
442442
" We won't save the session if auto-save is explicitly disabled.
443443
return
444444
endif
445-
" Get the name of the active session (if any).
446-
let name = xolox#session#find_current_session()
447-
" If no session is active and the user doesn't have any sessions yet, help
448-
" them get started by suggesting to create the default session.
449-
if empty(name) && (empty(xolox#session#get_names()) || g:session_default_overwrite)
450-
let name = g:session_default_name
445+
if empty(g:session_autosave_to)
446+
" Get the name of the active session (if any).
447+
let name = xolox#session#find_current_session()
448+
" If no session is active and the user doesn't have any sessions yet, help
449+
" them get started by suggesting to create the default session.
450+
if empty(name) && (empty(xolox#session#get_names()) || g:session_default_overwrite)
451+
let name = g:session_default_name
452+
endif
453+
" Prompt the user to save the active/first/default session?
454+
else
455+
let name = g:session_autosave_to
451456
endif
452457
" Prompt the user to save the active/first/default session?
453458
if !empty(name)

doc/session.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Contents ~
2525
5. The |g:session_extension| option
2626
6. The |g:session_autoload| option
2727
7. The |g:session_autosave| option
28+
7. The |g:session_autosave_to| option
2829
8. The |g:session_autosave_periodic| option
2930
9. The |g:session_verbose_messages| option
3031
10. The |g:session_default_to_last| option
@@ -337,6 +338,16 @@ to your session. Set this option to "'yes'" to always automatically save open
337338
sessions when you quit Vim. To completely disable automatic saving you can set
338339
this option to "'no'".
339340

341+
-------------------------------------------------------------------------------
342+
The *g:session_autosave_to* option
343+
344+
If |g:session_autosave| equals "'yes'" and this option is different from "''",
345+
autosave always autosaves to a session with name |g:session_autosave_to| regardless
346+
of what the current session is or any other options. In particular,
347+
|g:session_default_overwrite| does not have any effect. If "''", autosave saves to
348+
the session name that would be used if this option did not exist. The default
349+
value is "''".
350+
340351
-------------------------------------------------------------------------------
341352
The *g:session_autosave_periodic* option
342353

0 commit comments

Comments
 (0)