File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66" Remove duplicate values from {list} in-place (preserves order).
77
88function ! xolox#misc#list#unique (list )
9- let index = 0
10- while index < len (a: list )
11- let value = a: list [index ]
12- let match = index (a: list , value, index + 1 )
13- if match >= 0
14- call remove (a: list , match )
15- else
16- let index += 1
17- endif
18- unlet value
19- endwhile
20- return a: list
9+ call reverse (a: list )
10+ call filter (a: list , ' count(a:list, v:val) == 1' )
11+ return reverse (a: list )
2112endfunction
2213
2314" Binary insertion (more efficient than calling sort() after each insertion).
Original file line number Diff line number Diff line change 11" Vim auto-load script
22" Author: Peter Odding <peter@peterodding.com>
3- " Last Change: August 31 , 2011
3+ " Last Change: September 26 , 2011
44" URL: http://peterodding.com/code/vim/misc/
55
66let s: windows_compatible = has (' win32' ) || has (' win64' )
77
8+ function ! xolox#misc#path#which (... )
9+ let extensions = s: windows_compatible ? split ($PATHEXT , ' ;' ) : [' ' ]
10+ let matches = []
11+ let checked = {}
12+ for directory in split ($PATH , s: windows_compatible ? ' ;' : ' :' )
13+ let directory = xolox#misc#path#absolute (directory )
14+ if ! has_key (checked, directory )
15+ if isdirectory (directory )
16+ for program in a: 000
17+ for extension in extensions
18+ let path = xolox#misc#path#merge (directory , program . extension)
19+ if executable (path )
20+ call add (matches, path )
21+ endif
22+ endfor
23+ endfor
24+ endif
25+ let checked[directory ] = 1
26+ endif
27+ endfor
28+ return matches
29+ endfunction
30+
831" Split a pathname into a list of path components.
932
1033function ! xolox#misc#path#split (path )
You can’t perform that action at this time.
0 commit comments