diff options
author | Peter Odding <peter@peterodding.com> | 2011-09-26 01:47:30 +0200 |
---|---|---|
committer | Peter Odding <peter@peterodding.com> | 2011-09-26 01:47:30 +0200 |
commit | 0a9a07eee93aa823fe0a17967b15367afa15f48b (patch) | |
tree | 49372ed5d93d616bb4f66ad5533f1b5d1f929da4 | |
parent | 100bd8df876c589c956a08a76fa4fd9eac96af2d (diff) | |
parent | 362ec9c9391decf5440b1a14e8a84a71168158cd (diff) | |
download | vim-easytags-0a9a07eee93aa823fe0a17967b15367afa15f48b.tar.gz |
Merge branch 'master' of https://github.com/xolox/vim-misc
-rw-r--r-- | autoload/xolox/misc/list.vim | 15 | ||||
-rw-r--r-- | autoload/xolox/misc/path.vim | 25 |
2 files changed, 27 insertions, 13 deletions
diff --git a/autoload/xolox/misc/list.vim b/autoload/xolox/misc/list.vim index 44d6b20..ee243d4 100644 --- a/autoload/xolox/misc/list.vim +++ b/autoload/xolox/misc/list.vim @@ -6,18 +6,9 @@ " Remove duplicate values from {list} in-place (preserves order). function! xolox#misc#list#unique(list) - let index = 0 - while index < len(a:list) - let value = a:list[index] - let match = index(a:list, value, index+1) - if match >= 0 - call remove(a:list, match) - else - let index += 1 - endif - unlet value - endwhile - return a:list + call reverse(a:list) + call filter(a:list, 'count(a:list, v:val) == 1') + return reverse(a:list) endfunction " Binary insertion (more efficient than calling sort() after each insertion). diff --git a/autoload/xolox/misc/path.vim b/autoload/xolox/misc/path.vim index ee0f2e2..efb6340 100644 --- a/autoload/xolox/misc/path.vim +++ b/autoload/xolox/misc/path.vim @@ -1,10 +1,33 @@ " Vim auto-load script " Author: Peter Odding <peter@peterodding.com> -" Last Change: August 31, 2011 +" Last Change: September 26, 2011 " URL: http://peterodding.com/code/vim/misc/ let s:windows_compatible = has('win32') || has('win64') +function! xolox#misc#path#which(...) + let extensions = s:windows_compatible ? split($PATHEXT, ';') : [''] + let matches = [] + let checked = {} + for directory in split($PATH, s:windows_compatible ? ';' : ':') + let directory = xolox#misc#path#absolute(directory) + if !has_key(checked, directory) + if isdirectory(directory) + for program in a:000 + for extension in extensions + let path = xolox#misc#path#merge(directory, program . extension) + if executable(path) + call add(matches, path) + endif + endfor + endfor + endif + let checked[directory] = 1 + endif + endfor + return matches +endfunction + " Split a pathname into a list of path components. function! xolox#misc#path#split(path) |