Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'master' of https://github.com/xolox/vim-misc

  • Loading branch information...
commit c8c3405b0f05463410c4e646d9a46d4679b4a69b 2 parents fd90005 + 362ec9c
Peter Odding authored September 26, 2011
15  autoload/xolox/misc/list.vim
@@ -6,18 +6,9 @@
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).
25  autoload/xolox/misc/path.vim
... ...
@@ -1,10 +1,33 @@
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)

0 notes on commit c8c3405

Please sign in to comment.
Something went wrong with that request. Please try again.