vim-patch:7.4.1499

Problem:    No error message when :packadd does not find anything.
Solution:   Add an error message. (Hirohito Higashi)

be82c25486
This commit is contained in:
James McCoy
2016-06-20 10:12:07 -04:00
parent 85e539c996
commit 8ecdc571b0
6 changed files with 29 additions and 10 deletions

View File

@@ -2277,8 +2277,7 @@ static void source_callback(char_u *fname, void *cookie)
/// 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.
/// When "flags" has DIP_DIR: find directories instead of files.
/// 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)
@@ -2288,7 +2287,16 @@ int source_runtime(char_u *name, int all)
#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.
/// Find the file "name" in all directories in "path" and invoke
/// "callback(fname, cookie)".
/// "name" can contain wildcards.
/// When "flags" has DIP_ALL: source all files, otherwise only the first one.
/// When "flags" has DIP_DIR: find directories instead of files.
/// When "flags" has DIP_ERR: give an error message if there is no match.
///
/// return FAIL when no file could be sourced, OK otherwise.
static int do_in_path(char_u *path, char_u *name, int flags,
DoInRuntimepathCB callback, void *cookie)
{
@@ -2357,10 +2365,16 @@ static int do_in_path(char_u *path, char_u *name, int flags,
}
xfree(buf);
xfree(rtp_copy);
if (p_verbose > 0 && !did_one && name != NULL) {
verbose_enter();
smsg(_("not found in 'runtimepath': \"%s\""), name);
verbose_leave();
if (!did_one && name != NULL) {
char *basepath = path == p_rtp ? "runtimepath" : "packpath";
if (flags & DIP_ERR) {
EMSG3(_(e_dirnotf), basepath, name);
} else if (p_verbose > 0) {
verbose_enter();
smsg(_("not found in '%s': \"%s\""), basepath, name);
verbose_leave();
}
}
@@ -2497,7 +2511,7 @@ void ex_packadd(exarg_T *eap)
size_t len = STRLEN(plugpat) + STRLEN(eap->arg);
char *pat = (char *)xmallocz(len);
vim_snprintf(pat, len, plugpat, eap->arg);
do_in_path(p_pp, (char_u *)pat, DIP_ALL + DIP_DIR, add_pack_plugin,
do_in_path(p_pp, (char_u *)pat, DIP_ALL + DIP_DIR + DIP_ERR, add_pack_plugin,
eap->forceit ? NULL : p_pp);
xfree(pat);
}