Skip to content

Commit b6b6d7f

Browse files
committed
Invoke autoload functions instead of custom commands
Pull request #31: #31 Ingo's explanation (which I completely agree with): Some people using the :Session... alternatives may :delcommand the original commands; in that case, the invocations by the script would fail. Prevent this error by invoking the autoload functions directly; this also obsoletes the need for fnameescape().
1 parent d405393 commit b6b6d7f

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ When this option is enabled the session plug-in will define the following comman
148148

149149
The aliases support tab completion just like the real commands; they're exactly the same except for the names.
150150

151+
When you enable the aliases, the default command names will still be available. If you really don't like them, feel free to delete them using [:delcommand] [delcommand].
152+
151153
### The `g:loaded_session` option
152154

153155
This variable isn't really an option but if you want to avoid loading the `session.vim` plug-in you can set this variable to any value in your [vimrc script] [vimrc]:
@@ -274,7 +276,9 @@ Here's an example session script generated by the `session.vim` plug-in while I
274276
doautoall SessionLoadPost
275277
unlet SessionLoad
276278

279+
280+
[delcommand]: http://vimdoc.sourceforge.net/htmldoc/map.html#:delcommand
277281
[mksession]: http://vimdoc.sourceforge.net/htmldoc/starting.html#:mksession
282+
[sessionoptions]: http://vimdoc.sourceforge.net/htmldoc/options.html#%27sessionoptions%27
278283
[source]: http://vimdoc.sourceforge.net/htmldoc/repeat.html#:source
279284
[vimrc]: http://vimdoc.sourceforge.net/htmldoc/starting.html#vimrc
280-
[sessionoptions]: http://vimdoc.sourceforge.net/htmldoc/options.html#%27sessionoptions%27

autoload/xolox/session.vim

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

6-
let g:xolox#session#version = '1.5.8'
6+
let g:xolox#session#version = '1.5.9'
77

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

@@ -255,7 +255,7 @@ function! xolox#session#auto_load() " {{{2
255255
if v:servername !~ '^\cgvim\d*$'
256256
for session in xolox#session#get_names()
257257
if v:servername ==? session
258-
execute 'OpenSession' fnameescape(session)
258+
call xolox#session#open_cmd(session, '')
259259
return
260260
endif
261261
endfor
@@ -267,7 +267,7 @@ function! xolox#session#auto_load() " {{{2
267267
let msg = "Do you want to restore your %s editing session?"
268268
let label = session != 'default' ? 'last used' : 'default'
269269
if s:prompt(printf(msg, label), 'g:session_autoload')
270-
execute 'OpenSession' fnameescape(session)
270+
call xolox#session#open_cmd(session, '')
271271
endif
272272
endif
273273
endif
@@ -279,7 +279,7 @@ function! xolox#session#auto_save() " {{{2
279279
if name != ''
280280
let msg = "Do you want to save your editing session before quitting Vim?"
281281
if s:prompt(msg, 'g:session_autosave')
282-
execute 'SaveSession' fnameescape(name)
282+
call xolox#session#save_cmd(name, '')
283283
endif
284284
endif
285285
endif
@@ -396,7 +396,7 @@ function! xolox#session#close_cmd(bang, silent, save_allowed) abort " {{{2
396396
if a:save_allowed
397397
let msg = "Do you want to save your current editing session before closing it?"
398398
if s:prompt(msg, 'g:session_autosave')
399-
SaveSession
399+
call xolox#session#save_cmd(name, a:bang)
400400
endif
401401
else
402402
call xolox#misc#msg#debug("session.vim %s: Session reset requested, not saving changes to session ..", g:xolox#session#version)
@@ -448,7 +448,7 @@ function! xolox#session#restart_cmd(bang, args) abort " {{{2
448448
else
449449
let name = s:get_name('', 0)
450450
if name == '' | let name = 'restart' | endif
451-
execute 'SaveSession' . a:bang fnameescape(name)
451+
call xolox#session#save_cmd(name, a:bang)
452452
let progname = xolox#misc#escape#shell(fnameescape(v:progname))
453453
let command = progname . ' -c ' . xolox#misc#escape#shell('OpenSession\! ' . fnameescape(name))
454454
let args = matchstr(a:args, '^\s*|\s*\zs.\+$')
@@ -466,7 +466,7 @@ function! xolox#session#restart_cmd(bang, args) abort " {{{2
466466
call add(cmdline, printf("--cmd ':set enc=%s'", escape(&enc, '\ ')))
467467
silent execute '!' join(cmdline, ' ') '&'
468468
endif
469-
execute 'CloseSession' . a:bang
469+
call xolox#session#close_cmd(a:bang, 0, 1)
470470
silent quitall
471471
endif
472472
endfunction

doc/session.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,10 @@ command aliases:
299299
The aliases support tab completion just like the real commands; they're
300300
exactly the same except for the names.
301301

302+
When you enable the aliases, the default command names will still be
303+
available. If you really don't like them, feel free to delete them using
304+
|:delcommand|.
305+
302306
-------------------------------------------------------------------------------
303307
The *g:loaded_session* option
304308

0 commit comments

Comments
 (0)