patch 7.4.1486
Problem: ":loadplugin" is not optimal, some people find it confusing.
Solution: Only use ":packadd" with an optional "!".
diff --git a/src/testdir/Make_all.mak b/src/testdir/Make_all.mak
index 4c3c616..854f95b 100644
--- a/src/testdir/Make_all.mak
+++ b/src/testdir/Make_all.mak
@@ -178,7 +178,7 @@
test_increment.res \
test_json.res \
test_langmap.res \
- test_loadplugin.res \
+ test_packadd.res \
test_perl.res \
test_quickfix.res \
test_syntax.res \
diff --git a/src/testdir/test_loadplugin.vim b/src/testdir/test_packadd.vim
similarity index 77%
rename from src/testdir/test_loadplugin.vim
rename to src/testdir/test_packadd.vim
index 431dd4a..aec80ef 100644
--- a/src/testdir/test_loadplugin.vim
+++ b/src/testdir/test_packadd.vim
@@ -1,4 +1,4 @@
-" Tests for :loadplugin
+" Tests for 'packpath' and :packadd
func SetUp()
let s:topdir = expand('%:h') . '/Xdir'
@@ -10,7 +10,7 @@
call delete(s:topdir, 'rf')
endfunc
-func Test_loadplugin()
+func Test_packadd()
call mkdir(s:plugdir . '/plugin', 'p')
call mkdir(s:plugdir . '/ftdetect', 'p')
set rtp&
@@ -25,7 +25,7 @@
call setline(1, 'let g:ftdetect_works = 17')
wq
- loadplugin mytest
+ packadd mytest
call assert_equal(42, g:plugin_works)
call assert_equal(17, g:ftdetect_works)
@@ -33,16 +33,25 @@
call assert_true(&rtp =~ 'testdir/Xdir/pack/mine/opt/mytest\($\|,\)')
endfunc
-func Test_packadd()
+func Test_packadd_noload()
+ call mkdir(s:plugdir . '/plugin', 'p')
call mkdir(s:plugdir . '/syntax', 'p')
set rtp&
let rtp = &rtp
- packadd mytest
+
+ exe 'split ' . s:plugdir . '/plugin/test.vim'
+ call setline(1, 'let g:plugin_works = 42')
+ wq
+ let g:plugin_works = 0
+
+ packadd! mytest
+
call assert_true(len(&rtp) > len(rtp))
call assert_true(&rtp =~ 'testdir/Xdir/pack/mine/opt/mytest\($\|,\)')
+ call assert_equal(0, g:plugin_works)
" check the path is not added twice
let new_rtp = &rtp
- packadd mytest
+ packadd! mytest
call assert_equal(new_rtp, &rtp)
endfunc