]> granicus.if.org Git - vim/commitdiff
patch 7.4.1550 v7.4.1550
authorBram Moolenaar <Bram@vim.org>
Sat, 12 Mar 2016 19:34:27 +0000 (20:34 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 12 Mar 2016 19:34:27 +0000 (20:34 +0100)
Problem:    Cannot load packages early.
Solution:   Add the ":packloadall" command.

src/ex_cmds.h
src/ex_cmds2.c
src/main.c
src/proto/ex_cmds2.pro
src/testdir/test_packadd.vim
src/version.c

index c25ee2ee65b221de65972daf59062ae98ae7a61a..34defea44e445a43dc3e550ee636397f7c48453e 100644 (file)
@@ -1014,6 +1014,9 @@ EX(CMD_print,             "print",        ex_print,
 EX(CMD_packadd,                "packadd",      ex_packadd,
                        BANG|FILE1|NEEDARG|TRLBAR|SBOXOK|CMDWIN,
                        ADDR_LINES),
+EX(CMD_packloadall,    "packloadall",  ex_packloadall,
+                       BANG|TRLBAR|SBOXOK|CMDWIN,
+                       ADDR_LINES),
 EX(CMD_pclose,         "pclose",       ex_pclose,
                        BANG|TRLBAR,
                        ADDR_LINES),
index 19d7d19fa25c98653f302ee936385c8b95f4f0e2..616f7a078f709b65965ed3290ca59cb289fc7d95 100644 (file)
@@ -3189,14 +3189,21 @@ theend:
     vim_free(ffname);
 }
 
+static int did_source_packages = FALSE;
+
 /*
+ * ":packloadall"
  * Find plugins in the package directories and source them.
  */
     void
-source_packages()
+ex_packloadall(exarg_T *eap)
 {
-    do_in_path(p_pp, (char_u *)"pack/*/start/*", DIP_ALL + DIP_DIR,
+    if (!did_source_packages || (eap != NULL && eap->forceit))
+    {
+       did_source_packages = TRUE;
+       do_in_path(p_pp, (char_u *)"pack/*/start/*", DIP_ALL + DIP_DIR,
                                                        add_pack_plugin, p_pp);
+    }
 }
 
 /*
index 076898c34561092705c45340b77344477d62beab..7bbf248e417519afe09dd9ae63d9a3255894f672 100644 (file)
@@ -634,7 +634,7 @@ vim_main2(int argc UNUSED, char **argv UNUSED)
 # endif
        TIME_MSG("loading plugins");
 
-       source_packages();
+       ex_packloadall(NULL);
        TIME_MSG("loading packages");
     }
 #endif
index e10f072419de1d2e310d2d46928ff994e10434e4..1f1177429b20b36b71d1fea4b4924072f443b285 100644 (file)
@@ -62,8 +62,7 @@ void ex_compiler(exarg_T *eap);
 void ex_runtime(exarg_T *eap);
 int source_runtime(char_u *name, int all);
 int do_in_runtimepath(char_u *name, int all, void (*callback)(char_u *fname, void *ck), void *cookie);
-void source_packages(void);
-void ex_loadplugin(exarg_T *eap);
+void ex_packloadall(exarg_T *eap);
 void ex_packadd(exarg_T *eap);
 void ex_options(exarg_T *eap);
 void ex_source(exarg_T *eap);
index a0a270149b4f600afecbe46d721d3c285adb6d50..2b66f6d321dd8aa5854d3afbfd50c2479775d09a 100644 (file)
@@ -80,3 +80,20 @@ func Test_packadd_completion()
   call assert_equal("packadd pluginC", li[2])
   call assert_equal("packadd ", li[3])
 endfunc
+
+func Test_packloadall()
+  let plugindir = &packpath . '/pack/mine/start/foo/plugin'
+  call mkdir(plugindir, 'p')
+  call writefile(['let g:plugin_foo_number = 1234'], plugindir . '/bar.vim')
+  packloadall
+  call assert_equal(1234, g:plugin_foo_number)
+
+  " only works once
+  call writefile(['let g:plugin_bar_number = 4321'], plugindir . '/bar2.vim')
+  packloadall
+  call assert_false(exists('g:plugin_bar_number'))
+
+  " works when ! used
+  packloadall!
+  call assert_equal(4321, g:plugin_bar_number)
+endfunc
index 87fdebcdec1b246dcd4f2195d96f961e379f2172..4f66f9d4883e5c9f4f6260576a5a4e5b6fb472d1 100644 (file)
@@ -743,6 +743,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1550,
 /**/
     1549,
 /**/