Introduce g:startify_session_remove_lines

References #159.
This commit is contained in:
Marco Hinz 2015-05-12 11:22:06 +02:00
parent 9ef7fcb502
commit 1f42935fd6
2 changed files with 39 additions and 3 deletions

View file

@ -251,14 +251,27 @@ function! startify#session_write(spath)
let &sessionoptions = ssop
endtry
if exists('g:startify_session_savevars') || exists('g:startify_session_savecmds')
if exists('g:startify_session_remove_lines')
\ || exists('g:startify_session_savevars')
\ || exists('g:startify_session_savecmds')
execute 'split' a:spath
" remove lines from the session file
if exists('g:startify_session_remove_lines')
for pattern in g:startify_session_remove_lines
execute 'silent global/'. pattern .'/delete'
endfor
endif
" put existing variables from savevars into session file
call append(line('$')-3, map(filter(copy(get(g:, 'startify_session_savevars', [])), 'exists(v:val)'), '"let ". v:val ." = ". strtrans(string(eval(v:val)))'))
if exists('g:startify_session_savevars')
call append(line('$')-3, map(filter(copy(g:startify_session_savevars), 'exists(v:val)'), '"let ". v:val ." = ". strtrans(string(eval(v:val)))'))
endif
" put commands from savecmds into session file
call append(line('$')-3, get(g:, 'startify_session_savecmds', []))
if exists('g:startify_session_savecmds')
call append(line('$')-3, g:startify_session_savecmds)
endif
setlocal bufhidden=delete
silent update

View file

@ -103,6 +103,7 @@ default values.
|g:startify_session_delete_buffers|
|g:startify_session_dir|
|g:startify_session_persistence|
|g:startify_session_remove_lines|
|g:startify_session_savecmds|
|g:startify_session_savevars|
|g:startify_skiplist_server|
@ -307,6 +308,28 @@ Currently this option does this:
- don't check every file if it's readable (stat(2))
- don't filter through the bookmark list
------------------------------------------------------------------------------
*g:startify_session_remove_lines*
>
let g:startify_session_remove_lines = []
<
Lines matching any of the patterns in this list, will be removed from the
session file.
Example:
>
let g:startify_session_remove_lines = ['setlocal', 'winheight']
<
Internally this simply does:
>
:global/setlocal/delete
:global/winheight/delete
<
So you can use any |pattern|.
NOTE: Take care not to mess up any expressions within the session file,
otherwise you'll probably get problems when trying to load it.
------------------------------------------------------------------------------
*g:startify_session_savevars*
>