To: vim_dev@googlegroups.com Subject: Patch 7.4.1552 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 7.4.1552 Problem: ":colorscheme" does not use 'packpath'. Solution: Also look in "start" and "opt" directories in 'packpath'. Files: src/ex_cmds2.c, src/gui.c, src/hardcopy.c, src/os_mswin.c, src/spell.c, src/tag.c, src/if_py_both.h, src/vim.h, src/digraph.c, src/eval.c, src/ex_docmd.c, src/main.c, src/option.c, src/syntax.c, src/testdir/test_packadd.vim *** ../vim-7.4.1551/src/ex_cmds2.c 2016-03-12 21:28:22.238433457 +0100 --- src/ex_cmds2.c 2016-03-12 21:53:03.522920586 +0100 *************** *** 2872,2878 **** do_unlet((char_u *)"b:current_compiler", TRUE); sprintf((char *)buf, "compiler/%s.vim", eap->arg); ! if (source_runtime(buf, TRUE) == FAIL) EMSG2(_("E666: compiler not supported: %s"), eap->arg); vim_free(buf); --- 2872,2878 ---- do_unlet((char_u *)"b:current_compiler", TRUE); sprintf((char *)buf, "compiler/%s.vim", eap->arg); ! if (source_runtime(buf, DIP_ALL) == FAIL) EMSG2(_("E666: compiler not supported: %s"), eap->arg); vim_free(buf); *************** *** 2906,2912 **** void ex_runtime(exarg_T *eap) { ! source_runtime(eap->arg, eap->forceit); } static void --- 2906,2912 ---- void ex_runtime(exarg_T *eap) { ! source_runtime(eap->arg, eap->forceit ? DIP_ALL : 0); } static void *************** *** 2918,2931 **** /* * 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. * * return FAIL when no file could be sourced, OK otherwise. */ int ! source_runtime(char_u *name, int all) { ! return do_in_runtimepath(name, all, source_callback, NULL); } /* --- 2918,2931 ---- /* * Source the file "name" from all directories in 'runtimepath'. * "name" can contain wildcards. ! * 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 flags) { ! return do_in_runtimepath(name, flags, source_callback, NULL); } /* *************** *** 3052,3059 **** /* * 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. * Returns OK when at least one match found, FAIL otherwise. * * If "name" is NULL calls callback for each entry in runtimepath. Cookie is --- 3052,3059 ---- /* * Find "name" in 'runtimepath'. When found, invoke the callback function for * it: callback(fname, "cookie") ! * 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,3073 **** int do_in_runtimepath( char_u *name, ! int all, void (*callback)(char_u *fname, void *ck), void *cookie) { ! return do_in_path(p_rtp, name, all ? DIP_ALL : 0, callback, cookie); } /* --- 3063,3103 ---- int do_in_runtimepath( char_u *name, ! int flags, void (*callback)(char_u *fname, void *ck), void *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; } /* *** ../vim-7.4.1551/src/gui.c 2016-03-11 22:52:00.734438114 +0100 --- src/gui.c 2016-03-12 21:37:40.616582020 +0100 *************** *** 4988,4994 **** 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 || *buffer == NUL) return FAIL; return OK; --- 4988,4994 ---- if (STRLEN(name) > MAXPATHL - 14) return FAIL; vim_snprintf((char *)buffer, MAXPATHL, "bitmaps/%s.%s", name, ext); ! if (do_in_runtimepath(buffer, 0, gfp_setname, buffer) == FAIL || *buffer == NUL) return FAIL; return OK; *** ../vim-7.4.1551/src/hardcopy.c 2016-01-30 17:24:01.798502450 +0100 --- src/hardcopy.c 2016-03-12 21:37:45.388532045 +0100 *************** *** 1741,1747 **** 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, resource->filename) && resource->filename[0] != NUL); vim_free(buffer); --- 1741,1747 ---- vim_strcat(buffer, (char_u *)name, MAXPATHL); vim_strcat(buffer, (char_u *)".ps", MAXPATHL); resource->filename[0] = NUL; ! retval = (do_in_runtimepath(buffer, 0, prt_resource_name, resource->filename) && resource->filename[0] != NUL); vim_free(buffer); *** ../vim-7.4.1551/src/os_mswin.c 2016-03-11 22:52:00.738438072 +0100 --- src/os_mswin.c 2016-03-12 21:37:59.824380860 +0100 *************** *** 950,956 **** mch_icon_load(HANDLE *iconp) { return do_in_runtimepath((char_u *)"bitmaps/vim.ico", ! FALSE, mch_icon_load_cb, iconp); } int --- 950,956 ---- mch_icon_load(HANDLE *iconp) { return do_in_runtimepath((char_u *)"bitmaps/vim.ico", ! 0, mch_icon_load_cb, iconp); } int *** ../vim-7.4.1551/src/spell.c 2016-01-30 21:10:05.001342579 +0100 --- src/spell.c 2016-03-12 21:38:35.916002887 +0100 *************** *** 2478,2484 **** "spell/%s.%s.spl", #endif lang, spell_enc()); ! r = do_in_runtimepath(fname_enc, FALSE, spell_load_cb, &sl); if (r == FAIL && *sl.sl_lang != NUL) { --- 2478,2484 ---- "spell/%s.%s.spl", #endif lang, spell_enc()); ! r = do_in_runtimepath(fname_enc, 0, spell_load_cb, &sl); if (r == FAIL && *sl.sl_lang != NUL) { *************** *** 2490,2496 **** "spell/%s.ascii.spl", #endif lang); ! r = do_in_runtimepath(fname_enc, FALSE, spell_load_cb, &sl); #ifdef FEAT_AUTOCMD if (r == FAIL && *sl.sl_lang != NUL && round == 1 --- 2490,2496 ---- "spell/%s.ascii.spl", #endif lang); ! r = do_in_runtimepath(fname_enc, 0, spell_load_cb, &sl); #ifdef FEAT_AUTOCMD if (r == FAIL && *sl.sl_lang != NUL && round == 1 *************** *** 2519,2525 **** { /* 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); } } --- 2519,2525 ---- { /* 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, DIP_ALL, spell_load_cb, &sl); } } *** ../vim-7.4.1551/src/tag.c 2016-01-30 21:10:05.005342537 +0100 --- src/tag.c 2016-03-12 21:38:53.491818826 +0100 *************** *** 2638,2644 **** #else "doc/tags" #endif ! , TRUE, found_tagfile_cb, NULL); } if (tnp->tn_hf_idx >= tag_fnames.ga_len) --- 2638,2644 ---- #else "doc/tags" #endif ! , DIP_ALL, found_tagfile_cb, NULL); } if (tnp->tn_hf_idx >= tag_fnames.ga_len) *** ../vim-7.4.1551/src/if_py_both.h 2016-02-06 19:57:11.601323655 +0100 --- src/if_py_both.h 2016-03-12 21:39:15.895584207 +0100 *************** *** 1061,1067 **** data.callable = callable; data.result = NULL; ! do_in_runtimepath(NULL, FALSE, &map_rtp_callback, &data); if (data.result == NULL) { --- 1061,1067 ---- data.callable = callable; data.result = NULL; ! do_in_runtimepath(NULL, 0, &map_rtp_callback, &data); if (data.result == NULL) { *************** *** 1150,1156 **** if (!(ret = PyList_New(0))) return NULL; ! do_in_runtimepath(NULL, FALSE, &map_finder_callback, ret); if (PyErr_Occurred()) { --- 1150,1156 ---- if (!(ret = PyList_New(0))) return NULL; ! do_in_runtimepath(NULL, 0, &map_finder_callback, ret); if (PyErr_Occurred()) { *** ../vim-7.4.1551/src/vim.h 2016-03-12 21:28:22.238433457 +0100 --- src/vim.h 2016-03-12 22:10:01.404271300 +0100 *************** *** 2289,2296 **** #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. */ #endif /* VIM__H */ --- 2289,2298 ---- #endif /* Used for flags of do_in_path() */ ! #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 */ *** ../vim-7.4.1551/src/digraph.c 2016-02-23 14:52:31.869232337 +0100 --- src/digraph.c 2016-03-12 21:42:07.613786048 +0100 *************** *** 2320,2332 **** /* 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) # 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) { vim_free(buf); return (char_u *)N_("E544: Keymap file not found"); --- 2320,2332 ---- /* 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, 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, 0) == FAIL) { vim_free(buf); return (char_u *)N_("E544: Keymap file not found"); *** ../vim-7.4.1551/src/eval.c 2016-03-12 19:03:28.213328900 +0100 --- src/eval.c 2016-03-12 21:42:12.729732480 +0100 *************** *** 23942,23948 **** } /* Try loading the package from $VIMRUNTIME/autoload/.vim */ ! if (source_runtime(scriptname, FALSE) == OK) ret = TRUE; } --- 23942,23948 ---- } /* Try loading the package from $VIMRUNTIME/autoload/.vim */ ! if (source_runtime(scriptname, 0) == OK) ret = TRUE; } *** ../vim-7.4.1551/src/ex_docmd.c 2016-03-05 17:41:43.105189030 +0100 --- src/ex_docmd.c 2016-03-12 21:43:27.080953973 +0100 *************** *** 11777,11792 **** { if (*arg == 'o' || !filetype_detect) { ! source_runtime((char_u *)FILETYPE_FILE, TRUE); filetype_detect = TRUE; if (plugin) { ! source_runtime((char_u *)FTPLUGIN_FILE, TRUE); filetype_plugin = TRUE; } if (indent) { ! source_runtime((char_u *)INDENT_FILE, TRUE); filetype_indent = TRUE; } } --- 11777,11792 ---- { if (*arg == 'o' || !filetype_detect) { ! source_runtime((char_u *)FILETYPE_FILE, DIP_ALL); filetype_detect = TRUE; if (plugin) { ! source_runtime((char_u *)FTPLUGIN_FILE, DIP_ALL); filetype_plugin = TRUE; } if (indent) { ! source_runtime((char_u *)INDENT_FILE, DIP_ALL); filetype_indent = TRUE; } } *************** *** 11802,11819 **** { if (plugin) { ! source_runtime((char_u *)FTPLUGOF_FILE, TRUE); filetype_plugin = FALSE; } if (indent) { ! source_runtime((char_u *)INDOFF_FILE, TRUE); filetype_indent = FALSE; } } else { ! source_runtime((char_u *)FTOFF_FILE, TRUE); filetype_detect = FALSE; } } --- 11802,11819 ---- { if (plugin) { ! source_runtime((char_u *)FTPLUGOF_FILE, DIP_ALL); filetype_plugin = FALSE; } if (indent) { ! source_runtime((char_u *)INDOFF_FILE, DIP_ALL); filetype_indent = FALSE; } } else { ! source_runtime((char_u *)FTOFF_FILE, DIP_ALL); filetype_detect = FALSE; } } *** ../vim-7.4.1551/src/main.c 2016-03-12 20:34:22.820382141 +0100 --- src/main.c 2016-03-12 21:43:36.668853585 +0100 *************** *** 628,636 **** if (p_lpl) { # ifdef VMS /* Somehow VMS doesn't handle the "**". */ ! source_runtime((char_u *)"plugin/*.vim", TRUE); # else ! source_runtime((char_u *)"plugin/**/*.vim", TRUE); # endif TIME_MSG("loading plugins"); --- 628,636 ---- if (p_lpl) { # ifdef VMS /* Somehow VMS doesn't handle the "**". */ ! source_runtime((char_u *)"plugin/*.vim", DIP_ALL); # else ! source_runtime((char_u *)"plugin/**/*.vim", DIP_ALL); # endif TIME_MSG("loading plugins"); *** ../vim-7.4.1551/src/option.c 2016-02-23 14:52:31.889232130 +0100 --- src/option.c 2016-03-12 21:43:49.568718519 +0100 *************** *** 7290,7296 **** if (vim_strchr((char_u *)"_.,", *p) != NULL) break; vim_snprintf((char *)fname, 200, "spell/%.*s.vim", (int)(p - q), q); ! source_runtime(fname, TRUE); } #endif } --- 7290,7296 ---- if (vim_strchr((char_u *)"_.,", *p) != NULL) break; vim_snprintf((char *)fname, 200, "spell/%.*s.vim", (int)(p - q), q); ! source_runtime(fname, DIP_ALL); } #endif } *** ../vim-7.4.1551/src/syntax.c 2016-03-12 19:22:43.781293285 +0100 --- src/syntax.c 2016-03-12 21:44:58.683994990 +0100 *************** *** 4813,4819 **** 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) EMSG2(_(e_notopen), eap->arg); curwin->w_s->b_syn_topgrp = prev_toplvl_grp; current_syn_inc_tag = prev_syn_inc_tag; --- 4813,4819 ---- 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, 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,7081 **** else { ++recursive; ! (void)source_runtime((char_u *)"syntax/syncolor.vim", TRUE); --recursive; } } --- 7075,7081 ---- else { ++recursive; ! (void)source_runtime((char_u *)"syntax/syncolor.vim", DIP_ALL); --recursive; } } *************** *** 7104,7110 **** if (buf != NULL) { sprintf((char *)buf, "colors/%s.vim", name); ! retval = source_runtime(buf, FALSE); vim_free(buf); #ifdef FEAT_AUTOCMD apply_autocmds(EVENT_COLORSCHEME, name, curbuf->b_fname, FALSE, curbuf); --- 7104,7110 ---- if (buf != NULL) { sprintf((char *)buf, "colors/%s.vim", name); ! retval = source_runtime(buf, DIP_START + DIP_OPT); vim_free(buf); #ifdef FEAT_AUTOCMD apply_autocmds(EVENT_COLORSCHEME, name, curbuf->b_fname, FALSE, curbuf); *** ../vim-7.4.1551/src/testdir/test_packadd.vim 2016-03-12 21:28:22.238433457 +0100 --- src/testdir/test_packadd.vim 2016-03-12 22:04:05.247996917 +0100 *************** *** 114,116 **** --- 114,136 ---- 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 *** ../vim-7.4.1551/src/version.c 2016-03-12 21:28:22.242433415 +0100 --- src/version.c 2016-03-12 21:54:14.350179409 +0100 *************** *** 745,746 **** --- 745,748 ---- { /* Add new patch number below this line */ + /**/ + 1552, /**/ -- What a wonderfully exciting cough! Do you mind if I join you? -- Douglas Adams, "The Hitchhiker's Guide to the Galaxy" /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///