Skip to content

Commit b9d03be

Browse files
committed
Merge branch 'master' of https://github.com/xolox/vim-misc
2 parents 2421490 + 362ec9c commit b9d03be

File tree

2 files changed

+27
-13
lines changed

2 files changed

+27
-13
lines changed

autoload/xolox/misc/list.vim

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,9 @@
66
" Remove duplicate values from {list} in-place (preserves order).
77

88
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)
2112
endfunction
2213

2314
" Binary insertion (more efficient than calling sort() after each insertion).

autoload/xolox/misc/path.vim

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,33 @@
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

66
let 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

1033
function! xolox#misc#path#split(path)

0 commit comments

Comments
 (0)