From 9e7f26cf7bc1af037d3eedb10f3fee09b611f79a Mon Sep 17 00:00:00 2001 From: Vladimir Chizhov Date: Wed, 31 Jul 2013 03:34:04 +0400 Subject: [PATCH 1/4] infect: return loaded paths --- autoload/pathogen.vim | 49 +++++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/autoload/pathogen.vim b/autoload/pathogen.vim index 7b89ccaf..46406363 100644 --- a/autoload/pathogen.vim +++ b/autoload/pathogen.vim @@ -25,24 +25,24 @@ endfunction " Point of entry for basic default usage. Give a relative path to invoke " pathogen#incubate() (defaults to "bundle/{}"), or an absolute path to invoke " pathogen#surround(). For backwards compatibility purposes, a full path that -" does not end in {} or * is given to pathogen#runtime_prepend_subdirectories() -" instead. +" does not end in {} or * is given to pathogen#surround(). function! pathogen#infect(...) abort " {{{1 + let result = {'before' : [], 'after' : []} for path in a:0 ? reverse(copy(a:000)) : ['bundle/{}'] if path =~# '^[^\\/]\+$' call s:warn('Change pathogen#infect('.string(path).') to pathogen#infect('.string(path.'/{}').')') - call pathogen#incubate(path . '/{}') + let result = pathogen#incubate(path . '/{}') elseif path =~# '^[^\\/]\+[\\/]\%({}\|\*\)$' - call pathogen#incubate(path) + let result = pathogen#incubate(path) elseif path =~# '[\\/]\%({}\|\*\)$' - call pathogen#surround(path) + let result = pathogen#surround(path) else call s:warn('Change pathogen#infect('.string(path).') to pathogen#infect('.string(path.'/{}').')') - call pathogen#surround(path . '/{}') + let result = pathogen#surround(path . '/{}') endif endfor call pathogen#cycle_filetype() - return '' + return result endfunction " }}}1 " Split a path into a list. @@ -159,14 +159,15 @@ function! pathogen#surround(path) abort " {{{1 call filter(rtp, 'index(before + after, v:val) == -1') endif let &rtp = pathogen#join(before, rtp, after) - return &rtp + return {'before' : before, 'after' : after} endfunction " }}}1 " Prepend all subdirectories of path to the rtp, and append all 'after' " directories in those subdirectories. Deprecated. function! pathogen#runtime_prepend_subdirectories(path) " {{{1 call s:warn('Change pathogen#runtime_prepend_subdirectories('.string(a:path).') to pathogen#surround('.string(a:path.'/{}').')') - return pathogen#surround(a:path . pathogen#separator() . '{}') + call pathogen#surround(a:path . pathogen#separator() . '{}') + return &rtp " for backwards compatibility with earlier pathogen#surround() impl endfunction " }}}1 " For each directory in the runtime path, add a second entry with the given @@ -182,24 +183,40 @@ function! pathogen#incubate(...) abort " {{{1 return "" endif let s:done_bundles .= name . "\n" - let list = [] + let rtp_list = [] " full list of old and newly added runtimepath entries + " newly added entries only + let before = [] + let after = [] + " newly added entries for current rtp dir + let before_dir = [] + let after_dir = [] + for dir in pathogen#split(&rtp) if dir =~# '\ Date: Thu, 25 Jul 2013 03:13:28 +0400 Subject: [PATCH 2/4] infect: better detect relative paths Nested paths like 'bundle/public/{}' (containing more than one path separator) were not detected as relative. Thus they were passed to `surround`, instead of `incubate`. --- autoload/pathogen.vim | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/autoload/pathogen.vim b/autoload/pathogen.vim index 46406363..edff667b 100644 --- a/autoload/pathogen.vim +++ b/autoload/pathogen.vim @@ -29,16 +29,14 @@ endfunction function! pathogen#infect(...) abort " {{{1 let result = {'before' : [], 'after' : []} for path in a:0 ? reverse(copy(a:000)) : ['bundle/{}'] - if path =~# '^[^\\/]\+$' + if path !~# '[\\/]\%({}\|\*\)$' " Doesn't end with a mask '/{}' or '/*' call s:warn('Change pathogen#infect('.string(path).') to pathogen#infect('.string(path.'/{}').')') - let result = pathogen#incubate(path . '/{}') - elseif path =~# '^[^\\/]\+[\\/]\%({}\|\*\)$' + let path = path . '/{}' + endif + if path =~# '^[^\\/~]' " Doesn't start from slash or tilde => relative let result = pathogen#incubate(path) - elseif path =~# '[\\/]\%({}\|\*\)$' - let result = pathogen#surround(path) else - call s:warn('Change pathogen#infect('.string(path).') to pathogen#infect('.string(path.'/{}').')') - let result = pathogen#surround(path . '/{}') + let result = pathogen#surround(path) endif endfor call pathogen#cycle_filetype() From b522bde232d0a3d336786441a2767bc158fc91ff Mon Sep 17 00:00:00 2001 From: Vladimir Chizhov Date: Wed, 31 Jul 2013 03:18:13 +0400 Subject: [PATCH 3/4] incubate: fallback to surround if nothing found If pathogen#incubate() was called for a non-default relative path and nothing was found in runtimepath - it will "fallback" to pathogen#surround(). It will also protect absolute/relative path detection logic from failing on some platforms, like windows. --- autoload/pathogen.vim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/autoload/pathogen.vim b/autoload/pathogen.vim index edff667b..a8c77876 100644 --- a/autoload/pathogen.vim +++ b/autoload/pathogen.vim @@ -213,6 +213,10 @@ function! pathogen#incubate(...) abort " {{{1 let before += before_dir endif endfor + " fallback to pathogen#surround() if nothing was found in runtimepath + if (a:0 && (len(before) == 0) && (len(after) == 0)) + return pathogen#surround(name) + endif let &rtp = pathogen#join(pathogen#uniq(rtp_list)) return {'before' : pathogen#uniq(before), 'after' : pathogen#uniq(after)} endfunction " }}}1 From f9be8f55153b5efd4fa32c99d6f93db9e5677d40 Mon Sep 17 00:00:00 2001 From: Vladimir Chizhov Date: Wed, 7 Aug 2013 09:19:25 +0400 Subject: [PATCH 4/4] infect: revert returned value --- autoload/pathogen.vim | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/autoload/pathogen.vim b/autoload/pathogen.vim index a8c77876..d0ee0417 100644 --- a/autoload/pathogen.vim +++ b/autoload/pathogen.vim @@ -27,20 +27,19 @@ endfunction " pathogen#surround(). For backwards compatibility purposes, a full path that " does not end in {} or * is given to pathogen#surround(). function! pathogen#infect(...) abort " {{{1 - let result = {'before' : [], 'after' : []} for path in a:0 ? reverse(copy(a:000)) : ['bundle/{}'] if path !~# '[\\/]\%({}\|\*\)$' " Doesn't end with a mask '/{}' or '/*' call s:warn('Change pathogen#infect('.string(path).') to pathogen#infect('.string(path.'/{}').')') let path = path . '/{}' endif if path =~# '^[^\\/~]' " Doesn't start from slash or tilde => relative - let result = pathogen#incubate(path) + call pathogen#incubate(path) else - let result = pathogen#surround(path) + call pathogen#surround(path) endif endfor call pathogen#cycle_filetype() - return result + return '' endfunction " }}}1 " Split a path into a list.