Skip to content

Commit

Permalink
Move version variable to autoload script
Browse files Browse the repository at this point in the history
  • Loading branch information
xolox committed Aug 31, 2011
1 parent e374c77 commit 93d504a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -125,7 +125,7 @@ If you have questions, bug reports, suggestions, etc. the author can be contacte
## License

This software is licensed under the [MIT license](http://en.wikipedia.org/wiki/MIT_License).
© 2010 Peter Odding &lt;<peter@peterodding.com>&gt;.
© 2011 Peter Odding &lt;<peter@peterodding.com>&gt;.

## Sample session script

Expand Down
38 changes: 20 additions & 18 deletions autoload/xolox/session.vim
@@ -1,8 +1,10 @@
" Vim script
" Author: Peter Odding
" Last Change: June 18, 2011
" Last Change: August 31, 2011
" URL: http://peterodding.com/code/vim/session/

let g:xolox#session#version = '1.4.10'

" Public API for session persistence. {{{1

" The functions in this fold take a single list argument in which the Vim
Expand All @@ -13,7 +15,7 @@

function! xolox#session#save_session(commands, filename) " {{{2
call add(a:commands, '" ' . a:filename . ': Vim session script.')
call add(a:commands, '" Created by session.vim ' . g:session_version . ' on ' . strftime('%d %B %Y at %H:%M:%S.'))
call add(a:commands, '" Created by session.vim ' . g:xolox#session#version . ' on ' . strftime('%d %B %Y at %H:%M:%S.'))
call add(a:commands, '" Open this file in Vim and run :source % to restore your session.')
call add(a:commands, '')
call add(a:commands, 'set guioptions=' . escape(&go, ' "\'))
Expand Down Expand Up @@ -294,7 +296,7 @@ function! xolox#session#open_cmd(name, bang) abort " {{{2
let path = xolox#session#name_to_path(name)
if !filereadable(path)
let msg = "session.vim %s: The %s session at %s doesn't exist!"
call xolox#misc#msg#warn(msg, g:session_version, string(name), fnamemodify(path, ':~'))
call xolox#misc#msg#warn(msg, g:xolox#session#version, string(name), fnamemodify(path, ':~'))
elseif a:bang == '!' || !s:session_is_locked(path, 'OpenSession')
let oldcwd = s:nerdtree_persist()
call xolox#session#close_cmd(a:bang, 1)
Expand All @@ -303,8 +305,8 @@ function! xolox#session#open_cmd(name, bang) abort " {{{2
execute 'source' fnameescape(path)
unlet! s:session_is_dirty
call s:last_session_persist(name)
call xolox#misc#timer#stop("session.vim %s: Opened %s session in %s.", g:session_version, string(name), starttime)
call xolox#misc#msg#info("session.vim %s: Opened %s session from %s.", g:session_version, string(name), fnamemodify(path, ':~'))
call xolox#misc#timer#stop("session.vim %s: Opened %s session in %s.", g:xolox#session#version, string(name), starttime)
call xolox#misc#msg#info("session.vim %s: Opened %s session from %s.", g:xolox#session#version, string(name), fnamemodify(path, ':~'))
endif
endif
endfunction
Expand All @@ -315,10 +317,10 @@ function! xolox#session#view_cmd(name) abort " {{{2
let path = xolox#session#name_to_path(name)
if !filereadable(path)
let msg = "session.vim %s: The %s session at %s doesn't exist!"
call xolox#misc#msg#warn(msg, g:session_version, string(name), fnamemodify(path, ':~'))
call xolox#misc#msg#warn(msg, g:xolox#session#version, string(name), fnamemodify(path, ':~'))
else
execute 'tab drop' fnameescape(path)
call xolox#misc#msg#info("session.vim %s: Viewing session script %s.", g:session_version, fnamemodify(path, ':~'))
call xolox#misc#msg#info("session.vim %s: Viewing session script %s.", g:xolox#session#version, fnamemodify(path, ':~'))
endif
endif
endfunction
Expand All @@ -336,11 +338,11 @@ function! xolox#session#save_cmd(name, bang) abort " {{{2
endif
if writefile(lines, path) != 0
let msg = "session.vim %s: Failed to save %s session to %s!"
call xolox#misc#msg#warn(msg, g:session_version, string(name), friendly_path)
call xolox#misc#msg#warn(msg, g:xolox#session#version, string(name), friendly_path)
else
call s:last_session_persist(name)
call xolox#misc#timer#stop("session.vim %s: Saved %s session in %s.", g:session_version, string(name), starttime)
call xolox#misc#msg#info("session.vim %s: Saved %s session to %s.", g:session_version, string(name), friendly_path)
call xolox#misc#timer#stop("session.vim %s: Saved %s session in %s.", g:xolox#session#version, string(name), starttime)
call xolox#misc#msg#info("session.vim %s: Saved %s session to %s.", g:xolox#session#version, string(name), friendly_path)
let v:this_session = path
call s:lock_session(path)
unlet! s:session_is_dirty
Expand All @@ -354,15 +356,15 @@ function! xolox#session#delete_cmd(name, bang) " {{{2
let path = xolox#session#name_to_path(name)
if !filereadable(path)
let msg = "session.vim %s: The %s session at %s doesn't exist!"
call xolox#misc#msg#warn(msg, g:session_version, string(name), fnamemodify(path, ':~'))
call xolox#misc#msg#warn(msg, g:xolox#session#version, string(name), fnamemodify(path, ':~'))
elseif a:bang == '!' || !s:session_is_locked(path, 'DeleteSession')
if delete(path) != 0
let msg = "session.vim %s: Failed to delete %s session at %s!"
call xolox#misc#msg#warn(msg, g:session_version, string(name), fnamemodify(path, ':~'))
call xolox#misc#msg#warn(msg, g:xolox#session#version, string(name), fnamemodify(path, ':~'))
else
call s:unlock_session(path)
let msg = "session.vim %s: Deleted %s session at %s."
call xolox#misc#msg#info(msg, g:session_version, string(name), fnamemodify(path, ':~'))
call xolox#misc#msg#info(msg, g:xolox#session#version, string(name), fnamemodify(path, ':~'))
endif
endif
endif
Expand Down Expand Up @@ -403,12 +405,12 @@ function! xolox#session#close_cmd(bang, silent) abort " {{{2
if v:this_session == ''
if !a:silent
let msg = "session.vim %s: Closed session."
call xolox#misc#msg#info(msg, g:session_version)
call xolox#misc#msg#info(msg, g:xolox#session#version)
endif
else
if !a:silent
let msg = "session.vim %s: Closed session %s."
call xolox#misc#msg#info(msg, g:session_version, fnamemodify(v:this_session, ':~'))
call xolox#misc#msg#info(msg, g:xolox#session#version, fnamemodify(v:this_session, ':~'))
endif
let v:this_session = ''
endif
Expand All @@ -418,7 +420,7 @@ endfunction
function! xolox#session#restart_cmd(bang, args) abort " {{{2
if !has('gui_running')
let msg = "session.vim %s: The :RestartVim command only works in graphical Vim!"
call xolox#misc#msg#warn(msg, g:session_version)
call xolox#misc#msg#warn(msg, g:xolox#session#version)
else
let name = s:get_name('', 0)
if name == '' | let name = 'restart' | endif
Expand Down Expand Up @@ -511,7 +513,7 @@ endfunction
function! s:last_session_persist(name)
if g:session_default_to_last
if writefile([a:name], s:last_session_file()) != 0
call xolox#misc#msg#warn("session.vim %s: Failed to persist name of last used session!", g:session_version)
call xolox#misc#msg#warn("session.vim %s: Failed to persist name of last used session!", g:xolox#session#version)
endif
endif
endfunction
Expand Down Expand Up @@ -561,7 +563,7 @@ function! s:session_is_locked(session_path, ...)
if a:0 >= 1
let msg = "session.vim %s: The %s session is locked by another Vim instance named %s! Use :%s! to override."
let name = string(fnamemodify(a:session_path, ':t:r'))
call xolox#misc#msg#warn(msg, g:session_version, name, string(lines[0]), a:1)
call xolox#misc#msg#warn(msg, g:xolox#session#version, name, string(lines[0]), a:1)
endif
return 1
endif
Expand Down
2 changes: 1 addition & 1 deletion doc/session.txt
Expand Up @@ -241,7 +241,7 @@ If you like the script please vote for it on Vim Online [10].
*session-license*
License ~

This software is licensed under the MIT license [11]. Copyright 2010 Peter
This software is licensed under the MIT license [11]. Copyright 2011 Peter
Odding <peter@peterodding.com>.

===============================================================================
Expand Down
6 changes: 2 additions & 4 deletions plugin/session.vim
@@ -1,6 +1,6 @@
" Vim script
" Author: Peter Odding
" Last Change: June 18, 2011
" Last Change: August 31, 2011
" URL: http://peterodding.com/code/vim/session/

" Support for automatic update using the GLVS plug-in.
Expand All @@ -11,8 +11,6 @@ if &cp || exists('g:loaded_session')
finish
endif

let g:session_version = '1.4.9'

" When you start Vim without opening any files the plug-in will prompt you
" whether you want to load the default session. Other supported values for
" this option are 'yes' (to load the default session without prompting) and
Expand Down Expand Up @@ -52,7 +50,7 @@ if !isdirectory(s:directory)
endif
if filewritable(s:directory) != 2
let s:msg = "session.vim %s: The sessions directory %s isn't writable!"
call xolox#misc#msg#warn(s:msg, g:session_version, string(s:directory))
call xolox#misc#msg#warn(s:msg, g:xolox#session#version, string(s:directory))
unlet s:msg
finish
endif
Expand Down

0 comments on commit 93d504a

Please sign in to comment.