1 let s:segment_mods = []
3 function! Pl#Mod#AddSegmentMod(action, properties) " {{{
4 call add(s:segment_mods, [a:action, a:properties])
6 function! Pl#Mod#ApplySegmentMods(theme) " {{{
7 let theme = deepcopy(a:theme)
9 for mod in s:segment_mods
10 let [action, properties] = mod
12 " We have to loop through the segments instead of using index() because some
14 let target_seg_idx = -1
16 for i in range(0, len(theme) - 1)
18 let segment = theme[i]
20 if type(segment) == type(properties.target_segment) && segment == properties.target_segment
21 let target_seg_idx = i
26 if action == 'insert_segment'
28 if target_seg_idx != -1
29 call insert(theme, properties.new_segment, (properties.where == 'before' ? target_seg_idx : target_seg_idx + 1))
31 elseif action == 'remove_segment'
33 if target_seg_idx != -1
34 call remove(theme, target_seg_idx)