File tree Expand file tree Collapse file tree 2 files changed +27
-13
lines changed Expand file tree Collapse file tree 2 files changed +27
-13
lines changed Original file line number Diff line number Diff line change 6
6
" Remove duplicate values from {list} in-place (preserves order).
7
7
8
8
function ! 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 )
21
12
endfunction
22
13
23
14
" Binary insertion (more efficient than calling sort() after each insertion).
Original file line number Diff line number Diff line change 1
1
" Vim auto-load script
2
2
" Author: Peter Odding <peter@peterodding.com>
3
- " Last Change: August 31 , 2011
3
+ " Last Change: September 26 , 2011
4
4
" URL: http://peterodding.com/code/vim/misc/
5
5
6
6
let s: windows_compatible = has (' win32' ) || has (' win64' )
7
7
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
+
8
31
" Split a pathname into a list of path components.
9
32
10
33
function ! xolox#misc#path#split (path )
You can’t perform that action at this time.
0 commit comments