Skip to content

Commit 6a4af75

Browse files
committed
Option to set default session name (issue #22)
Issue #22 on GitHub: #22
1 parent d0a3940 commit 6a4af75

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

autoload/xolox/session.vim

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
" Last Change: May 2, 2013
44
" URL: http://peterodding.com/code/vim/session/
55

6-
let g:xolox#session#version = '1.6'
6+
let g:xolox#session#version = '1.6.1'
77

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

@@ -260,12 +260,12 @@ function! xolox#session#auto_load() " {{{2
260260
endif
261261
endfor
262262
endif
263-
" Default to the last used session or the session named `default'?
263+
" Default to the last used session or the default session?
264264
let session = s:last_session_recall()
265265
let path = xolox#session#name_to_path(session)
266266
if filereadable(path) && !s:session_is_locked(path)
267267
let msg = "Do you want to restore your %s editing session?"
268-
let label = session != 'default' ? 'last used' : 'default'
268+
let label = session != g:session_default_name ? 'last used' : 'default'
269269
if s:prompt(printf(msg, label), 'g:session_autoload')
270270
call xolox#session#open_cmd(session, '')
271271
endif
@@ -495,7 +495,7 @@ function! s:select_name(name, action) " {{{2
495495
endif
496496
let sessions = sort(xolox#session#get_names())
497497
if empty(sessions)
498-
return 'default'
498+
return g:session_default_name
499499
elseif len(sessions) == 1
500500
return sessions[0]
501501
endif
@@ -519,7 +519,7 @@ function! s:get_name(name, use_default) " {{{2
519519
let name = xolox#session#path_to_name(v:this_session)
520520
endif
521521
endif
522-
return name != '' ? name : a:use_default ? 'default' : ''
522+
return name != '' ? name : a:use_default ? g:session_default_name : ''
523523
endfunction
524524

525525
function! xolox#session#name_to_path(name) " {{{2
@@ -565,7 +565,7 @@ function! s:last_session_recall()
565565
return readfile(fname)[0]
566566
endif
567567
endif
568-
return 'default'
568+
return g:session_default_name
569569
endfunction
570570

571571
" Lock file management: {{{2

plugin/session.vim

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
" Vim script
22
" Author: Peter Odding
3-
" Last Change: April 20, 2013
3+
" Last Change: May 2, 2013
44
" URL: http://peterodding.com/code/vim/session/
55

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

14+
" The name of the default session (without directory or filename extension).
15+
if !exists('g:session_default_name')
16+
let g:session_default_name = 'default'
17+
endif
18+
1419
" When you start Vim without opening any files the plug-in will prompt you
1520
" whether you want to load the default session. Other supported values for
1621
" this option are 'yes' (to load the default session without prompting) and

0 commit comments

Comments
 (0)