Bram,
after I run into an error message, that was caused by trying to feed 
back the return value from getmatches() to setmatches() (BTW: it was not 
obvious from the error message what the problem was, because according 
to the documentation this should just work™), I decided to finally fix 
this problem in Vim so not every plugin has to take care of this itself.

I guess, this must have been forgotten, when the matchaddpos() function 
was added.

So here is a patch, that makes setmatches() aware of the matchaddpos() 
function, so it can now be used again to add matches, that have been 
created using the matchaddpos() function.

Best,
Christian

-- 
-- 
You received this message from the "vim_dev" 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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/eval.c b/src/eval.c
--- a/src/eval.c
+++ b/src/eval.c
@@ -17118,6 +17118,7 @@ f_setmatches(argvars, rettv)
     list_T	*l;
     listitem_T	*li;
     dict_T	*d;
+    list_T	*s = NULL;
 
     rettv->vval.v_number = -1;
     if (argvars[0].v_type != VAR_LIST)
@@ -17140,7 +17141,8 @@ f_setmatches(argvars, rettv)
 		return;
 	    }
 	    if (!(dict_find(d, (char_u *)"group", -1) != NULL
-			&& dict_find(d, (char_u *)"pattern", -1) != NULL
+			&& (dict_find(d, (char_u *)"pattern", -1) != NULL ||
+			    dict_find(d, (char_u *)"pos1", -1) != NULL)
 			&& dict_find(d, (char_u *)"priority", -1) != NULL
 			&& dict_find(d, (char_u *)"id", -1) != NULL))
 	    {
@@ -17150,15 +17152,62 @@ f_setmatches(argvars, rettv)
 	    li = li->li_next;
 	}
 
+
 	clear_matches(curwin);
 	li = l->lv_first;
 	while (li != NULL)
 	{
+	    int	    i = 0;
+	    char_u  buf[4];
+	    dictitem_T  *di;
+
 	    d = li->li_tv.vval.v_dict;
-	    match_add(curwin, get_dict_string(d, (char_u *)"group", FALSE),
+
+	    if (!(dict_find(d, (char_u *)"pattern", -1) != NULL))
+	    {
+		if (s == NULL)
+		{
+		    s = list_alloc();
+		    if (s == NULL)
+			return;
+		}
+
+		/* match from matchaddpos() */
+		for (i=1; i<9; i++)
+		{
+		    sprintf((char *)buf, (char *)"pos%d", i);
+		    if ((di = dict_find(d, (char_u *)buf, -1)) != NULL)
+		    {
+			if (s == NULL)
+			{
+			    s = list_alloc();
+			    if (s == NULL)
+				return;
+			}
+			if (di->di_tv.v_type != VAR_LIST)
+			    return;
+
+			list_append_tv(s, &di->di_tv);
+			s->lv_refcount++;
+		    }
+		    else
+			break;
+		}
+	    }
+	    if (!i)
+		match_add(curwin, get_dict_string(d, (char_u *)"group", FALSE),
 		    get_dict_string(d, (char_u *)"pattern", FALSE),
 		    (int)get_dict_number(d, (char_u *)"priority"),
 		    (int)get_dict_number(d, (char_u *)"id"), NULL);
+	    else
+	    {
+		match_add(curwin, get_dict_string(d, (char_u *)"group", FALSE),
+		    NULL, (int)get_dict_number(d, (char_u *)"priority"),
+		    (int)get_dict_number(d, (char_u *)"id"), s);
+		list_unref(s);
+		s = NULL;
+	    }
+
 	    li = li->li_next;
 	}
 	rettv->vval.v_number = 0;

Raspunde prin e-mail lui