diff --git a/README.md b/README.md index 47649fb..0cebdac 100644 --- a/README.md +++ b/README.md @@ -131,6 +131,10 @@ This option controls the location of your session scripts. Its default value is The name of the default session without directory or filename extension (you'll never guess what the default is). +### The `g:session_default_overwrite` option + +If you set this to true (1), every Vim instance without an explicit session loaded will overwrite the default session (the last Vim instance wins). + ### The `g:session_extension` option The filename extension of session scripts. This should include the dot that separates the basename from the extension. Defaults to '.vim'. @@ -236,7 +240,7 @@ Recently this plug-in switched from reimplementing [:mksession][mksession] to ac The documentation of the 34 functions below was extracted from -1 Vim scripts on July 4, 2013 at 00:27. +1 Vim scripts on July 4, 2013 at 01:25. ### Public API for the vim-notes plug-in diff --git a/autoload/xolox/session.vim b/autoload/xolox/session.vim index d96c465..f34e8f6 100644 --- a/autoload/xolox/session.vim +++ b/autoload/xolox/session.vim @@ -4,7 +4,7 @@ " Last Change: July 4, 2013 " URL: http://peterodding.com/code/vim/session/ -let g:xolox#session#version = '2.4.5' +let g:xolox#session#version = '2.4.6' " Public API for session persistence. {{{1 @@ -430,18 +430,23 @@ function! xolox#session#auto_save() " {{{2 let name = xolox#session#find_current_session() " If no session is active and the user doesn't have any sessions yet, help " them get started by suggesting to create the default session. - if empty(name) && empty(xolox#session#get_names()) + if empty(name) && (empty(xolox#session#get_names()) || g:session_default_overwrite) let name = g:session_default_name endif - " Prompt the user to save the active or first session? + " Prompt the user to save the active/first/default session? if !empty(name) let is_tab_scoped = xolox#session#is_tab_scoped() let msg = "Do you want to save your %s before quitting Vim?" if s:prompt(printf(msg, xolox#session#get_label(name, is_tab_scoped)), ['&Yes', '&No'], 'g:session_autosave') == 1 + if g:session_default_overwrite && (name == g:session_default_overwrite) + let bang = '!' + else + let bang = '' + endif if is_tab_scoped - call xolox#session#save_tab_cmd(name, '', 'SaveTabSession') + call xolox#session#save_tab_cmd(name, bang, 'SaveTabSession') else - call xolox#session#save_cmd(name, '', 'SaveSession') + call xolox#session#save_cmd(name, bang, 'SaveSession') endif endif endif diff --git a/doc/session.txt b/doc/session.txt index 0a089c3..66000c4 100644 --- a/doc/session.txt +++ b/doc/session.txt @@ -21,16 +21,17 @@ Contents ~ 1. The |sessionoptions| setting 2. The |g:session_directory| option 3. The |g:session_default_name| option - 4. The |g:session_extension| option - 5. The |g:session_autoload| option - 6. The |g:session_autosave| option - 7. The |g:session_autosave_periodic| option - 8. The |g:session_verbose_messages| option - 9. The |g:session_default_to_last| option - 10. The |g:session_persist_globals| option - 11. The |g:session_restart_environment| option - 12. The |g:session_command_aliases| option - 13. The |g:loaded_session| option + 4. The |g:session_default_overwrite| option + 5. The |g:session_extension| option + 6. The |g:session_autoload| option + 7. The |g:session_autosave| option + 8. The |g:session_autosave_periodic| option + 9. The |g:session_verbose_messages| option + 10. The |g:session_default_to_last| option + 11. The |g:session_persist_globals| option + 12. The |g:session_restart_environment| option + 13. The |g:session_command_aliases| option + 14. The |g:loaded_session| option 5. Compatibility with other plug-ins |session-compatibility-with-other-plug-ins| 6. Known issues |session-known-issues| 7. Function reference |session-function-reference| @@ -304,6 +305,12 @@ The *g:session_default_name* option The name of the default session without directory or filename extension (you'll never guess what the default is). +------------------------------------------------------------------------------- +The *g:session_default_overwrite* option + +If you set this to true (1), every Vim instance without an explicit session +loaded will overwrite the default session (the last Vim instance wins). + ------------------------------------------------------------------------------- The *g:session_extension* option @@ -477,7 +484,7 @@ might take a while...) Function reference ~ The documentation of the 34 functions below was extracted from 1 Vim scripts on -July 4, 2013 at 00:27. +July 4, 2013 at 01:25. ------------------------------------------------------------------------------- *session-public-api-for-vim-notes-plug-in* diff --git a/plugin/session.vim b/plugin/session.vim index 3a37cc7..4bd3f8c 100644 --- a/plugin/session.vim +++ b/plugin/session.vim @@ -32,6 +32,12 @@ if !exists('g:session_default_name') let g:session_default_name = 'default' endif +" If you set this to 1 (true), every Vim instance without an explicit session +" loaded will overwrite the default session (the last Vim instance wins). +if !exists('g:session_default_overwrite') + let g:session_default_overwrite = 0 +endif + " The file extension of session scripts. if !exists('g:session_extension') let g:session_extension = '.vim'