File tree 2 files changed +38
-0
lines changed
2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -519,6 +519,33 @@ list with one string on success and an empty list on failure.
519
519
520
520
<!-- End of generated documentation -->
521
521
522
+ ### Using a custom filter on ` :SaveSession `
523
+
524
+ #### The ` xolox#session#use_custom_filter() ` function
525
+
526
+ You can use this function to provide a ` funcref ` to filter the commands through
527
+ before ` vim-session ` saves them. In the following example we also persist the
528
+ tab names previously assigned with [ gcmt/taboo.vim] ( https://github.com/gcmt/taboo.vim ) :
529
+
530
+ ```
531
+ function! CustomFilter(commands)
532
+ let currentTab = tabpagenr()
533
+ let tabNames = []
534
+ tabdo call add(tabNames, TabooTabName(tabpagenr()))
535
+ exec 'tabn ' . currentTab
536
+ let idx = match(a:commands, '^[^"]') - 1
537
+ echom 'found ' . idx
538
+ for t in tabNames
539
+ if !empty(t)
540
+ call insert(a:commands, 'TabooRename ' . t, idx+1)
541
+ endif
542
+ let idx = match(a:commands, 'tabedit.*', idx+2)
543
+ " echom idx
544
+ endfor
545
+ endfunction
546
+ call xolox#session#use_custom_filter(function('CustomFilter'))
547
+ ```
548
+
522
549
## Troubleshooting
523
550
524
551
### Using multiple platforms (multi boot, Cygwin, etc.)
Original file line number Diff line number Diff line change @@ -8,6 +8,14 @@ let g:xolox#session#version = '2.13.1'
8
8
9
9
" Public API for session persistence. {{{1
10
10
11
+ function ! xolox#session#use_custom_filter (fn)
12
+ if type (a: fn ) == 2
13
+ let s: custom_filter = a: fn
14
+ elseif exists (' s:custom_filter' )
15
+ unlet s: custom_filter
16
+ endif
17
+ endfunction
18
+
11
19
function ! xolox#session#save_session (commands, filename) " {{{2
12
20
" Save the current Vim editing session to a Vim script using the
13
21
" [:mksession] [] command and some additional Vim magic provided by the
@@ -197,6 +205,9 @@ function! xolox#session#save_state(commands) " {{{2
197
205
call s: cleanup_after_plugin (a: commands , ' s:wipebuf' )
198
206
call add (a: commands , " endif" )
199
207
call add (a: commands , " endif" )
208
+ if exists (' s:custom_filter' ) && type (s: custom_filter ) == 2
209
+ call s: custom_filter (a: commands )
210
+ endif
200
211
return 1
201
212
finally
202
213
let &sessionoptions = ssop_save
You can’t perform that action at this time.
0 commit comments