]> granicus.if.org Git - vim/commitdiff
patch 7.4.1552 v7.4.1552
authorBram Moolenaar <Bram@vim.org>
Sat, 12 Mar 2016 21:11:39 +0000 (22:11 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 12 Mar 2016 21:11:39 +0000 (22:11 +0100)
Problem:    ":colorscheme" does not use 'packpath'.
Solution:   Also use in "start" and "opt" directories in 'packpath'.

16 files changed:
src/digraph.c
src/eval.c
src/ex_cmds2.c
src/ex_docmd.c
src/gui.c
src/hardcopy.c
src/if_py_both.h
src/main.c
src/option.c
src/os_mswin.c
src/spell.c
src/syntax.c
src/tag.c
src/testdir/test_packadd.vim
src/version.c
src/vim.h

index 5dab51b20fcfd484b1c7a6e81d19a046386b2562..b17340cb2c51c832b3eb4bfb9862aa0e740c6cdd 100644 (file)
@@ -2320,13 +2320,13 @@ keymap_init(void)
        /* try finding "keymap/'keymap'_'encoding'.vim"  in 'runtimepath' */
        vim_snprintf((char *)buf, buflen, "keymap/%s_%s.vim",
                                                   curbuf->b_p_keymap, p_enc);
-       if (source_runtime(buf, FALSE) == FAIL)
+       if (source_runtime(buf, 0) == FAIL)
 # endif
        {
            /* try finding "keymap/'keymap'.vim" in 'runtimepath'  */
            vim_snprintf((char *)buf, buflen, "keymap/%s.vim",
                                                          curbuf->b_p_keymap);
-           if (source_runtime(buf, FALSE) == FAIL)
+           if (source_runtime(buf, 0) == FAIL)
            {
                vim_free(buf);
                return (char_u *)N_("E544: Keymap file not found");
index 765d9b99dd70512213507d2a38670172f6b33887..0b589fdc0f649196c3b77b2ec06d3e39531d76db 100644 (file)
@@ -23942,7 +23942,7 @@ script_autoload(
        }
 
        /* Try loading the package from $VIMRUNTIME/autoload/<name>.vim */
-       if (source_runtime(scriptname, FALSE) == OK)
+       if (source_runtime(scriptname, 0) == OK)
            ret = TRUE;
     }
 
index 75146749b5b100be932c9a18e06b253b035af711..b99d0020ee015015c86d9224288a7eeab6009f45 100644 (file)
@@ -2872,7 +2872,7 @@ ex_compiler(exarg_T *eap)
            do_unlet((char_u *)"b:current_compiler", TRUE);
 
            sprintf((char *)buf, "compiler/%s.vim", eap->arg);
-           if (source_runtime(buf, TRUE) == FAIL)
+           if (source_runtime(buf, DIP_ALL) == FAIL)
                EMSG2(_("E666: compiler not supported: %s"), eap->arg);
            vim_free(buf);
 
@@ -2906,7 +2906,7 @@ ex_compiler(exarg_T *eap)
     void
 ex_runtime(exarg_T *eap)
 {
-    source_runtime(eap->arg, eap->forceit);
+    source_runtime(eap->arg, eap->forceit ? DIP_ALL : 0);
 }
 
     static void
@@ -2918,14 +2918,14 @@ source_callback(char_u *fname, void *cookie UNUSED)
 /*
  * Source the file "name" from all directories in 'runtimepath'.
  * "name" can contain wildcards.
- * When "all" is TRUE: source all files, otherwise only the first one.
+ * When "flags" has DIP_ALL: source all files, otherwise only the first one.
  *
  * return FAIL when no file could be sourced, OK otherwise.
  */
     int
-source_runtime(char_u *name, int all)
+source_runtime(char_u *name, int flags)
 {
-    return do_in_runtimepath(name, all, source_callback, NULL);
+    return do_in_runtimepath(name, flags, source_callback, NULL);
 }
 
 /*
@@ -3052,8 +3052,8 @@ do_in_path(
 /*
  * Find "name" in 'runtimepath'.  When found, invoke the callback function for
  * it: callback(fname, "cookie")
- * When "all" is TRUE repeat for all matches, otherwise only the first one is
- * used.
+ * When "flags" has DIP_ALL repeat for all matches, otherwise only the first
+ * one is used.
  * Returns OK when at least one match found, FAIL otherwise.
  *
  * If "name" is NULL calls callback for each entry in runtimepath. Cookie is
@@ -3063,11 +3063,41 @@ do_in_path(
     int
 do_in_runtimepath(
     char_u     *name,
-    int                all,
+    int                flags,
     void       (*callback)(char_u *fname, void *ck),
     void       *cookie)
 {
-    return do_in_path(p_rtp, name, all ? DIP_ALL : 0, callback, cookie);
+    int                done;
+    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 (done == FAIL && (flags & DIP_START))
+    {
+       len = STRLEN(start_dir) + STRLEN(name);
+       s = alloc(len);
+       if (s == NULL)
+           return FAIL;
+       vim_snprintf((char *)s, len, start_dir, name);
+       done = do_in_path(p_pp, s, flags, callback, cookie);
+       vim_free(s);
+    }
+
+    if (done == FAIL && (flags & DIP_OPT))
+    {
+       len = STRLEN(opt_dir) + STRLEN(name);
+       s = alloc(len);
+       if (s == NULL)
+           return FAIL;
+       vim_snprintf((char *)s, len, opt_dir, name);
+       done = do_in_path(p_pp, s, flags, callback, cookie);
+       vim_free(s);
+    }
+
+    return done;
 }
 
 /*
index 63e982eee11dbf4e6312b2c913aba5ba3a42492b..9b116e2bde5751cbd7f79128eee7c6e93b7a86e2 100644 (file)
@@ -11777,16 +11777,16 @@ ex_filetype(exarg_T *eap)
     {
        if (*arg == 'o' || !filetype_detect)
        {
-           source_runtime((char_u *)FILETYPE_FILE, TRUE);
+           source_runtime((char_u *)FILETYPE_FILE, DIP_ALL);
            filetype_detect = TRUE;
            if (plugin)
            {
-               source_runtime((char_u *)FTPLUGIN_FILE, TRUE);
+               source_runtime((char_u *)FTPLUGIN_FILE, DIP_ALL);
                filetype_plugin = TRUE;
            }
            if (indent)
            {
-               source_runtime((char_u *)INDENT_FILE, TRUE);
+               source_runtime((char_u *)INDENT_FILE, DIP_ALL);
                filetype_indent = TRUE;
            }
        }
@@ -11802,18 +11802,18 @@ ex_filetype(exarg_T *eap)
        {
            if (plugin)
            {
-               source_runtime((char_u *)FTPLUGOF_FILE, TRUE);
+               source_runtime((char_u *)FTPLUGOF_FILE, DIP_ALL);
                filetype_plugin = FALSE;
            }
            if (indent)
            {
-               source_runtime((char_u *)INDOFF_FILE, TRUE);
+               source_runtime((char_u *)INDOFF_FILE, DIP_ALL);
                filetype_indent = FALSE;
            }
        }
        else
        {
-           source_runtime((char_u *)FTOFF_FILE, TRUE);
+           source_runtime((char_u *)FTOFF_FILE, DIP_ALL);
            filetype_detect = FALSE;
        }
     }
index e91fcaf91ac03eabdf820e3b101d3eedc15c9b8b..2701265f1d91208388f28833726583565fbb31ab 100644 (file)
--- a/src/gui.c
+++ b/src/gui.c
@@ -4988,7 +4988,7 @@ gui_find_bitmap(char_u *name, char_u *buffer, char *ext)
     if (STRLEN(name) > MAXPATHL - 14)
        return FAIL;
     vim_snprintf((char *)buffer, MAXPATHL, "bitmaps/%s.%s", name, ext);
-    if (do_in_runtimepath(buffer, FALSE, gfp_setname, buffer) == FAIL
+    if (do_in_runtimepath(buffer, 0, gfp_setname, buffer) == FAIL
                                                            || *buffer == NUL)
        return FAIL;
     return OK;
index b6fa95bebecea4821334ea61deac98eb406d9c9f..74fee2e214550406f33d745f565fdf037e162df7 100644 (file)
@@ -1741,7 +1741,7 @@ prt_find_resource(char *name, struct prt_ps_resource_S *resource)
     vim_strcat(buffer, (char_u *)name, MAXPATHL);
     vim_strcat(buffer, (char_u *)".ps", MAXPATHL);
     resource->filename[0] = NUL;
-    retval = (do_in_runtimepath(buffer, FALSE, prt_resource_name,
+    retval = (do_in_runtimepath(buffer, 0, prt_resource_name,
                                                           resource->filename)
            && resource->filename[0] != NUL);
     vim_free(buffer);
index 6ae3fe7f6b8941e7e0116aaddde1b5268ca26351..e916e6aa8dcfebf1b32f733148c0819ec0396746 100644 (file)
@@ -1061,7 +1061,7 @@ VimForeachRTP(PyObject *self UNUSED, PyObject *callable)
     data.callable = callable;
     data.result = NULL;
 
-    do_in_runtimepath(NULL, FALSE, &map_rtp_callback, &data);
+    do_in_runtimepath(NULL, 0, &map_rtp_callback, &data);
 
     if (data.result == NULL)
     {
@@ -1150,7 +1150,7 @@ Vim_GetPaths(PyObject *self UNUSED)
     if (!(ret = PyList_New(0)))
        return NULL;
 
-    do_in_runtimepath(NULL, FALSE, &map_finder_callback, ret);
+    do_in_runtimepath(NULL, 0, &map_finder_callback, ret);
 
     if (PyErr_Occurred())
     {
index 7bbf248e417519afe09dd9ae63d9a3255894f672..8c7d3d68b1dff21b503e48d446ff121128a2b250 100644 (file)
@@ -628,9 +628,9 @@ vim_main2(int argc UNUSED, char **argv UNUSED)
     if (p_lpl)
     {
 # ifdef VMS    /* Somehow VMS doesn't handle the "**". */
-       source_runtime((char_u *)"plugin/*.vim", TRUE);
+       source_runtime((char_u *)"plugin/*.vim", DIP_ALL);
 # else
-       source_runtime((char_u *)"plugin/**/*.vim", TRUE);
+       source_runtime((char_u *)"plugin/**/*.vim", DIP_ALL);
 # endif
        TIME_MSG("loading plugins");
 
index b624aad094922eefdd852895b08567b7c798a756..648919dc74e18f97dc14320b630bcd29e3852ab3 100644 (file)
@@ -7290,7 +7290,7 @@ did_set_string_option(
                if (vim_strchr((char_u *)"_.,", *p) != NULL)
                    break;
            vim_snprintf((char *)fname, 200, "spell/%.*s.vim", (int)(p - q), q);
-           source_runtime(fname, TRUE);
+           source_runtime(fname, DIP_ALL);
        }
 #endif
     }
index 2a80381a0314f61bac1d9a857c782e70bf3b4951..607fd6a51fdc364255dea56c1cf8715ec55342af 100644 (file)
@@ -950,7 +950,7 @@ mch_icon_load_cb(char_u *fname, void *cookie)
 mch_icon_load(HANDLE *iconp)
 {
     return do_in_runtimepath((char_u *)"bitmaps/vim.ico",
-                                             FALSE, mch_icon_load_cb, iconp);
+                                                 0, mch_icon_load_cb, iconp);
 }
 
     int
index 9220bc0bed2ddb3f099074006bc78a7285021654..3f23bf9927466d69b9a72b81a101ef2264013ff3 100644 (file)
@@ -2478,7 +2478,7 @@ spell_load_lang(char_u *lang)
                                        "spell/%s.%s.spl",
 #endif
                                                           lang, spell_enc());
-       r = do_in_runtimepath(fname_enc, FALSE, spell_load_cb, &sl);
+       r = do_in_runtimepath(fname_enc, 0, spell_load_cb, &sl);
 
        if (r == FAIL && *sl.sl_lang != NUL)
        {
@@ -2490,7 +2490,7 @@ spell_load_lang(char_u *lang)
                                                  "spell/%s.ascii.spl",
 #endif
                                                                        lang);
-           r = do_in_runtimepath(fname_enc, FALSE, spell_load_cb, &sl);
+           r = do_in_runtimepath(fname_enc, 0, spell_load_cb, &sl);
 
 #ifdef FEAT_AUTOCMD
            if (r == FAIL && *sl.sl_lang != NUL && round == 1
@@ -2519,7 +2519,7 @@ spell_load_lang(char_u *lang)
     {
        /* At least one file was loaded, now load ALL the additions. */
        STRCPY(fname_enc + STRLEN(fname_enc) - 3, "add.spl");
-       do_in_runtimepath(fname_enc, TRUE, spell_load_cb, &sl);
+       do_in_runtimepath(fname_enc, DIP_ALL, spell_load_cb, &sl);
     }
 }
 
index ac80ab4e73c836f9cc72b0b4c0169d4eed1199e6..7d2233a988063ac1760ff29d2ec9112bb6d1bc6f 100644 (file)
@@ -4813,7 +4813,7 @@ syn_cmd_include(exarg_T *eap, int syncing UNUSED)
     prev_toplvl_grp = curwin->w_s->b_syn_topgrp;
     curwin->w_s->b_syn_topgrp = sgl_id;
     if (source ? do_source(eap->arg, FALSE, DOSO_NONE) == FAIL
-                               : source_runtime(eap->arg, TRUE) == FAIL)
+                               : source_runtime(eap->arg, DIP_ALL) == FAIL)
        EMSG2(_(e_notopen), eap->arg);
     curwin->w_s->b_syn_topgrp = prev_toplvl_grp;
     current_syn_inc_tag = prev_syn_inc_tag;
@@ -7075,7 +7075,7 @@ init_highlight(
        else
        {
            ++recursive;
-           (void)source_runtime((char_u *)"syntax/syncolor.vim", TRUE);
+           (void)source_runtime((char_u *)"syntax/syncolor.vim", DIP_ALL);
            --recursive;
        }
     }
@@ -7104,7 +7104,7 @@ load_colors(char_u *name)
     if (buf != NULL)
     {
        sprintf((char *)buf, "colors/%s.vim", name);
-       retval = source_runtime(buf, FALSE);
+       retval = source_runtime(buf, DIP_START + DIP_OPT);
        vim_free(buf);
 #ifdef FEAT_AUTOCMD
        apply_autocmds(EVENT_COLORSCHEME, name, curbuf->b_fname, FALSE, curbuf);
index d2fdee6ae990eaf7f38046138b4f20ef08c54cd8..154125950d485c28942bd936fd7848cf8e448a2f 100644 (file)
--- a/src/tag.c
+++ b/src/tag.c
@@ -2638,7 +2638,7 @@ get_tagfname(
 #else
                    "doc/tags"
 #endif
-                                             , TRUE, found_tagfile_cb, NULL);
+                                          , DIP_ALL, found_tagfile_cb, NULL);
        }
 
        if (tnp->tn_hf_idx >= tag_fnames.ga_len)
index 008bb937053ccdc8aa85813aec818a96618c262f..3ca8375fc903cfee266c1856ba4b402114334bbf 100644 (file)
@@ -114,3 +114,23 @@ func Test_helptags()
   let tags2 = readfile(docdir2 . '/tags') 
   call assert_true(tags2[0] =~ 'look-away')
 endfunc
+
+func Test_colorscheme()
+  let colordirrun = &packpath . '/runtime/colors'
+  let colordirstart = &packpath . '/pack/mine/start/foo/colors'
+  let colordiropt = &packpath . '/pack/mine/opt/bar/colors'
+  call mkdir(colordirrun, 'p')
+  call mkdir(colordirstart, 'p')
+  call mkdir(colordiropt, 'p')
+  call writefile(['let g:found_one = 1'], colordirrun . '/one.vim')
+  call writefile(['let g:found_two = 1'], colordirstart . '/two.vim')
+  call writefile(['let g:found_three = 1'], colordiropt . '/three.vim')
+  exe 'set rtp=' . &packpath . '/runtime'
+
+  colorscheme one
+  call assert_equal(1, g:found_one)
+  colorscheme two
+  call assert_equal(1, g:found_two)
+  colorscheme three
+  call assert_equal(1, g:found_three)
+endfunc
index 5d142703a6c143759b6f4c150cf31b38f41b31c4..d77d4805bc295ba309b2269c84d61d6baf81f8f2 100644 (file)
@@ -743,6 +743,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1552,
 /**/
     1551,
 /**/
index ea3c498bae78dd49bc4562ac3ed0b742f5bd0d98..becc26a692c630c016c3cfd049d6c40dc4bfd857 100644 (file)
--- a/src/vim.h
+++ b/src/vim.h
@@ -2289,8 +2289,10 @@ int vim_main2(int argc, char **argv);
 #endif
 
 /* Used for flags of do_in_path() */
-#define DIP_ALL        1       /* all matches, not just the first one */
-#define DIP_DIR        2       /* find directories instead of files. */
-#define DIP_ERR        4       /* give an error message when none found. */
+#define DIP_ALL            0x01        /* all matches, not just the first one */
+#define DIP_DIR            0x02        /* find directories instead of files. */
+#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' */
 
 #endif /* VIM__H */