aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_cmds2.c
diff options
context:
space:
mode:
authorJames McCoy <jamessan@jamessan.com>2016-06-20 10:12:07 -0400
committerJames McCoy <jamessan@jamessan.com>2016-07-08 01:43:36 -0400
commit8ecdc571b0cf679c5195088d140f2988bcbe87e1 (patch)
treeb8b19e35a0d0109c3a366af490f09dac135b47d0 /src/nvim/ex_cmds2.c
parent85e539c99609cec0b5a0eab3aded394d0bbab555 (diff)
downloadrneovim-8ecdc571b0cf679c5195088d140f2988bcbe87e1.tar.gz
rneovim-8ecdc571b0cf679c5195088d140f2988bcbe87e1.tar.bz2
rneovim-8ecdc571b0cf679c5195088d140f2988bcbe87e1.zip
vim-patch:7.4.1499
Problem: No error message when :packadd does not find anything. Solution: Add an error message. (Hirohito Higashi) https://github.com/vim/vim/commit/be82c254862e475a582c0717455e1db6bf96b0d0
Diffstat (limited to 'src/nvim/ex_cmds2.c')
-rw-r--r--src/nvim/ex_cmds2.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c
index 6bfa494094..8e88a55d41 100644
--- a/src/nvim/ex_cmds2.c
+++ b/src/nvim/ex_cmds2.c
@@ -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);
}