mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Make set{qf,loc}list() take {title}
Add an extra argument to these functions to set w:quickfix_title. This is a modified version of a patch from vim_dev. Discussion here: https://groups.google.com/forum/#!topic/vim_dev/X7VVPd4Do5s Credits go to Christian "chrisbra" Brabandt and Daniel "blueyed" Hahler.
This commit is contained in:
parent
8160e875a0
commit
39c3842621
@ -1999,11 +1999,12 @@ setbufvar( {expr}, {varname}, {val}) set {varname} in buffer {expr} to {val}
|
|||||||
setcharsearch( {dict}) Dict set character search from {dict}
|
setcharsearch( {dict}) Dict set character search from {dict}
|
||||||
setcmdpos( {pos}) Number set cursor position in command-line
|
setcmdpos( {pos}) Number set cursor position in command-line
|
||||||
setline( {lnum}, {line}) Number set line {lnum} to {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}
|
Number modify location list using {list}
|
||||||
setmatches( {list}) Number restore a list of matches
|
setmatches( {list}) Number restore a list of matches
|
||||||
setpos( {expr}, {list}) Number set the {expr} position to {list}
|
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
|
setreg( {n}, {v}[, {opt}]) Number set register to value and type
|
||||||
settabvar( {nr}, {varname}, {val}) set {varname} in tab page {nr} to {val}
|
settabvar( {nr}, {varname}, {val}) set {varname} in tab page {nr} to {val}
|
||||||
settabwinvar( {tabnr}, {winnr}, {varname}, {val}) set {varname} in window
|
settabwinvar( {tabnr}, {winnr}, {varname}, {val}) set {varname} in window
|
||||||
@ -5732,11 +5733,13 @@ setline({lnum}, {text}) *setline()*
|
|||||||
:endfor
|
:endfor
|
||||||
< Note: The '[ and '] marks are not set.
|
< 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}.
|
Create or replace or add to the location list for window {nr}.
|
||||||
When {nr} is zero the current window is used. For a location
|
When {nr} is zero the current window is used. For a location
|
||||||
list window, the displayed location list is modified. For an
|
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 used to set |w:quickfix_title| after opening
|
||||||
|
the location window.
|
||||||
Otherwise, same as |setqflist()|.
|
Otherwise, same as |setqflist()|.
|
||||||
Also see |location-list|.
|
Also see |location-list|.
|
||||||
|
|
||||||
@ -5793,7 +5796,7 @@ setpos({expr}, {list})
|
|||||||
|winrestview()|.
|
|winrestview()|.
|
||||||
|
|
||||||
|
|
||||||
setqflist({list} [, {action}]) *setqflist()*
|
setqflist({list} [, {action}[, {title}]]) *setqflist()*
|
||||||
Create or replace or add to the quickfix list using the items
|
Create or replace or add to the quickfix list using the items
|
||||||
in {list}. Each item in {list} is a dictionary.
|
in {list}. Each item in {list} is a dictionary.
|
||||||
Non-dictionary items in {list} are ignored. Each dictionary
|
Non-dictionary items in {list} are ignored. Each dictionary
|
||||||
@ -5832,6 +5835,9 @@ setqflist({list} [, {action}]) *setqflist()*
|
|||||||
with the items from {list}. If {action} is not present or is
|
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 used to set |w:quickfix_title|
|
||||||
|
after opening the quickfix window.
|
||||||
|
|
||||||
Returns zero for success, -1 for failure.
|
Returns zero for success, -1 for failure.
|
||||||
|
|
||||||
This function can be used to create a quickfix list
|
This function can be used to create a quickfix list
|
||||||
|
@ -7324,10 +7324,10 @@ static struct fst {
|
|||||||
{ "setcharsearch", 1, 1, f_setcharsearch },
|
{ "setcharsearch", 1, 1, f_setcharsearch },
|
||||||
{ "setcmdpos", 1, 1, f_setcmdpos },
|
{ "setcmdpos", 1, 1, f_setcmdpos },
|
||||||
{ "setline", 2, 2, f_setline },
|
{ "setline", 2, 2, f_setline },
|
||||||
{ "setloclist", 2, 3, f_setloclist },
|
{ "setloclist", 2, 4, f_setloclist },
|
||||||
{ "setmatches", 1, 1, f_setmatches },
|
{ "setmatches", 1, 1, f_setmatches },
|
||||||
{ "setpos", 2, 2, f_setpos },
|
{ "setpos", 2, 2, f_setpos },
|
||||||
{ "setqflist", 1, 2, f_setqflist },
|
{ "setqflist", 1, 3, f_setqflist },
|
||||||
{ "setreg", 2, 3, f_setreg },
|
{ "setreg", 2, 3, f_setreg },
|
||||||
{ "settabvar", 3, 3, f_settabvar },
|
{ "settabvar", 3, 3, f_settabvar },
|
||||||
{ "settabwinvar", 4, 4, f_settabwinvar },
|
{ "settabwinvar", 4, 4, f_settabwinvar },
|
||||||
@ -15215,14 +15215,26 @@ static void f_setline(typval_T *argvars, typval_T *rettv)
|
|||||||
appended_lines_mark(lcount, added);
|
appended_lines_mark(lcount, added);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Create quickfix/location list from VimL values
|
||||||
/*
|
///
|
||||||
* Used by "setqflist()" and "setloclist()" functions
|
/// Used by `setqflist()` and `setloclist()` functions. Accepts invalid
|
||||||
*/
|
/// list_arg, action_arg and title_arg arguments in which case errors out,
|
||||||
static void set_qf_ll_list(win_T *wp, typval_T *list_arg, typval_T *action_arg, typval_T *rettv)
|
/// including VAR_UNKNOWN parameters.
|
||||||
|
///
|
||||||
|
/// @param[in,out] wp Window to create location list for. May be NULL in
|
||||||
|
/// which case quickfix list will be created.
|
||||||
|
/// @param[in] list_arg Quickfix list contents.
|
||||||
|
/// @param[in] action_arg Action to perform: append to an existing list,
|
||||||
|
/// replace its content or create a new one.
|
||||||
|
/// @param[in] title_arg New list title. Defaults to caller function name.
|
||||||
|
/// @param[out] rettv Return value: 0 in case of success, -1 otherwise.
|
||||||
|
static void set_qf_ll_list(win_T *wp, typval_T *list_arg, typval_T *action_arg,
|
||||||
|
typval_T *title_arg, typval_T *rettv)
|
||||||
|
FUNC_ATTR_NONNULL_ARG(2, 3, 4, 5)
|
||||||
{
|
{
|
||||||
char_u *act;
|
char_u *act;
|
||||||
int action = ' ';
|
int action = ' ';
|
||||||
|
char_u *title = NULL;
|
||||||
|
|
||||||
rettv->vval.v_number = -1;
|
rettv->vval.v_number = -1;
|
||||||
|
|
||||||
@ -15231,7 +15243,7 @@ static void set_qf_ll_list(win_T *wp, typval_T *list_arg, typval_T *action_arg,
|
|||||||
else {
|
else {
|
||||||
list_T *l = list_arg->vval.v_list;
|
list_T *l = list_arg->vval.v_list;
|
||||||
|
|
||||||
if (action_arg->v_type == VAR_STRING) {
|
if (action_arg->v_type != VAR_UNKNOWN) {
|
||||||
act = get_tv_string_chk(action_arg);
|
act = get_tv_string_chk(action_arg);
|
||||||
if (act == NULL)
|
if (act == NULL)
|
||||||
return; /* type error; errmsg already given */
|
return; /* type error; errmsg already given */
|
||||||
@ -15239,9 +15251,20 @@ static void set_qf_ll_list(win_T *wp, typval_T *list_arg, typval_T *action_arg,
|
|||||||
action = *act;
|
action = *act;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (l != NULL && set_errorlist(wp, l, action,
|
if (title_arg->v_type != VAR_UNKNOWN) {
|
||||||
(char_u *)(wp == NULL ? "setqflist()" : "setloclist()")) == OK)
|
title = get_tv_string_chk(title_arg);
|
||||||
|
if (!title) {
|
||||||
|
return; // type error; errmsg already given
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!title) {
|
||||||
|
title = (char_u*)(wp ? "setloclist()" : "setqflist()");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (l && set_errorlist(wp, l, action, title) == OK) {
|
||||||
rettv->vval.v_number = 0;
|
rettv->vval.v_number = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -15255,8 +15278,9 @@ static void f_setloclist(typval_T *argvars, typval_T *rettv)
|
|||||||
rettv->vval.v_number = -1;
|
rettv->vval.v_number = -1;
|
||||||
|
|
||||||
win = find_win_by_nr(&argvars[0], NULL);
|
win = find_win_by_nr(&argvars[0], NULL);
|
||||||
if (win != 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -15392,7 +15416,7 @@ static void f_setpos(typval_T *argvars, typval_T *rettv)
|
|||||||
*/
|
*/
|
||||||
static void f_setqflist(typval_T *argvars, typval_T *rettv)
|
static void f_setqflist(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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user