patch 7.4.1553
Problem: ":runtime" does not use 'packpath'.
Solution: Add "what" argument.
diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c
index b99d002..d7bf609 100644
--- a/src/ex_cmds2.c
+++ b/src/ex_cmds2.c
@@ -2901,12 +2901,38 @@
#endif
/*
- * ":runtime {name}"
+ * ":runtime [what] {name}"
*/
void
ex_runtime(exarg_T *eap)
{
- source_runtime(eap->arg, eap->forceit ? DIP_ALL : 0);
+ char_u *arg = eap->arg;
+ char_u *p = skiptowhite(arg);
+ int len = (int)(p - arg);
+ int flags = eap->forceit ? DIP_ALL : 0;
+
+ if (STRNCMP(arg, "START", len) == 0)
+ {
+ flags += DIP_START + DIP_NORTP;
+ arg = skipwhite(arg + len);
+ }
+ else if (STRNCMP(arg, "OPT", len) == 0)
+ {
+ flags += DIP_OPT + DIP_NORTP;
+ arg = skipwhite(arg + len);
+ }
+ else if (STRNCMP(arg, "PACK", len) == 0)
+ {
+ flags += DIP_START + DIP_OPT + DIP_NORTP;
+ arg = skipwhite(arg + len);
+ }
+ else if (STRNCMP(arg, "ALL", len) == 0)
+ {
+ flags += DIP_START + DIP_OPT;
+ arg = skipwhite(arg + len);
+ }
+
+ source_runtime(arg, flags);
}
static void
@@ -3067,15 +3093,16 @@
void (*callback)(char_u *fname, void *ck),
void *cookie)
{
- int done;
+ int done = FAIL;
char_u *s;
int len;
char *start_dir = "pack/*/start/*/%s";
char *opt_dir = "pack/*/opt/*/%s";
- done = do_in_path(p_rtp, name, flags, callback, cookie);
+ if ((flags & DIP_NORTP) == 0)
+ done = do_in_path(p_rtp, name, flags, callback, cookie);
- if (done == FAIL && (flags & DIP_START))
+ if ((done == FAIL || (flags & DIP_ALL)) && (flags & DIP_START))
{
len = STRLEN(start_dir) + STRLEN(name);
s = alloc(len);
@@ -3086,7 +3113,7 @@
vim_free(s);
}
- if (done == FAIL && (flags & DIP_OPT))
+ if ((done == FAIL || (flags & DIP_ALL)) && (flags & DIP_OPT))
{
len = STRLEN(opt_dir) + STRLEN(name);
s = alloc(len);
diff --git a/src/testdir/test_packadd.vim b/src/testdir/test_packadd.vim
index 3ca8375..52e6a33 100644
--- a/src/testdir/test_packadd.vim
+++ b/src/testdir/test_packadd.vim
@@ -134,3 +134,50 @@
colorscheme three
call assert_equal(1, g:found_three)
endfunc
+
+func Test_runtime()
+ let rundir = &packpath . '/runtime/extra'
+ let startdir = &packpath . '/pack/mine/start/foo/extra'
+ let optdir = &packpath . '/pack/mine/opt/bar/extra'
+ call mkdir(rundir, 'p')
+ call mkdir(startdir, 'p')
+ call mkdir(optdir, 'p')
+ call writefile(['let g:sequence .= "run"'], rundir . '/bar.vim')
+ call writefile(['let g:sequence .= "start"'], startdir . '/bar.vim')
+ call writefile(['let g:sequence .= "foostart"'], startdir . '/foo.vim')
+ call writefile(['let g:sequence .= "opt"'], optdir . '/bar.vim')
+ call writefile(['let g:sequence .= "xxxopt"'], optdir . '/xxx.vim')
+ exe 'set rtp=' . &packpath . '/runtime'
+
+ let g:sequence = ''
+ runtime extra/bar.vim
+ call assert_equal('run', g:sequence)
+ let g:sequence = ''
+ runtime START extra/bar.vim
+ call assert_equal('start', g:sequence)
+ let g:sequence = ''
+ runtime OPT extra/bar.vim
+ call assert_equal('opt', g:sequence)
+ let g:sequence = ''
+ runtime PACK extra/bar.vim
+ call assert_equal('start', g:sequence)
+ let g:sequence = ''
+ runtime! PACK extra/bar.vim
+ call assert_equal('startopt', g:sequence)
+ let g:sequence = ''
+ runtime PACK extra/xxx.vim
+ call assert_equal('xxxopt', g:sequence)
+
+ let g:sequence = ''
+ runtime ALL extra/bar.vim
+ call assert_equal('run', g:sequence)
+ let g:sequence = ''
+ runtime ALL extra/foo.vim
+ call assert_equal('foostart', g:sequence)
+ let g:sequence = ''
+ runtime! ALL extra/xxx.vim
+ call assert_equal('xxxopt', g:sequence)
+ let g:sequence = ''
+ runtime! ALL extra/bar.vim
+ call assert_equal('runstartopt', g:sequence)
+endfunc
diff --git a/src/version.c b/src/version.c
index d77d480..ed6e4b2 100644
--- a/src/version.c
+++ b/src/version.c
@@ -744,6 +744,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1553,
+/**/
1552,
/**/
1551,
diff --git a/src/vim.h b/src/vim.h
index becc26a..9e4406a 100644
--- a/src/vim.h
+++ b/src/vim.h
@@ -2294,5 +2294,6 @@
#define DIP_ERR 0x04 /* give an error message when none found. */
#define DIP_START 0x08 /* also use "start" directory in 'packpath' */
#define DIP_OPT 0x10 /* also use "opt" directory in 'packpath' */
+#define DIP_NORTP 0x20 /* do not use 'runtimepath' */
#endif /* VIM__H */