diff options
Diffstat (limited to 'option.vim')
-rw-r--r-- | option.vim | 27 |
1 files changed, 26 insertions, 1 deletions
@@ -1,6 +1,6 @@ " Vim auto-load script " Author: Peter Odding <peter@peterodding.com> -" Last Change: June 27, 2011 +" Last Change: August 31, 2011 " URL: http://peterodding.com/code/vim/misc/ function! xolox#misc#option#get(name, ...) @@ -56,4 +56,29 @@ function! s:escape_tags(s) return escape(a:s, ', ') endfunction +function! xolox#misc#option#eval_tags(value, ...) + let pathnames = [] + let first_only = exists('a:1') && a:1 + for pattern in xolox#misc#option#split_tags(a:value) + " Make buffer relative pathnames absolute. + if pattern =~ '^\./' + let directory = xolox#misc#escape#substitute(expand('%:p:h')) + let pattern = substitute(pattern, '^.\ze/', directory, '') + endif + " Make working directory relative pathnames absolute. + if xolox#misc#path#is_relative(pattern) + let pattern = xolox#misc#path#merge(getcwd(), pattern) + endif + " Ignore the trailing `;' for recursive upwards searching because we + " always want the most specific pathname available. + let pattern = substitute(pattern, ';$', '', '') + " Expand the pattern. + call extend(pathnames, split(expand(pattern), "\n")) + if first_only && !empty(pathnames) + return pathnames[0] + endif + endfor + return firstonly ? '' : pathnames +endfunction + " vim: ts=2 sw=2 et |