Hi Bram,

On So, 04 Mär 2012, Tim Chase wrote:

> On 03/04/12 00:49, Paul Isambert wrote:
> >howard Schwartz<howard...@gmail.com>  a écrit:
> >>au BufRead * for i in range(1,9) | let @i = "" | endfor
> >
> >You should use ":exe[cute]":
> >
> >   au BufRead * for i in range(1,9) | exe "let @" . i . " = ''" | endfor
> 
> 
> In attempting to answer for this, I reached for
> curly-braces-expansion but discovered it didn't work as expected:
> 
>  :let i=3
>  :let @{i}=''
>  :echo @{i}
> 
> returned an E18 (on the let) and an E15 (on the echo).   If I issue
> 
>  :let i=3
>  :let x{i}=42
>  :echo x3
> 
> it works as expected.  Reading up at
> 
>   :help curly-braces-names
> 
> doesn't give me much insight.  Any takers to tell me it's a bug or
> point out my misunderstanding?

Attached patch fixes it


regards,
Christian

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
diff --git a/src/eval.c b/src/eval.c
--- a/src/eval.c
+++ b/src/eval.c
@@ -2435,13 +2435,29 @@
 	if (op != NULL && (*op == '+' || *op == '-'))
 	    EMSG2(_(e_letwrong), op);
 	else if (endchars != NULL
-			 && vim_strchr(endchars, *skipwhite(arg + 1)) == NULL)
+		&& (vim_strchr(arg, '{') == NULL ||
+		    vim_strchr(arg, '}') == NULL)
+		&& vim_strchr(endchars, *skipwhite(arg + 1)) == NULL)
 	    EMSG(_(e_letunexp));
 	else
 	{
 	    char_u	*ptofree = NULL;
 	    char_u	*s;
 
+	    if (vim_strchr(arg, '{') != NULL
+		&& vim_strchr(arg, '}') != NULL)
+	    {
+		/* brace expansion */
+		char_u *alias;
+		int l = 0;
+
+		l = get_name_len(&arg, &alias, TRUE, TRUE);
+		if (alias != NULL)
+		    arg = alias;
+		if (l <= 0)
+		    EMSG(_(e_letunexp));
+	    }
+
 	    p = get_tv_string_chk(tv);
 	    if (p != NULL && op != NULL && *op == '.')
 	    {
@@ -5086,6 +5102,20 @@
      * Register contents: @r.
      */
     case '@':	++*arg;
+		if (vim_strchr(*arg, '{') != NULL
+			&& vim_strchr(*arg, '}') != NULL)
+		{
+		    /* brace expansion */
+		    len = get_name_len(arg, &alias, TRUE, TRUE);
+		    if (alias != NULL)
+		      *arg = alias;
+		    if (len <= 0)
+		    {
+			EMSG(_("EXXX: Failed to evaluate '{expr}'"));
+			clear_tv(rettv);
+			ret = FAIL;
+		    }
+		}
 		if (evaluate)
 		{
 		    rettv->v_type = VAR_STRING;

Reply via email to