On Sun, Feb 1, 2009 at 5:12 PM, Nazri Ramliy <[email protected]> wrote:
> Hello all,
> The patch is against the latest pull from repo.or.cz's vim repository.
> Patch it with -p1 from your ~/src/vim.

Eek! Please use this patch instead as the previous one contains two
unnecessary hunks that modified misc2.c and os_msdos.c (hehe).

Now I'll go back to my cave.

nazri.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

commit 90a9446256817373de26541845be18842846528f
Author: Nazri Ramliy <[email protected]>
Date:   Sun Feb 1 15:36:01 2009 +0800

    Expand files found in 'path' for :find and :sfind

diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index b5d76c1..b747388 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -3422,6 +3422,10 @@ set_one_cmd_context(xp, buff)
  */
     switch (ea.cmdidx)
     {
+	case CMD_find:
+	case CMD_sfind:
+	    xp->xp_context = EXPAND_FILES_IN_PATH;
+	    break;
 	case CMD_cd:
 	case CMD_chdir:
 	case CMD_lcd:
diff --git a/src/ex_getln.c b/src/ex_getln.c
index e324e7e..c09985b 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -4063,6 +4063,7 @@ addstar(fname, len, context)
     char_u	*tail;
 
     if (context != EXPAND_FILES
+	    && context != EXPAND_FILES_IN_PATH
 	    && context != EXPAND_SHELLCMD
 	    && context != EXPAND_DIRECTORIES)
     {
@@ -4377,7 +4378,9 @@ ExpandFromContext(xp, pat, num_file, file, options)
     if (options & WILD_SILENT)
 	flags |= EW_SILENT;
 
-    if (xp->xp_context == EXPAND_FILES || xp->xp_context == EXPAND_DIRECTORIES)
+    if (xp->xp_context == EXPAND_FILES
+	    || xp->xp_context == EXPAND_DIRECTORIES
+	    || xp->xp_context == EXPAND_FILES_IN_PATH)
     {
 	/*
 	 * Expand file or directory names.
@@ -4407,6 +4410,8 @@ ExpandFromContext(xp, pat, num_file, file, options)
 
 	if (xp->xp_context == EXPAND_FILES)
 	    flags |= EW_FILE;
+	else if (xp->xp_context == EXPAND_FILES_IN_PATH)
+	    flags |= (EW_FILE | EW_PATH);
 	else
 	    flags = (flags | EW_DIR) & ~EW_FILE;
 	ret = expand_wildcards(1, &pat, num_file, file, flags);
diff --git a/src/misc1.c b/src/misc1.c
index 0487290..d2aa91d 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -9205,7 +9205,65 @@ gen_expand_wildcards(num_pat, pat, num_file, file, flags)
 	     * when EW_NOTFOUND is given.
 	     */
 	    if (mch_has_exp_wildcard(p))
-		add_pat = mch_expandpath(&ga, p, flags);
+	    {
+		if (flags & EW_PATH)
+		{
+		    /* Expand stuff in each 'path' values */
+		    int dcount;
+		    char_u **dnames;
+		    char_u *cwd_orig;
+		    char_u *cwd;
+		    char_u *dir;
+		    char_u *path_option = *curbuf->b_p_path == NUL ? 
+						    p_path : curbuf->b_p_path;
+		    int c = 0;
+
+		    if ((cwd_orig = alloc((int)(MAXPATHL))) == NULL ||
+			(cwd = alloc((int)(MAXPATHL))) == NULL ||
+		        (dir = alloc((int)(MAXPATHL))) == NULL)
+		        mch_exit(0);
+
+		    if (getcwd((char *)cwd_orig, MAXPATHL) == NULL)
+			/* Ignore it */ ;
+
+		    for(;;)
+		    {
+			STRCPY(cwd, cwd_orig);
+
+			dir[0] = 0;
+			copy_option_part(&path_option, dir, MAXPATHL, " ;,");
+			    STRCPY(cwd, dir);
+
+			if (!mch_isFullName(dir))
+			{
+			    char_u *joined;
+			    joined = concat_fnames(cwd_orig, dir, TRUE);
+			    STRNCPY(cwd, joined, MAXPATHL);
+			    vim_free(joined);
+			} else {
+			    STRCPY(cwd, dir);
+			}
+
+			if (mch_chdir(cwd) == 0)
+			    c += mch_expandpath(&ga, p, flags);
+
+			if (path_option == NULL || *path_option == NUL)
+			    break;
+		    }
+
+		    add_pat  = c;
+		    if (mch_chdir(cwd_orig) != 0)
+			/* Ignore it */ ;
+
+		    vim_free(dir);
+		    vim_free(cwd);
+		    vim_free(cwd_orig);
+		}
+		else
+		{
+		    add_pat = mch_expandpath(&ga, p, flags);
+		}
+	    }
 	}
 
 	if (add_pat == -1 || (add_pat == 0 && (flags & EW_NOTFOUND)))
diff --git a/src/vim.h b/src/vim.h
index 0a979e4..70d2cdd 100644
--- a/src/vim.h
+++ b/src/vim.h
@@ -708,6 +708,7 @@ extern char *(*dyn_libintl_textdomain)(const char *domainname);
 #define EXPAND_USER_DEFINED	30
 #define EXPAND_USER_LIST	31
 #define EXPAND_SHELLCMD		32
+#define EXPAND_FILES_IN_PATH    33
 
 /* Values for exmode_active (0 is no exmode) */
 #define EXMODE_NORMAL		1
@@ -739,6 +740,7 @@ extern char *(*dyn_libintl_textdomain)(const char *domainname);
 #define EW_KEEPALL	0x10	/* keep all matches */
 #define EW_SILENT	0x20	/* don't print "1 returned" from shell */
 #define EW_EXEC		0x40	/* executable files */
+#define EW_PATH		0x80	/* search in 'path' too */
 /* Note: mostly EW_NOTFOUND and EW_SILENT are mutually exclusive: EW_NOTFOUND
  * is used when executing commands and EW_SILENT for interactive expanding. */
 

Raspunde prin e-mail lui