diff options
author | Peter Odding <peter@peterodding.com> | 2011-09-26 01:46:25 +0200 |
---|---|---|
committer | Peter Odding <peter@peterodding.com> | 2011-09-26 01:46:25 +0200 |
commit | 362ec9c9391decf5440b1a14e8a84a71168158cd (patch) | |
tree | 3b5d625ee4234ffb1cc6d923bab687dd920c47f8 | |
parent | 9cabfbd1d09b41b7b78ebf57a42957ba87ff136f (diff) | |
download | vim-easytags-362ec9c9391decf5440b1a14e8a84a71168158cd.tar.gz |
New xolox#misc#path#which() function to search the $PATH
-rw-r--r-- | path.vim | 25 |
1 files changed, 24 insertions, 1 deletions
@@ -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) |