comparison src/ex_cmds2.c @ 8524:2f57bbe870ea v7.4.1552

commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f Author: Bram Moolenaar <Bram@vim.org> Date: Sat Mar 12 22:11:39 2016 +0100 patch 7.4.1552 Problem: ":colorscheme" does not use 'packpath'. Solution: Also use in "start" and "opt" directories in 'packpath'.
author Christian Brabandt <cb@256bit.org>
date Sat, 12 Mar 2016 22:15:05 +0100
parents 721e8d6cb7b5
children 981cc3bef9f3
comparison
equal deleted inserted replaced
8523:299f84e1e738 8524:2f57bbe870ea
2870 } 2870 }
2871 do_unlet((char_u *)"g:current_compiler", TRUE); 2871 do_unlet((char_u *)"g:current_compiler", TRUE);
2872 do_unlet((char_u *)"b:current_compiler", TRUE); 2872 do_unlet((char_u *)"b:current_compiler", TRUE);
2873 2873
2874 sprintf((char *)buf, "compiler/%s.vim", eap->arg); 2874 sprintf((char *)buf, "compiler/%s.vim", eap->arg);
2875 if (source_runtime(buf, TRUE) == FAIL) 2875 if (source_runtime(buf, DIP_ALL) == FAIL)
2876 EMSG2(_("E666: compiler not supported: %s"), eap->arg); 2876 EMSG2(_("E666: compiler not supported: %s"), eap->arg);
2877 vim_free(buf); 2877 vim_free(buf);
2878 2878
2879 do_cmdline_cmd((char_u *)":delcommand CompilerSet"); 2879 do_cmdline_cmd((char_u *)":delcommand CompilerSet");
2880 2880
2904 * ":runtime {name}" 2904 * ":runtime {name}"
2905 */ 2905 */
2906 void 2906 void
2907 ex_runtime(exarg_T *eap) 2907 ex_runtime(exarg_T *eap)
2908 { 2908 {
2909 source_runtime(eap->arg, eap->forceit); 2909 source_runtime(eap->arg, eap->forceit ? DIP_ALL : 0);
2910 } 2910 }
2911 2911
2912 static void 2912 static void
2913 source_callback(char_u *fname, void *cookie UNUSED) 2913 source_callback(char_u *fname, void *cookie UNUSED)
2914 { 2914 {
2916 } 2916 }
2917 2917
2918 /* 2918 /*
2919 * Source the file "name" from all directories in 'runtimepath'. 2919 * Source the file "name" from all directories in 'runtimepath'.
2920 * "name" can contain wildcards. 2920 * "name" can contain wildcards.
2921 * When "all" is TRUE: source all files, otherwise only the first one. 2921 * When "flags" has DIP_ALL: source all files, otherwise only the first one.
2922 * 2922 *
2923 * return FAIL when no file could be sourced, OK otherwise. 2923 * return FAIL when no file could be sourced, OK otherwise.
2924 */ 2924 */
2925 int 2925 int
2926 source_runtime(char_u *name, int all) 2926 source_runtime(char_u *name, int flags)
2927 { 2927 {
2928 return do_in_runtimepath(name, all, source_callback, NULL); 2928 return do_in_runtimepath(name, flags, source_callback, NULL);
2929 } 2929 }
2930 2930
2931 /* 2931 /*
2932 * Find the file "name" in all directories in "path" and invoke 2932 * Find the file "name" in all directories in "path" and invoke
2933 * "callback(fname, cookie)". 2933 * "callback(fname, cookie)".
3050 } 3050 }
3051 3051
3052 /* 3052 /*
3053 * Find "name" in 'runtimepath'. When found, invoke the callback function for 3053 * Find "name" in 'runtimepath'. When found, invoke the callback function for
3054 * it: callback(fname, "cookie") 3054 * it: callback(fname, "cookie")
3055 * When "all" is TRUE repeat for all matches, otherwise only the first one is 3055 * When "flags" has DIP_ALL repeat for all matches, otherwise only the first
3056 * used. 3056 * one is used.
3057 * Returns OK when at least one match found, FAIL otherwise. 3057 * Returns OK when at least one match found, FAIL otherwise.
3058 * 3058 *
3059 * If "name" is NULL calls callback for each entry in runtimepath. Cookie is 3059 * If "name" is NULL calls callback for each entry in runtimepath. Cookie is
3060 * passed by reference in this case, setting it to NULL indicates that callback 3060 * passed by reference in this case, setting it to NULL indicates that callback
3061 * has done its job. 3061 * has done its job.
3062 */ 3062 */
3063 int 3063 int
3064 do_in_runtimepath( 3064 do_in_runtimepath(
3065 char_u *name, 3065 char_u *name,
3066 int all, 3066 int flags,
3067 void (*callback)(char_u *fname, void *ck), 3067 void (*callback)(char_u *fname, void *ck),
3068 void *cookie) 3068 void *cookie)
3069 { 3069 {
3070 return do_in_path(p_rtp, name, all ? DIP_ALL : 0, callback, cookie); 3070 int done;
3071 char_u *s;
3072 int len;
3073 char *start_dir = "pack/*/start/*/%s";
3074 char *opt_dir = "pack/*/opt/*/%s";
3075
3076 done = do_in_path(p_rtp, name, flags, callback, cookie);
3077
3078 if (done == FAIL && (flags & DIP_START))
3079 {
3080 len = STRLEN(start_dir) + STRLEN(name);
3081 s = alloc(len);
3082 if (s == NULL)
3083 return FAIL;
3084 vim_snprintf((char *)s, len, start_dir, name);
3085 done = do_in_path(p_pp, s, flags, callback, cookie);
3086 vim_free(s);
3087 }
3088
3089 if (done == FAIL && (flags & DIP_OPT))
3090 {
3091 len = STRLEN(opt_dir) + STRLEN(name);
3092 s = alloc(len);
3093 if (s == NULL)
3094 return FAIL;
3095 vim_snprintf((char *)s, len, opt_dir, name);
3096 done = do_in_path(p_pp, s, flags, callback, cookie);
3097 vim_free(s);
3098 }
3099
3100 return done;
3071 } 3101 }
3072 3102
3073 /* 3103 /*
3074 * Expand wildcards in "pat" and invoke do_source() for each match. 3104 * Expand wildcards in "pat" and invoke do_source() for each match.
3075 */ 3105 */