aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Odding <peter@peterodding.com>2011-08-31 23:23:07 +0200
committerPeter Odding <peter@peterodding.com>2011-08-31 23:23:07 +0200
commit571abe35c99566996381b716c6f87756fef34748 (patch)
treeb1e8319fac58fa28f27a5a0d0b0614f34910ccc7
parentdbab84bb2b37da40c27b6ade36920d2b96612ba5 (diff)
downloadvim-easytags-571abe35c99566996381b716c6f87756fef34748.tar.gz
'tags' evaluation
-rw-r--r--option.vim27
1 files changed, 26 insertions, 1 deletions
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 <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