Am Samstag, 15. Februar 2014 22:48:15 UTC+1 schrieb Christian Brabandt:
> On Fr, 14 Feb 2014, Daniel Hahler wrote:
> > > Another update, that fixes failure of test10.
> > This patch changes the default title (?) from ":setloclist()" to
> > "setloclist()".
> The reason for leaving out the colon was so that it wouldn't confuse the
> user and will not leave the impression, that there exists a :setloclist
> ex command. But note, that I don't have a strong feeling about it
> anyhow.
I have updated the patch to use the old default titles, as mentioned earlier:
diff --git a/src/eval.c b/src/eval.c
index 2f7da3d..b366223 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -16733,7 +16733,7 @@ set_qf_ll_list(wp, list_arg, action_arg, title_arg,
rettv)
return; /* type error; errmsg already given */
}
if (title == NULL)
- title = (char_u*)(wp == NULL ? "setqflist()" : "setloclist()");
+ title = (char_u*)(wp == NULL ? ":setqflist()" : ":setloclist()");
if (l != NULL && set_errorlist(wp, l, action, title) == OK)
rettv->vval.v_number = 0;
FWIW, I have created a branch (based on a Git mirror) to track this patch:
https://github.com/blueyed/vim/compare/setqflist_title
The patch can be seen also by adding ".patch" to the URL:
https://github.com/blueyed/vim/compare/setqflist_title.patch
It would be nice to get it applied/included finally.
Regards,
Daniel.
--
--
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 c/runtime/doc/eval.txt w/runtime/doc/eval.txt
index 1ffd7ed..5c037cc 100644
--- c/runtime/doc/eval.txt
+++ w/runtime/doc/eval.txt
@@ -1952,11 +1952,12 @@ serverlist() String get a list of available servers
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
@@ -5317,11 +5318,12 @@ setline({lnum}, {text}) *setline()*
: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|.
@@ -5378,7 +5380,7 @@ setpos({expr}, {list})
|winrestview()|.
-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
@@ -5415,7 +5417,8 @@ setqflist({list} [, {action}]) *setqflist()*
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 c/src/eval.c w/src/eval.c
index 728b7d1..b366223 100644
--- c/src/eval.c
+++ w/src/eval.c
@@ -8100,10 +8100,10 @@ static struct fst
{"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},
@@ -16690,21 +16690,23 @@ f_setline(argvars, rettv)
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;
@@ -16724,9 +16726,16 @@ set_qf_ll_list(wp, list_arg, action_arg, rettv)
if (*act == 'a' || *act == 'r')
action = *act;
}
+ 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,
- (char_u *)(wp == NULL ? "setqflist()" : "setloclist()")) == OK)
+ if (l != NULL && set_errorlist(wp, l, action, title) == OK)
rettv->vval.v_number = 0;
}
#endif
@@ -16746,7 +16755,7 @@ f_setloclist(argvars, rettv)
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);
}
/*
@@ -16864,7 +16873,7 @@ f_setqflist(argvars, rettv)
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);
}
/*
@@ -17117,6 +17126,15 @@ setwinvar(argvars, rettv, off)
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 c/src/proto/quickfix.pro w/src/proto/quickfix.pro
index a5c690f..86dd4c0 100644
--- c/src/proto/quickfix.pro
+++ w/src/proto/quickfix.pro
@@ -5,6 +5,7 @@ void copy_loclist __ARGS((win_T *from, win_T *to));
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 c/src/quickfix.c w/src/quickfix.c
index 799421e..69d69c6 100644
--- c/src/quickfix.c
+++ w/src/quickfix.c
@@ -917,13 +917,7 @@ qf_new_list(qi, qf_title)
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);
}
/*
@@ -2619,6 +2613,27 @@ qf_set_title(qi)
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!
@@ -2816,6 +2831,7 @@ ex_make(eap)
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))
@@ -2888,10 +2904,10 @@ ex_make(eap)
#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
@@ -3054,6 +3070,7 @@ ex_cfile(eap)
#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)
@@ -3099,10 +3116,10 @@ ex_cfile(eap)
* 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)
@@ -3163,6 +3180,8 @@ ex_vimgrep(eap)
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;
@@ -3240,7 +3259,7 @@ ex_vimgrep(eap)
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;
@@ -3342,7 +3361,7 @@ ex_vimgrep(eap)
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;
}
}
@@ -3519,6 +3538,7 @@ theend:
vim_free(dirname_now);
vim_free(dirname_start);
vim_free(target_dir);
+ vim_free(q);
vim_regfree(regmatch.regprog);
}
@@ -3839,6 +3859,7 @@ set_errorlist(wp, list, action, title)
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;
@@ -3847,6 +3868,12 @@ set_errorlist(wp, list, action, title)
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)
@@ -4058,6 +4085,7 @@ ex_helpgrep(eap)
#ifdef FEAT_AUTOCMD
char_u *au_name = NULL;
#endif
+ char_u title[130] = ":";
#ifdef FEAT_MULTI_LANG
/* Check for a specified language */
@@ -4120,7 +4148,7 @@ ex_helpgrep(eap)
#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;