On Mi, 08 Mai 2013, Christian Brabandt wrote:

> Updated patch attached. Includes documentation and fixes the issue 
> mentioned so far plus allows setting the w:quickfix_title using 
> setwinvar().

Another update, that fixes failure of test10.

regards,
Christian
-- 
Die Managerkrankheit ist eine Epidemie, die durch den Uhrzeiger
hervorgerufen und durch den Terminkalender übertragen wird.
                -- John Ernst Steinbeck

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -1924,11 +1924,12 @@
 setbufvar( {expr}, {varname}, {val})	set {varname} in buffer {expr} to {val}
 setcmdpos( {pos})		Number	set cursor position in command-line
 setline( {lnum}, {line})	Number	set line {lnum} to {line}
-setloclist( {nr}, {list}[, {action}])
+setloclist( {nr}, {list}[, {action}[, {title}]])
 				Number	modify location list using {list}
 setmatches( {list})		Number	restore a list of matches
 setpos( {expr}, {list})		Number	set the {expr} position to {list}
-setqflist( {list}[, {action}])	Number	modify quickfix list using {list}
+setqflist( {list}[, {action}[, {title}]])
+				Number	modify quickfix list using {list}
 setreg( {n}, {v}[, {opt}])	Number	set register to value and type
 settabvar( {nr}, {varname}, {val})	set {varname} in tab page {nr} to {val}
 settabwinvar( {tabnr}, {winnr}, {varname}, {val})    set {varname} in window
@@ -5200,11 +5201,12 @@
 			:endfor
 <		Note: The '[ and '] marks are not set.
 
-setloclist({nr}, {list} [, {action}])			*setloclist()*
+setloclist({nr}, {list} [, {action}[, {title}]])		*setloclist()*
 		Create or replace or add to the location list for window {nr}.
 		When {nr} is zero the current window is used. For a location
 		list window, the displayed location list is modified.  For an
-		invalid window number {nr}, -1 is returned.
+		invalid window number {nr}, -1 is returned. If {title} is
+		given, it will be stored in the variable |w:quickfix_title|.
 		Otherwise, same as |setqflist()|.
 		Also see |location-list|.
 
@@ -5247,7 +5249,7 @@
 		vertically.  See |winrestview()| for that.
 
 
-setqflist({list} [, {action}])				*setqflist()*
+setqflist({list} [, {action}[, {title}]])			*setqflist()*
 		Create or replace or add to the quickfix list using the items
 		in {list}.  Each item in {list} is a dictionary.
 		Non-dictionary items in {list} are ignored.  Each dictionary
@@ -5284,7 +5286,8 @@
 		list, then a new list is created. If {action} is set to 'r',
 		then the items from the current quickfix list are replaced
 		with the items from {list}. If {action} is not present or is
-		set to ' ', then a new list is created.
+		set to ' ', then a new list is created. If {title} is
+		given, it will be stored in the variable |w:quickfix_title|.
 
 		Returns zero for success, -1 for failure.
 
diff --git a/src/eval.c b/src/eval.c
--- a/src/eval.c
+++ b/src/eval.c
@@ -8057,10 +8057,10 @@
     {"setbufvar",	3, 3, f_setbufvar},
     {"setcmdpos",	1, 1, f_setcmdpos},
     {"setline",		2, 2, f_setline},
-    {"setloclist",	2, 3, f_setloclist},
+    {"setloclist",	2, 4, f_setloclist},
     {"setmatches",	1, 1, f_setmatches},
     {"setpos",		2, 2, f_setpos},
-    {"setqflist",	1, 2, f_setqflist},
+    {"setqflist",	1, 3, f_setqflist},
     {"setreg",		2, 3, f_setreg},
     {"settabvar",	3, 3, f_settabvar},
     {"settabwinvar",	4, 4, f_settabwinvar},
@@ -16375,21 +16375,23 @@
 	appended_lines_mark(lcount, added);
 }
 
-static void set_qf_ll_list __ARGS((win_T *wp, typval_T *list_arg, typval_T *action_arg, typval_T *rettv));
+static void set_qf_ll_list __ARGS((win_T *wp, typval_T *list_arg, typval_T *action_arg, typval_T *title_arg, typval_T *rettv));
 
 /*
  * Used by "setqflist()" and "setloclist()" functions
  */
     static void
-set_qf_ll_list(wp, list_arg, action_arg, rettv)
+set_qf_ll_list(wp, list_arg, action_arg, title_arg, rettv)
     win_T	*wp UNUSED;
     typval_T	*list_arg UNUSED;
     typval_T	*action_arg UNUSED;
+    typval_T	*title_arg UNUSED;
     typval_T	*rettv;
 {
 #ifdef FEAT_QUICKFIX
     char_u	*act;
     int		action = ' ';
+    char_u	*title = NULL;
 #endif
 
     rettv->vval.v_number = -1;
@@ -16409,9 +16411,16 @@
 	    if (*act == 'a' || *act == 'r')
 		action = *act;
 	}
-
-	if (l != NULL && set_errorlist(wp, l, action,
-	       (char_u *)(wp == NULL ? "setqflist()" : "setloclist()")) == OK)
+	if (title_arg->v_type == VAR_STRING)
+	{
+	    title = get_tv_string_chk(title_arg);
+	    if (title == NULL)
+		return;		/* type error; errmsg already given */
+	}
+	if (title == NULL)
+	    title =  (char_u*)(wp == NULL ? "setqflist()" : "setloclist()");
+
+	if (l != NULL && set_errorlist(wp, l, action, title) == OK)
 	    rettv->vval.v_number = 0;
     }
 #endif
@@ -16431,7 +16440,7 @@
 
     win = find_win_by_nr(&argvars[0], NULL);
     if (win != NULL)
-	set_qf_ll_list(win, &argvars[1], &argvars[2], rettv);
+	set_qf_ll_list(win, &argvars[1], &argvars[2], &argvars[3], rettv);
 }
 
 /*
@@ -16546,7 +16555,7 @@
     typval_T	*argvars;
     typval_T	*rettv;
 {
-    set_qf_ll_list(NULL, &argvars[0], &argvars[1], rettv);
+    set_qf_ll_list(NULL, &argvars[0], &argvars[1], &argvars[2], rettv);
 }
 
 /*
@@ -16780,6 +16789,15 @@
 		STRCPY(winvarname, "w:");
 		STRCPY(winvarname + 2, varname);
 		set_var(winvarname, varp, TRUE);
+		if (STRCMP(varname, "quickfix_title") == 0)
+		{
+		    dictitem_T	*v;
+
+		    v = find_var_in_ht(&win->w_vars->dv_hashtab, 'w', varname, FALSE);
+		    if (v != NULL)
+			win_set_qf_title(curwin, (&v->di_tv)->vval.v_string); 
+		}
+
 		vim_free(winvarname);
 	    }
 	}
diff --git a/src/proto/quickfix.pro b/src/proto/quickfix.pro
--- a/src/proto/quickfix.pro
+++ b/src/proto/quickfix.pro
@@ -5,6 +5,7 @@
 void qf_jump __ARGS((qf_info_T *qi, int dir, int errornr, int forceit));
 void qf_list __ARGS((exarg_T *eap));
 void qf_age __ARGS((exarg_T *eap));
+void win_set_qf_title __ARGS((win_T *wp, char_u *title));
 void qf_mark_adjust __ARGS((win_T *wp, linenr_T line1, linenr_T line2, long amount, long amount_after));
 void ex_cwindow __ARGS((exarg_T *eap));
 void ex_cclose __ARGS((exarg_T *eap));
diff --git a/src/quickfix.c b/src/quickfix.c
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -914,13 +914,7 @@
 	qi->qf_curlist = qi->qf_listcount++;
     vim_memset(&qi->qf_lists[qi->qf_curlist], 0, (size_t)(sizeof(qf_list_T)));
     if (qf_title != NULL)
-    {
-	char_u *p = alloc((int)STRLEN(qf_title) + 2);
-
-	qi->qf_lists[qi->qf_curlist].qf_title = p;
-	if (p != NULL)
-	    sprintf((char *)p, ":%s", (char *)qf_title);
-    }
+	qi->qf_lists[qi->qf_curlist].qf_title = vim_strsave(qf_title);
 }
 
 /*
@@ -2588,6 +2582,27 @@
 				    qi->qf_lists[qi->qf_curlist].qf_title);
 }
 
+    void
+win_set_qf_title(wp, title)
+    win_T   *wp;
+    char_u  *title;
+{
+    qf_info_T	*qi;
+
+    if (IS_LL_WINDOW(wp))
+	qi  = wp->w_llist_ref;
+    else if (IS_QF_WINDOW(wp))
+	qi  = &ql_info;
+    else
+	return;
+
+    if (title != NULL)
+    {
+	vim_free(qi->qf_lists[qi->qf_curlist].qf_title);
+	qi->qf_lists[qi->qf_curlist].qf_title = vim_strsave(title);
+    }
+}
+
 /*
  * Fill current buffer with quickfix errors, replacing any previous contents.
  * curbuf must be the quickfix buffer!
@@ -2785,6 +2800,7 @@
     int		res;
 #ifdef FEAT_AUTOCMD
     char_u	*au_name = NULL;
+    char_u	title[130] = ":";
 
     /* Redirect ":grep" to ":vimgrep" if 'grepprg' is "internal". */
     if (grep_internal(eap->cmdidx))
@@ -2857,10 +2873,10 @@
 #endif
 
     res = qf_init(wp, fname, (eap->cmdidx != CMD_make
-			    && eap->cmdidx != CMD_lmake) ? p_gefm : p_efm,
-					   (eap->cmdidx != CMD_grepadd
-					    && eap->cmdidx != CMD_lgrepadd),
-					   *eap->cmdlinep);
+	    && eap->cmdidx != CMD_lmake) ? p_gefm : p_efm,
+		(eap->cmdidx != CMD_grepadd
+		&& eap->cmdidx != CMD_lgrepadd),
+		(char_u *)STRNCAT(title, *eap->cmdlinep, (size_t) 128));
     if (wp != NULL)
 	qi = GET_LOC_LIST(wp);
 #ifdef FEAT_AUTOCMD
@@ -3023,6 +3039,7 @@
 #ifdef FEAT_AUTOCMD
     char_u	*au_name = NULL;
 #endif
+    char_u	title[130] = ":";
 
     if (eap->cmdidx == CMD_lfile || eap->cmdidx == CMD_lgetfile
 					       || eap->cmdidx == CMD_laddfile)
@@ -3068,10 +3085,10 @@
      * quickfix list then a new list is created.
      */
     if (qf_init(wp, p_ef, p_efm, (eap->cmdidx != CMD_caddfile
-				  && eap->cmdidx != CMD_laddfile),
-							   *eap->cmdlinep) > 0
-				  && (eap->cmdidx == CMD_cfile
-					     || eap->cmdidx == CMD_lfile))
+	    && eap->cmdidx != CMD_laddfile),
+	    (char_u*) STRNCAT(title, *eap->cmdlinep, (size_t) 128)) > 0
+	    && (eap->cmdidx == CMD_cfile
+			    || eap->cmdidx == CMD_lfile))
     {
 #ifdef FEAT_AUTOCMD
 	if (au_name != NULL)
@@ -3132,6 +3149,8 @@
     char_u	*dirname_start = NULL;
     char_u	*dirname_now = NULL;
     char_u	*target_dir = NULL;
+    char_u	title[130] = ":";
+    char_u      *q = vim_strnsave(*eap->cmdlinep, 128);
 #ifdef FEAT_AUTOCMD
     char_u	*au_name =  NULL;
 
@@ -3209,7 +3228,7 @@
 	 eap->cmdidx != CMD_vimgrepadd && eap->cmdidx != CMD_lvimgrepadd)
 					|| qi->qf_curlist == qi->qf_listcount)
 	/* make place for a new list */
-	qf_new_list(qi, *eap->cmdlinep);
+	qf_new_list(qi, (char_u *)STRNCAT(title, q, (size_t) 128));
     else if (qi->qf_lists[qi->qf_curlist].qf_count > 0)
 	/* Adding to existing list, find last entry. */
 	for (prevp = qi->qf_lists[qi->qf_curlist].qf_start;
@@ -3311,7 +3330,7 @@
 	    if (idx == LISTCOUNT)
 	    {
 		/* List cannot be found, create a new one. */
-		qf_new_list(qi, *eap->cmdlinep);
+		qf_new_list(qi, (char_u *)STRNCAT(title, q, (size_t) 128));
 		cur_qf_start = qi->qf_lists[qi->qf_curlist].qf_start;
 	    }
 	}
@@ -3489,6 +3508,7 @@
     vim_free(dirname_start);
     vim_free(target_dir);
     vim_free(regmatch.regprog);
+    vim_free(q);
 }
 
 /*
@@ -3808,6 +3828,7 @@
     if (action == ' ' || qi->qf_curlist == qi->qf_listcount)
 	/* make place for a new list */
 	qf_new_list(qi, title);
+
     else if (action == 'a' && qi->qf_lists[qi->qf_curlist].qf_count > 0)
 	/* Adding to existing list, find last entry. */
 	for (prevp = qi->qf_lists[qi->qf_curlist].qf_start;
@@ -3816,6 +3837,12 @@
     else if (action == 'r')
 	qf_free(qi, qi->qf_curlist);
 
+    if (title != NULL && action != ' ')
+    {
+	vim_free(qi->qf_lists[qi->qf_curlist].qf_title);
+	qi->qf_lists[qi->qf_curlist].qf_title = vim_strsave(title);
+    }
+
     for (li = list->lv_first; li != NULL; li = li->li_next)
     {
 	if (li->li_tv.v_type != VAR_DICT)
@@ -4027,6 +4054,7 @@
 #ifdef FEAT_AUTOCMD
     char_u	*au_name =  NULL;
 #endif
+    char_u	title[130] = ":";
 
 #ifdef FEAT_MULTI_LANG
     /* Check for a specified language */
@@ -4089,7 +4117,7 @@
 #endif
 
 	/* create a new quickfix list */
-	qf_new_list(qi, *eap->cmdlinep);
+	qf_new_list(qi, (char_u*)STRNCAT(title, *eap->cmdlinep, (size_t) 128));
 
 	/* Go through all directories in 'runtimepath' */
 	p = p_rtp;

Raspunde prin e-mail lui