@@ -2918,8 +2918,7 @@ source_callback(char_u *fname, void *cookie UNUSED)
29182918/*
29192919 * Source the file "name" from all directories in 'runtimepath'.
29202920 * "name" can contain wildcards.
2921- * When "flags" has DIP_ALL: source all files, otherwise only the first one.
2922- * When "flags" has DIP_DIR: find directories instead of files.
2921+ * When "all" is TRUE: source all files, otherwise only the first one.
29232922 *
29242923 * return FAIL when no file could be sourced, OK otherwise.
29252924 */
@@ -2931,7 +2930,18 @@ source_runtime(char_u *name, int all)
29312930
29322931#define DIP_ALL 1 /* all matches, not just the first one */
29332932#define DIP_DIR 2 /* find directories instead of files. */
2933+ #define DIP_ERR 4 /* give an error message when none found. */
29342934
2935+ /*
2936+ * Find the file "name" in all directories in "path" and invoke
2937+ * "callback(fname, cookie)".
2938+ * "name" can contain wildcards.
2939+ * When "flags" has DIP_ALL: source all files, otherwise only the first one.
2940+ * When "flags" has DIP_DIR: find directories instead of files.
2941+ * When "flags" has DIP_ERR: give an error message if there is no match.
2942+ *
2943+ * return FAIL when no file could be sourced, OK otherwise.
2944+ */
29352945 static int
29362946do_in_path (
29372947 char_u * path ,
@@ -3022,11 +3032,18 @@ do_in_path(
30223032 }
30233033 vim_free (buf );
30243034 vim_free (rtp_copy );
3025- if (p_verbose > 0 && !did_one && name != NULL )
3035+ if (!did_one && name != NULL )
30263036 {
3027- verbose_enter ();
3028- smsg ((char_u * )_ ("not found in 'runtimepath': \"%s\"" ), name );
3029- verbose_leave ();
3037+ char * basepath = path == p_rtp ? "runtimepath" : "packpath" ;
3038+
3039+ if (flags & DIP_ERR )
3040+ EMSG3 (_ (e_dirnotf ), basepath , name );
3041+ else if (p_verbose > 0 )
3042+ {
3043+ verbose_enter ();
3044+ smsg ((char_u * )_ ("not found in '%s': \"%s\"" ), basepath , name );
3045+ verbose_leave ();
3046+ }
30303047 }
30313048
30323049#ifdef AMIGA
@@ -3178,8 +3195,8 @@ add_pack_plugin(char_u *fname, void *cookie)
31783195 void
31793196source_packages ()
31803197{
3181- do_in_path (p_pp , (char_u * )"pack/*/ever/*" ,
3182- DIP_ALL + DIP_DIR , add_pack_plugin , p_pp );
3198+ do_in_path (p_pp , (char_u * )"pack/*/ever/*" , DIP_ALL + DIP_DIR ,
3199+ add_pack_plugin , p_pp );
31833200}
31843201
31853202/*
@@ -3197,8 +3214,8 @@ ex_packadd(exarg_T *eap)
31973214 if (pat == NULL )
31983215 return ;
31993216 vim_snprintf (pat , len , plugpat , eap -> arg );
3200- do_in_path (p_pp , (char_u * )pat , DIP_ALL + DIP_DIR , add_pack_plugin ,
3201- eap -> forceit ? NULL : p_pp );
3217+ do_in_path (p_pp , (char_u * )pat , DIP_ALL + DIP_DIR + DIP_ERR ,
3218+ add_pack_plugin , eap -> forceit ? NULL : p_pp );
32023219 vim_free (pat );
32033220}
32043221
0 commit comments