The attached patch makes the quickfix / location list window's title
reflect the command that yielded the error list.

Additionally, two commands have been added:
:cse[ttitle]
:lse[ttitle]

The former allows for setting a custom title of the quickfix window. The
latter changes the title of the location list window.

An example can be found here:
http://i41.tinypic.com/nd8obr.png

The patch was made against Vim 7.2.147.

-- 
Cheers,
Lech

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

diff -acr vim7_runtime_orig/doc/quickfix.txt vim7_runtime/doc/quickfix.txt
*** vim7_runtime_orig/doc/quickfix.txt	2008-08-11 20:47:30.000000000 +0200
--- vim7_runtime/doc/quickfix.txt	2009-03-22 22:39:34.000000000 +0100
***************
*** 310,316 ****
  			'buftype' equal to "quickfix".  Don't change this!
  			If there already is a quickfix window, it will be made
  			the current window.  It is not possible to open a
! 			second quickfix window.
  
  							*:lop* *:lopen*
  :lop[en] [height]	Open a window to show the location list for the
--- 310,317 ----
  			'buftype' equal to "quickfix".  Don't change this!
  			If there already is a quickfix window, it will be made
  			the current window.  It is not possible to open a
! 			second quickfix window. The window's title will
! 			indicate the command used to get the list of errors.
  
  							*:lop* *:lopen*
  :lop[en] [height]	Open a window to show the location list for the
***************
*** 335,340 ****
--- 336,351 ----
  :lw[indow] [height]	Same as ":cwindow", except use the window showing the
  			location list for the current window.
  
+ 							*:cse* *:csettitle*
+ :cse[ttitle] [arguments]
+ 			Change the title of the quickfix window. If no
+ 			arguments are provided, the title will be cleared.
+ 
+ 							*:lse* *:lsettitle*
+ :lse[ttitle] [arguments]
+ 			Same as ":csettitle" but acts on the location list
+ 			window.
+ 
  Normally the quickfix window is at the bottom of the screen.  If there are
  vertical splits, it's at the bottom of the rightmost column of windows.  To
  make it always occupy the full width: >
diff -acr vim7_runtime_orig/doc/todo.txt vim7_runtime/doc/todo.txt
*** vim7_runtime_orig/doc/todo.txt	2009-02-22 22:51:57.000000000 +0100
--- vim7_runtime/doc/todo.txt	2009-03-22 22:40:58.000000000 +0100
***************
*** 4087,4094 ****
      Govindachar)
  7   Add a command that goes back to the position from before jumping to the
      first quickfix location.  ":cbefore"?
- 6   In the quickfix window statusline add the command used to get the list of
-     errors, e.g. ":make foo", ":grep something *.c".
  6   Python interface: add vim.message() function. (Michal Vitecek, 2002 Nov 5)
  7   Support using ":vert" with User commands.  Add expandable items <vert>.
      Do the same for ":browse" and ":confirm"?
--- 4087,4092 ----
Index: src/hardcopy.c
===================================================================
--- src/hardcopy.c	(revision 1421)
+++ src/hardcopy.c	(working copy)
@@ -568,6 +568,8 @@
     long_u		bytes_to_print = 0;
     int			page_line;
     int			jobsplit;
+    char_u		*bname = NULL;
+    int			do_return = FALSE;
 
     memset(&settings, 0, sizeof(prt_settings_T));
     settings.has_color = TRUE;
@@ -599,11 +601,16 @@
      */
     if (mch_print_init(&settings,
 			curbuf->b_fname == NULL
-			    ? (char_u *)buf_spname(curbuf)
+			    ? (bname = (char_u *)buf_spname(curbuf))
 			    : curbuf->b_sfname == NULL
 				? curbuf->b_fname
 				: curbuf->b_sfname,
 			eap->forceit) == FAIL)
+	do_return = TRUE;
+
+    if (bname)
+	vim_free(bname);
+    if (do_return)
 	return;
 
 #ifdef FEAT_SYN_HL
Index: src/ex_docmd.c
===================================================================
--- src/ex_docmd.c	(revision 1421)
+++ src/ex_docmd.c	(working copy)
@@ -7285,6 +7285,7 @@
     tabpage_T	*tp;
     win_T	*wp;
     int		tabcount = 1;
+    char_u	*bname;
 
     msg_start();
     msg_scroll = TRUE;
@@ -7307,8 +7308,12 @@
 	    msg_putchar(' ');
 	    msg_putchar(bufIsChanged(wp->w_buffer) ? '+' : ' ');
 	    msg_putchar(' ');
-	    if (buf_spname(wp->w_buffer) != NULL)
-		STRCPY(IObuff, buf_spname(wp->w_buffer));
+	    if ((bname = (char_u *)buf_spname(wp->w_buffer)) != NULL)
+	    {
+		STRNCPY(IObuff, bname, IOSIZE);
+		IObuff[IOSIZE - 1] = NUL;
+		vim_free(bname);
+	    }
 	    else
 		home_replace(wp->w_buffer, wp->w_buffer->b_fname,
 							IObuff, IOSIZE, TRUE);
Index: src/ex_cmds.h
===================================================================
--- src/ex_cmds.h	(revision 1421)
+++ src/ex_cmds.h	(working copy)
@@ -279,6 +279,8 @@
 			RANGE|NOTADR|COUNT|TRLBAR|BANG),
 EX(CMD_cscope,		"cscope",	do_cscope,
 			EXTRA|NOTRLCOM|XFILE),
+EX(CMD_csettitle,	"csettitle",	ex_csettitle,
+			EXTRA|SBOXOK|CMDWIN),
 EX(CMD_cstag,		"cstag",	do_cstag,
 			BANG|TRLBAR|WORD1),
 EX(CMD_cunmap,		"cunmap",	ex_unmap,
@@ -581,6 +583,8 @@
 			RANGE|NOTADR|COUNT|TRLBAR),
 EX(CMD_ls,		"ls",		buflist_list,
 			BANG|TRLBAR|CMDWIN),
+EX(CMD_lsettitle,	"lsettitle",	ex_csettitle,
+			EXTRA|SBOXOK|CMDWIN),
 EX(CMD_move,		"move",		ex_copymove,
 			RANGE|WHOLEFOLD|EXTRA|TRLBAR|CMDWIN|MODIFY),
 EX(CMD_mark,		"mark",		ex_mark,
Index: src/ex_cmds2.c
===================================================================
--- src/ex_cmds2.c	(revision 1421)
+++ src/ex_cmds2.c	(working copy)
@@ -1522,6 +1522,7 @@
 #ifdef FEAT_WINDOWS
     win_T	*wp;
 #endif
+    char_u	*bname;
 
     for (;;)
     {
@@ -1562,14 +1563,16 @@
 	    msg_didout = FALSE;
 	}
 	if (EMSG2(_("E162: No write since last change for buffer \"%s\""),
-		    buf_spname(buf) != NULL ? (char_u *)buf_spname(buf) :
-		    buf->b_fname))
+		    (bname = (char_u *)buf_spname(buf)) != NULL ? bname :
+								  buf->b_fname))
 	{
 	    save = no_wait_return;
 	    no_wait_return = FALSE;
 	    wait_return(FALSE);
 	    no_wait_return = save;
 	}
+	if (bname)
+	    vim_free(bname);
     }
 
 #ifdef FEAT_WINDOWS
Index: src/proto/quickfix.pro
===================================================================
--- src/proto/quickfix.pro	(revision 1421)
+++ src/proto/quickfix.pro	(working copy)
@@ -1,5 +1,7 @@
 /* quickfix.c */
-int qf_init __ARGS((win_T *wp, char_u *efile, char_u *errorformat, int newlist));
+int qf_init __ARGS((win_T *wp, char_u *efile, char_u *errorformat, int newlist, char *qf_title));
+char* qf_get_name __ARGS((qf_info_T *qi));
+void  ex_csettitle __ARGS((exarg_T *eap));
 void qf_free_all __ARGS((win_T *wp));
 void copy_loclist __ARGS((win_T *from, win_T *to));
 void qf_jump __ARGS((qf_info_T *qi, int dir, int errornr, int forceit));
Index: src/quickfix.c
===================================================================
--- src/quickfix.c	(revision 1421)
+++ src/quickfix.c	(working copy)
@@ -56,6 +56,9 @@
     int		qf_count;	/* number of errors (0 means no error list) */
     int		qf_index;	/* current index in the error list */
     int		qf_nonevalid;	/* TRUE if not a single valid entry found */
+    char	*qf_title;	/* title displayed in the quickfix/location
+				 * window's status bar
+				 */
 } qf_list_T;
 
 struct qf_info_S
@@ -104,8 +107,8 @@
     int		    conthere;	/* %> used */
 };
 
-static int	qf_init_ext __ARGS((qf_info_T *qi, char_u *efile, buf_T *buf, typval_T *tv, char_u *errorformat, int newlist, linenr_T lnumfirst, linenr_T lnumlast));
-static void	qf_new_list __ARGS((qf_info_T *qi));
+static int	qf_init_ext __ARGS((qf_info_T *qi, char_u *efile, buf_T *buf, typval_T *tv, char_u *errorformat, int newlist, linenr_T lnumfirst, linenr_T lnumlast, char *qf_title));
+static void	qf_new_list __ARGS((qf_info_T *qi, char *qf_title));
 static void	ll_free_all __ARGS((qf_info_T **pqi));
 static int	qf_add_entry __ARGS((qf_info_T *qi, qfline_T **prevp, char_u *dir, char_u *fname, int bufnum, char_u *mesg, long lnum, int col, int vis_col, char_u *pattern, int nr, int type, int valid));
 static qf_info_T *ll_new_list __ARGS((void));
@@ -148,11 +151,12 @@
  * Return -1 for error, number of errors for success.
  */
     int
-qf_init(wp, efile, errorformat, newlist)
+qf_init(wp, efile, errorformat, newlist, qf_title)
     win_T	    *wp;
     char_u	    *efile;
     char_u	    *errorformat;
     int		    newlist;		/* TRUE: start a new error list */
+    char	    *qf_title;
 {
     qf_info_T	    *qi = &ql_info;
 
@@ -167,10 +171,67 @@
     }
 
     return qf_init_ext(qi, efile, curbuf, NULL, errorformat, newlist,
-						    (linenr_T)0, (linenr_T)0);
+						    (linenr_T)0, (linenr_T)0,
+						    qf_title);
 }
 
 /*
+ * Returns the title of the qf_info_T's current qf_list_T.
+ */
+    char*
+qf_get_name(qi)
+    qf_info_T *qi;
+{
+    if (qi)
+	return qi->qf_lists[qi->qf_curlist].qf_title;
+
+    return ql_info.qf_lists[ql_info.qf_curlist].qf_title;
+}
+
+/*
+ * Sets the title of a quickfix window / location list window.
+ */
+    void
+ex_csettitle(eap)
+    exarg_T	*eap;
+{
+    qf_info_T	*list_ref;
+    win_T	*win;
+    char_u	*err_msg;
+
+    if (eap->cmdidx == CMD_csettitle)
+    {
+	list_ref = &ql_info;
+	err_msg = e_quickfix;
+    }
+    else
+    {
+	list_ref = GET_LOC_LIST(curwin);
+	err_msg = e_loclist;
+    }
+
+    if (!list_ref || !list_ref->qf_listcount)
+    {
+	EMSG(_(err_msg));
+	return;
+    }
+
+    if (NULL != list_ref->qf_lists[list_ref->qf_curlist].qf_title)
+	vim_free(list_ref->qf_lists[list_ref->qf_curlist].qf_title);
+    list_ref->qf_lists[list_ref->qf_curlist].qf_title = (char *)vim_strsave(eap->arg);
+
+    if (eap->cmdidx == CMD_csettitle)
+	list_ref = NULL;
+
+    need_maketitle = TRUE;
+    FOR_ALL_WINDOWS(win)
+    {
+	if (bt_quickfix(win->w_buffer) && list_ref == win->w_llist_ref)
+	    win_redr_status(win);
+    }
+}
+
+/*
  * Read the errorfile "efile" into memory, line by line, building the error
  * list.
  * Alternative: when "efile" is null read errors from buffer "buf".
@@ -179,7 +240,7 @@
  * Return -1 for error, number of errors for success.
  */
     static int
-qf_init_ext(qi, efile, buf, tv, errorformat, newlist, lnumfirst, lnumlast)
+qf_init_ext(qi, efile, buf, tv, errorformat, newlist, lnumfirst, lnumlast, qf_title)
     qf_info_T	    *qi;
     char_u	    *efile;
     buf_T	    *buf;
@@ -188,6 +249,7 @@
     int		    newlist;		/* TRUE: start a new error list */
     linenr_T	    lnumfirst;		/* first line number to use */
     linenr_T	    lnumlast;		/* last line number to use */
+    char	    *qf_title;
 {
     char_u	    *namebuf;
     char_u	    *errmsg;
@@ -257,12 +319,13 @@
 
     if (newlist || qi->qf_curlist == qi->qf_listcount)
 	/* make place for a new list */
-	qf_new_list(qi);
+	qf_new_list(qi, qf_title);
     else if (qi->qf_lists[qi->qf_curlist].qf_count > 0)
 	/* Adding to existing list, find last entry. */
 	for (qfprev = qi->qf_lists[qi->qf_curlist].qf_start;
-			    qfprev->qf_next != qfprev; qfprev = qfprev->qf_next)
-	    ;
+	     qfprev->qf_next != qfprev;
+	     qfprev = qfprev->qf_next)
+	{ /* do nothing */ }
 
 /*
  * Each part of the format string is copied and modified from errorformat to
@@ -860,8 +923,9 @@
  * Prepare for adding a new quickfix list.
  */
     static void
-qf_new_list(qi)
+qf_new_list(qi, qf_title)
     qf_info_T	*qi;
+    char	*qf_title;
 {
     int		i;
 
@@ -888,6 +952,8 @@
 	qi->qf_curlist = qi->qf_listcount++;
     qi->qf_lists[qi->qf_curlist].qf_index = 0;
     qi->qf_lists[qi->qf_curlist].qf_count = 0;
+    qi->qf_lists[qi->qf_curlist].qf_title = (char *)(qf_title? vim_strsave((char_u *)qf_title):
+							       NULL);
 }
 
 /*
@@ -1100,6 +1166,10 @@
 	to_qfl->qf_index = 0;
 	to_qfl->qf_start = NULL;
 	to_qfl->qf_ptr = NULL;
+	if (from_qfl->qf_title)
+	    to_qfl->qf_title = (char *)vim_strsave((char_u *)from_qfl->qf_title);
+	else
+	    to_qfl->qf_title = NULL;
 
 	if (from_qfl->qf_count)
 	{
@@ -2108,6 +2178,7 @@
 	qi->qf_lists[idx].qf_start = qfp;
 	--qi->qf_lists[idx].qf_count;
     }
+    vim_free(qi->qf_lists[idx].qf_title);
 }
 
 /*
@@ -2789,7 +2860,8 @@
     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->cmdidx != CMD_lgrepadd),
+					   (char *)*eap->cmdlinep);
 #ifdef FEAT_AUTOCMD
     if (au_name != NULL)
 	apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
@@ -2964,7 +3036,8 @@
      * quickfix list then a new list is created.
      */
     if (qf_init(wp, p_ef, p_efm, (eap->cmdidx != CMD_caddfile
-				  && eap->cmdidx != CMD_laddfile)) > 0
+				  && eap->cmdidx != CMD_laddfile),
+		(char *)*eap->cmdlinep) > 0
 				  && (eap->cmdidx == CMD_cfile
 					     || eap->cmdidx == CMD_lfile))
     {
@@ -3072,7 +3145,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);
+	qf_new_list(qi, (char *)*eap->cmdlinep);
     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;
@@ -3580,7 +3653,7 @@
 
     if (action == ' ' || qi->qf_curlist == qi->qf_listcount)
 	/* make place for a new list */
-	qf_new_list(qi);
+	qf_new_list(qi, NULL);
     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;
@@ -3710,7 +3783,8 @@
 	    if (qf_init_ext(qi, NULL, buf, NULL, p_efm,
 			    (eap->cmdidx != CMD_caddbuffer
 			     && eap->cmdidx != CMD_laddbuffer),
-						   eap->line1, eap->line2) > 0
+						   eap->line1, eap->line2,
+						   (char *)*eap->cmdlinep) > 0
 		    && (eap->cmdidx == CMD_cbuffer
 			|| eap->cmdidx == CMD_lbuffer))
 		qf_jump(qi, 0, 0, eap->forceit);  /* display first error */
@@ -3749,7 +3823,8 @@
 	    if (qf_init_ext(qi, NULL, NULL, tv, p_efm,
 			    (eap->cmdidx != CMD_caddexpr
 			     && eap->cmdidx != CMD_laddexpr),
-						 (linenr_T)0, (linenr_T)0) > 0
+						 (linenr_T)0, (linenr_T)0,
+			    (char *)*eap->cmdlinep) > 0
 		    && (eap->cmdidx == CMD_cexpr
 			|| eap->cmdidx == CMD_lexpr))
 		qf_jump(qi, 0, 0, eap->forceit);  /* display first error */
@@ -3819,7 +3894,7 @@
     if (regmatch.regprog != NULL)
     {
 	/* create a new quickfix list */
-	qf_new_list(qi);
+	qf_new_list(qi, (char *)*eap->cmdlinep);
 
 	/* Go through all directories in 'runtimepath' */
 	p = p_rtp;
Index: src/buffer.c
===================================================================
--- src/buffer.c	(revision 1421)
+++ src/buffer.c	(working copy)
@@ -2547,6 +2547,7 @@
     buf_T	*buf;
     int		len;
     int		i;
+    char_u	*bname;
 
     for (buf = firstbuf; buf != NULL && !got_int; buf = buf->b_next)
     {
@@ -2554,8 +2555,11 @@
 	if (!buf->b_p_bl && !eap->forceit)
 	    continue;
 	msg_putchar('\n');
-	if (buf_spname(buf) != NULL)
-	    STRCPY(NameBuff, buf_spname(buf));
+	if ((bname = (char_u *)buf_spname(buf)) != NULL)
+	{
+	    STRNCPY(NameBuff, bname, MAXPATHL);
+	    vim_free(bname);
+	}
 	else
 	    home_replace(buf, buf->b_fname, NameBuff, MAXPATHL, TRUE);
 
@@ -2960,6 +2964,7 @@
     char_u	*p;
     char_u	*buffer;
     size_t	len;
+    char_u	*bname;
 
     buffer = alloc(IOSIZE);
     if (buffer == NULL)
@@ -2974,8 +2979,11 @@
 	p = buffer;
 
     *p++ = '"';
-    if (buf_spname(curbuf) != NULL)
-	STRCPY(p, buf_spname(curbuf));
+    if ((bname = (char_u *)buf_spname(curbuf)) != NULL)
+    {
+	STRNCPY(p, bname, (int)(IOSIZE - (p - buffer)));
+	vim_free(bname);
+    }
     else
     {
 	if (!fullname && curbuf->b_fname != NULL)
@@ -2986,6 +2994,7 @@
 					  (int)(IOSIZE - (p - buffer)), TRUE);
     }
 
+    buffer[IOSIZE - 1] = NUL;
     len = STRLEN(buffer);
     vim_snprintf((char *)buffer + len, IOSIZE - len,
 	    "\"%s%s%s%s%s%s",
@@ -3257,8 +3266,9 @@
 	}
 	else
 	{
-	    if (buf_spname(curbuf) != NULL)
-		i_name = (char_u *)buf_spname(curbuf);
+	    char_u *bname;
+	    if ((bname = (char_u *)buf_spname(curbuf)) != NULL)
+		i_name = bname;
 	    else		    /* use file name only in icon */
 		i_name = gettail(curbuf->b_ffname);
 	    *i_str = NUL;
@@ -3274,6 +3284,8 @@
 		i_name += len;
 	    }
 	    STRCPY(i_str, i_name);
+	    if (bname)
+		vim_free(bname);
 	    trans_characters(i_str, IOSIZE);
 	}
     }
@@ -3378,6 +3390,7 @@
     int		curitem;
     int		groupitem[STL_MAX_ITEM];
     int		groupdepth;
+    char_u	*bname;
     struct stl_item
     {
 	char_u		*start;
@@ -3659,8 +3672,11 @@
 	case STL_FULLPATH:
 	case STL_FILENAME:
 	    fillable = FALSE;	/* don't change ' ' to fillchar */
-	    if (buf_spname(wp->w_buffer) != NULL)
-		STRCPY(NameBuff, buf_spname(wp->w_buffer));
+	    if ((bname = (char_u *)buf_spname(wp->w_buffer)) != NULL)
+	    {
+		STRNCPY(NameBuff, bname, MAXPATHL);
+		vim_free(bname);
+	    }
 	    else
 	    {
 		t = (opt == STL_FULLPATH) ? wp->w_buffer->b_ffname
@@ -5089,6 +5105,10 @@
 #if defined(FEAT_QUICKFIX) && defined(FEAT_WINDOWS)
     if (bt_quickfix(buf))
     {
+	char	    *qlname;
+	const char  *bt_name;
+	size_t	    len;
+	char	    *ret_ptr;
 	win_T	    *win = NULL;
 	tabpage_T   *tp;
 
@@ -5101,9 +5121,30 @@
 		goto win_found;
 win_found:
 	if (win != NULL && win->w_llist_ref != NULL)
-	    return _("[Location List]");
+	{
+	    qlname = qf_get_name(win->w_llist_ref);
+	    bt_name = "[Location List]";
+	}
 	else
-	    return _("[Quickfix List]");
+	{
+	    qlname = qf_get_name(NULL);
+	    bt_name = "[Quickfix List]";
+	}
+
+	len = STRLEN(_(bt_name));
+	if (qlname)
+	{
+	    len += STRLEN(qlname);
+	    ret_ptr = (char *)alloc(len + 2);
+	    sprintf(ret_ptr, "%s %s", _(bt_name),
+				      qlname);
+	}
+	else
+	{
+	    ret_ptr = (char *)alloc(len + 1);
+	    sprintf(ret_ptr, "%s", _(bt_name));
+	}
+	return ret_ptr;
     }
 #endif
 #ifdef FEAT_QUICKFIX
@@ -5112,12 +5153,12 @@
     if (bt_nofile(buf))
     {
 	if (buf->b_sfname != NULL)
-	    return (char *)buf->b_sfname;
-	return _("[Scratch]");
+	    return (char *)vim_strsave(buf->b_sfname);
+	return (char *)vim_strsave((char_u *)_("[Scratch]"));
     }
 #endif
     if (buf->b_fname == NULL)
-	return _("[No Name]");
+	return (char *)vim_strsave((char_u *)_("[No Name]"));
     return NULL;
 }
 
Index: src/main.c
===================================================================
--- src/main.c	(revision 1421)
+++ src/main.c	(working copy)
@@ -662,10 +662,12 @@
      */
     if (params.edit_type == EDIT_QF)
     {
+	char qf_title_buf[IOSIZE];
 	if (params.use_ef != NULL)
 	    set_string_option_direct((char_u *)"ef", -1,
 					   params.use_ef, OPT_FREE, SID_CARG);
-	if (qf_init(NULL, p_ef, p_efm, TRUE) < 0)
+	snprintf(qf_title_buf, IOSIZE, "cfile %s", p_ef);
+	if (qf_init(NULL, p_ef, p_efm, TRUE, qf_title_buf) < 0)
 	{
 	    out_char('\n');
 	    mch_exit(3);
Index: src/edit.c
===================================================================
--- src/edit.c	(revision 1421)
+++ src/edit.c	(working copy)
@@ -3896,6 +3896,7 @@
     char_u	*dict = NULL;
     int		dict_f = 0;
     compl_T	*old_match;
+    char    	*bname;
 
     if (!compl_started)
     {
@@ -3955,12 +3956,15 @@
 		    dict = ins_buf->b_fname;
 		    dict_f = DICT_EXACT;
 		}
+		bname = NULL;
 		vim_snprintf((char *)IObuff, IOSIZE, _("Scanning: %s"),
 			ins_buf->b_fname == NULL
-			    ? buf_spname(ins_buf)
+			    ? (bname = buf_spname(ins_buf))
 			    : ins_buf->b_sfname == NULL
 				? (char *)ins_buf->b_fname
 				: (char *)ins_buf->b_sfname);
+		if (bname)
+		    vim_free(bname);
 		msg_trunc_attr(IObuff, TRUE, hl_attr(HLF_R));
 	    }
 	    else if (*e_cpt == NUL)
Index: src/if_cscope.c
===================================================================
--- src/if_cscope.c	(revision 1421)
+++ src/if_cscope.c	(working copy)
@@ -44,7 +44,7 @@
 static void	    cs_fill_results __ARGS((char *, int , int *, char ***,
 			char ***, int *));
 static int	    cs_find __ARGS((exarg_T *eap));
-static int	    cs_find_common __ARGS((char *opt, char *pat, int, int, int));
+static int	    cs_find_common __ARGS((char *opt, char *pat, int, int, int, char *cmdline));
 static int	    cs_help __ARGS((exarg_T *eap));
 static void	    cs_init __ARGS((void));
 static void	    clear_csinfo __ARGS((int i));
@@ -287,7 +287,8 @@
 	if (cs_check_for_connections())
 	{
 	    ret = cs_find_common("g", (char *)(eap->arg), eap->forceit, FALSE,
-				 FALSE);
+				 FALSE,
+				 (char *)*eap->cmdlinep);
 	    if (ret == FALSE)
 	    {
 		cs_free_tags();
@@ -315,7 +316,8 @@
 		if (cs_check_for_connections())
 		{
 		    ret = cs_find_common("g", (char *)(eap->arg), eap->forceit,
-					 FALSE, FALSE);
+					 FALSE, FALSE,
+					 (char *)*eap->cmdlinep);
 		    if (ret == FALSE)
 			cs_free_tags();
 		}
@@ -324,7 +326,8 @@
 	else if (cs_check_for_connections())
 	{
 	    ret = cs_find_common("g", (char *)(eap->arg), eap->forceit, FALSE,
-				 FALSE);
+				 FALSE,
+				 (char *)*eap->cmdlinep);
 	    if (ret == FALSE)
 		cs_free_tags();
 	}
@@ -1062,6 +1065,7 @@
     exarg_T *eap;
 {
     char *opt, *pat;
+    int i;
 
     if (cs_check_for_connections() == FALSE)
     {
@@ -1082,8 +1086,17 @@
 	return FALSE;
     }
 
+    /*
+     * Let's replace the NULs written by strtok() with spaces - we need the
+     * spaces to correctly display the quickfix/location list window's title.
+     */
+    for (i = 0; i < eap_arg_len; ++i)
+	if ('\0' == eap->arg[i])
+	    eap->arg[i] = ' ';
+
     return cs_find_common(opt, pat, eap->forceit, TRUE,
-			  eap->cmdidx == CMD_lcscope);
+			  eap->cmdidx == CMD_lcscope,
+			  (char *)*eap->cmdlinep);
 } /* cs_find */
 
 
@@ -1093,12 +1106,13 @@
  * common code for cscope find, shared by cs_find() and do_cstag()
  */
     static int
-cs_find_common(opt, pat, forceit, verbose, use_ll)
+cs_find_common(opt, pat, forceit, verbose, use_ll, cmdline)
     char *opt;
     char *pat;
     int forceit;
     int verbose;
     int	use_ll;
+    char *cmdline;
 {
     int i;
     char *cmd;
@@ -1194,7 +1208,7 @@
     if (qfpos != NULL)
     {
 	qfpos++;
-	/* next symbol must be + or - */
+	/* next symbol must be +, - or 0 */
 	if (strchr(CSQF_FLAGS, *qfpos) == NULL)
 	{
 	    char *nf = _("E469: invalid cscopequickfix flag %c for %c");
@@ -1229,7 +1243,7 @@
 		wp = curwin;
 	    /* '-' starts a new error list */
 	    if (qf_init(wp, tmp, (char_u *)"%f%*\\t%l%*\\t%m",
-							   *qfpos == '-') > 0)
+							   *qfpos == '-', cmdline) > 0)
 	    {
 # ifdef FEAT_WINDOWS
 		if (postponed_split != 0)
Index: src/screen.c
===================================================================
--- src/screen.c	(revision 1421)
+++ src/screen.c	(working copy)
@@ -9342,8 +9342,12 @@
 get_trans_bufname(buf)
     buf_T	*buf;
 {
-    if (buf_spname(buf) != NULL)
-	STRCPY(NameBuff, buf_spname(buf));
+    char_u *bname = (char_u *)buf_spname(buf);
+    if (bname != NULL)
+    {
+	STRCPY(NameBuff, bname);
+	vim_free(bname);
+    }
     else
 	home_replace(buf, buf->b_fname, NameBuff, MAXPATHL, TRUE);
     trans_characters(NameBuff, MAXPATHL);
Index: src/memline.c
===================================================================
--- src/memline.c	(revision 1421)
+++ src/memline.c	(working copy)
@@ -580,12 +580,15 @@
 
     if (mfp->mf_fname == NULL)		/* Failed! */
     {
+	char_u *bname = (char_u *)buf_spname(buf);
 	need_wait_return = TRUE;	/* call wait_return later */
 	++no_wait_return;
 	(void)EMSG2(_("E303: Unable to open swap file for \"%s\", recovery impossible"),
-		    buf_spname(buf) != NULL
-			? (char_u *)buf_spname(buf)
+		    bname
+			? bname
 			: buf->b_fname);
+	if (bname)
+	    vim_free(bname);
 	--no_wait_return;
     }
 
@@ -860,6 +863,7 @@
     int		serious_error = TRUE;
     long	mtime;
     int		attr;
+    char_u	*bname;
 
     recoverymode = TRUE;
     called_from_main = (curbuf->b_ml.ml_mfp == NULL);
@@ -1060,8 +1064,12 @@
     home_replace(NULL, mfp->mf_fname, NameBuff, MAXPATHL, TRUE);
     smsg((char_u *)_("Using swap file \"%s\""), NameBuff);
 
-    if (buf_spname(curbuf) != NULL)
-	STRCPY(NameBuff, buf_spname(curbuf));
+    if ((bname = (char_u *)buf_spname(curbuf)) != NULL)
+    {
+	STRNCPY(NameBuff, bname, MAXPATHL);
+	NameBuff[MAXPATHL - 1] = NUL;
+	vim_free(bname);
+    }
     else
 	home_replace(NULL, curbuf->b_ffname, NameBuff, MAXPATHL, TRUE);
     smsg((char_u *)_("Original file \"%s\""), NameBuff);

Raspunde prin e-mail lui