From 571abe35c99566996381b716c6f87756fef34748 Mon Sep 17 00:00:00 2001 From: Peter Odding Date: Wed, 31 Aug 2011 23:23:07 +0200 Subject: 'tags' evaluation --- option.vim | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'option.vim') diff --git a/option.vim b/option.vim index 8727ea1..efaf1bc 100644 --- a/option.vim +++ b/option.vim @@ -1,6 +1,6 @@ " Vim auto-load script " Author: Peter Odding -" 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 -- cgit v1.2.3