Skip to content

Commit

Permalink
Enable non-verbose interactive prompts (pull request #33)
Browse files Browse the repository at this point in the history
Pull request on #33 on GitHub:
#33
  • Loading branch information
xolox committed May 2, 2013
1 parent 165ece4 commit c9fa3e2
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -109,6 +109,10 @@ By default this option is set to `'prompt'`. This means that when you start Vim

By default this option is set to `'prompt'`. When you've opened a session and you quit Vim, the session plug-in will ask whether you want to save the changes to your session. Set this option to `'yes'` to always automatically save open sessions when you quit Vim. To completely disable automatic saving you can set this option to `'no'`.

### The `g:session_verbose_messages` option

The session load/save prompts are quite verbose by default because they explain how to disable the prompts. If you find the additional explanation distracting you can lower the verbosity by setting this option to 0 (false) in your [vimrc script] [vimrc].

### The `g:session_default_to_last` option

By default this option is set to false (0). When you set this option to true (1) and you start Vim, the session plug-in will open your last used session instead of the default session. Note that the session plug-in will still show you the dialog asking whether you want to restore the last used session. To get rid of the dialog you have to set `g:session_autoload` to `'yes'`.
Expand Down
11 changes: 7 additions & 4 deletions autoload/xolox/session.vim
Expand Up @@ -3,7 +3,7 @@
" Last Change: May 2, 2013
" URL: http://peterodding.com/code/vim/session/

let g:xolox#session#version = '1.6.3'
let g:xolox#session#version = '1.6.4'

call xolox#misc#compat#check('session', 2)

Expand Down Expand Up @@ -304,9 +304,12 @@ function! s:prompt(msg, var)
if value == 'yes' || (type(value) != type('') && value)
return 1
else
let format = "%s Note that you can permanently disable this dialog by adding the following line to your %s script:\n\n\t:let %s = 'no'"
let vimrc = xolox#misc#os#is_win() ? '~\_vimrc' : '~/.vimrc'
let prompt = printf(format, a:msg, vimrc, a:var)
if g:session_verbose_messages
let format = "%s Note that you can permanently disable this dialog by adding the following line to your %s script:\n\n\t:let %s = 'no'"
let prompt = printf(format, a:msg, xolox#misc#os#is_win() ? '~\_vimrc' : '~/.vimrc', a:var)
else
let prompt = a:msg
endif
return confirm(prompt, "&Yes\n&No", 1, 'Question') == 1
endif
endfunction
Expand Down
19 changes: 14 additions & 5 deletions doc/session.txt
Expand Up @@ -20,11 +20,12 @@ Contents ~
4. The |g:session_extension| option
5. The |g:session_autoload| option
6. The |g:session_autosave| option
7. The |g:session_default_to_last| option
8. The |g:session_persist_globals| option
9. The |g:session_restart_environment| option
10. The |g:session_command_aliases| option
11. The |g:loaded_session| option
7. The |g:session_verbose_messages| option
8. The |g:session_default_to_last| option
9. The |g:session_persist_globals| option
10. The |g:session_restart_environment| option
11. The |g:session_command_aliases| option
12. The |g:loaded_session| option
5. Compatibility with other plug-ins |session-compatibility-with-other-plug-ins|
6. Known issues |session-known-issues|
7. Contact |session-contact|
Expand Down Expand Up @@ -235,6 +236,14 @@ changes to your session. Set this option to 'yes' to always automatically save
open sessions when you quit Vim. To completely disable automatic saving you
can set this option to 'no'.

-------------------------------------------------------------------------------
The *g:session_verbose_messages* option

The session load/save prompts are quite verbose by default because they
explain how to disable the prompts. If you find the additional explanation
distracting you can lower the verbosity by setting this option to 0 (false) in
your |vimrc| script.

-------------------------------------------------------------------------------
The *g:session_default_to_last* option

Expand Down
7 changes: 6 additions & 1 deletion plugin/session.vim
Expand Up @@ -37,9 +37,14 @@ if !exists('g:session_autosave')
let g:session_autosave = 'prompt'
endif

" Define the verbosity of messages.
if !exists('g:session_verbose_messages')
let g:session_verbose_messages = 1
endif

" The session plug-in can automatically open sessions in three ways: based on
" Vim's server name, by remembering the last used session or by opening the
" session named `default'. Enable this option to use the second approach.
" default session. Enable this option to use the second approach.
if !exists('g:session_default_to_last')
let g:session_default_to_last = 0
endif
Expand Down

0 comments on commit c9fa3e2

Please sign in to comment.