Skip to content

Commit

Permalink
Version 1.05
Browse files Browse the repository at this point in the history
- Improved compatibility with other scripts.
- Kill all cscope connections before sourcing new session.
  That allows to add additional connections in extra session script.
- Fixed extra session script file name when session name has an extension.
- Removed <ESC> mapping. Only 'q' will close session list.
  • Loading branch information
Yuri Klubakov authored and vim-scripts committed May 11, 2011
1 parent 2784417 commit 923a0a5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
4 changes: 2 additions & 2 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ On Unix sessions are saved in:
If this directory does not exist, it will be created by the :SessionSave command (requires Vim 7).

At the top of the window there is a help that shows normal mode mappings:
q, <ESC> - close session list
q - close session list
o, <CR>, <2-LeftMouse> - open session
d - delete session
e - edit session
x - edit extra session script
The name of an opened session is saved in g:LAST_SESSION variable which is saved in the viminfo file if 'viminfo' option contains '!'. It is used to open last session by :SessionOpenLast command. It can be done when Vim starts (gvim +bd -c OpenLastSession) or any time during a Vim session. You can edit an extra session script to specify additional settings and actions associated with a given session. If you change values of 'expandtab', 'tabstop' or 'shiftwidth', they will be restored to their original values when session is closed or before a new session is opened. When session is opened and 'cscope' is enabled, script calls 'cscope add' for the current directory so make sure it is set correctly for the session.
The name of an opened session is saved in g:LAST_SESSION variable which is saved in the viminfo file if 'viminfo' option contains '!'. It is used to open last session by :SessionOpenLast command. It can be done when Vim starts (gvim +bd -c SessionOpenLast) or any time during a Vim session. You can edit an extra session script to specify additional settings and actions associated with a given session. If you change values of 'expandtab', 'tabstop' or 'shiftwidth', they will be restored to their original values when session is closed or before a new session is opened. When session is opened and 'cscope' is enabled, script calls 'cscope add' for the current directory so make sure it is set correctly for the session.

:SessionOpen command takes a session name as an argument. It supports argument completion.

Expand Down
31 changes: 20 additions & 11 deletions plugin/sessionman.vim
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
" Copyright (c) Yuri Klubakov
"
" Author: Yuri Klubakov <yuri.mlists at gmail dot com>
" Version: 1.04 (2008-06-21)
" Version: 1.05 (2011-05-05)
" Requires: Vim 6
" License: GPL
"
Expand All @@ -30,15 +30,15 @@
"
" :SessionList command creates a new window with session names.
" At the top of the window there is a help that shows normal mode mappings:
" q, <ESC> - close session list
" q - close session list
" o, <CR>, <2-LeftMouse> - open session
" d - delete session
" e - edit session
" x - edit extra session script
" The name of an opened session is saved in g:LAST_SESSION variable which is
" saved in the viminfo file if 'viminfo' option contains '!'. It is used to
" open last session by :SessionOpenLast command. It can be done when Vim
" starts (gvim +bd -c OpenLastSession) or any time during a Vim session.
" starts (gvim +bd -c SessionOpenLast) or any time during a Vim session.
" You can edit an extra session script to specify additional settings and
" actions associated with a given session. If you change values of
" 'expandtab', 'tabstop' or 'shiftwidth', they will be restored to their
Expand Down Expand Up @@ -107,12 +107,21 @@ endfunction
function! s:OpenSession(name)
if a:name != '' && a:name[0] != '"'
call s:RestoreDefaults()
execute 'silent! 1,' . bufnr('$') . 'bwipeout!'
let n = bufnr('%')
execute 'silent! so ' . s:sessions_path . '/' . a:name
execute 'silent! bwipeout! ' . n
if has('cscope')
silent! cscope kill -1
endif
try
set eventignore=all
execute 'silent! 1,' . bufnr('$') . 'bwipeout!'
let n = bufnr('%')
execute 'silent! so ' . s:sessions_path . '/' . a:name
execute 'silent! bwipeout! ' . n
finally
set eventignore=
doautoall BufRead
doautoall SessionLoadPost
endtry
if has('cscope')
silent! cscope add .
endif
let g:LAST_SESSION = a:name
Expand Down Expand Up @@ -164,7 +173,8 @@ endfunction
function! s:EditSessionExtra(name)
if a:name != '' && a:name[0] != '"'
bwipeout!
execute 'silent! edit ' . s:sessions_path . '/' . a:name . 'x.vim'
let n = substitute(a:name, "\\.[^.]*$", '', '')
execute 'silent! edit ' . s:sessions_path . '/' . n . 'x.vim'
endif
endfunction

Expand All @@ -185,7 +195,6 @@ function! s:ListSessions()
setlocal nowrap
setlocal nobuflisted

nnoremap <buffer> <silent> <ESC> :bwipeout!<CR>
nnoremap <buffer> <silent> q :bwipeout!<CR>
nnoremap <buffer> <silent> o :call <SID>OpenSession(getline('.'))<CR>
nnoremap <buffer> <silent> <CR> :call <SID>OpenSession(getline('.'))<CR>
Expand All @@ -196,7 +205,7 @@ function! s:ListSessions()
syn match Comment "^\".*"
put ='\"-----------------------------------------------------'
put ='\" q, <ESC> - close session list'
put ='\" q - close session list'
put ='\" o, <CR>, <2-LeftMouse> - open session'
put ='\" d - delete session'
put ='\" e - edit session'
Expand Down Expand Up @@ -279,7 +288,7 @@ an 10.371 &File.S&essions.&Open\.\.\. :SessionList<CR>
an 10.372 &File.S&essions.Open\ &Last :SessionOpenLast<CR>
an 10.373 &File.S&essions.&Close :SessionClose<CR>
an 10.374 &File.S&essions.&Save :SessionSave<CR>
an 10.374 &File.S&essions.Save\ &As\.\.\. :SessionSaveAs<CR>
an 10.375 &File.S&essions.Save\ &As\.\.\. :SessionSaveAs<CR>

aug sessionman
au VimLeavePre * if sessionman_save_on_exit && v:this_session != '' | call s:SaveSession() | endif
Expand Down

0 comments on commit 923a0a5

Please sign in to comment.