Skip to content

Commit d43906d

Browse files
committed
patch 8.2.1255: cannot use a lambda with quickfix functions
Problem: Cannot use a lambda with quickfix functions. Solution: Add support for lambda. (Yegappan Lakshmanan, closes #6499)
1 parent 470adb8 commit d43906d

File tree

11 files changed

+224
-57
lines changed

11 files changed

+224
-57
lines changed

runtime/doc/eval.txt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*eval.txt* For Vim version 8.2. Last change: 2020 Jul 09
1+
*eval.txt* For Vim version 8.2. Last change: 2020 Jul 19
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -94,8 +94,9 @@ the Number. Examples:
9494
Number 0 --> String "0" ~
9595
Number -1 --> String "-1" ~
9696
*octal*
97-
Conversion from a String to a Number is done by converting the first digits to
98-
a number. Hexadecimal "0xf9", Octal "017" or "0o17", and Binary "0b10"
97+
Conversion from a String to a Number only happens in legacy Vim script, not in
98+
Vim9 script. It is done by converting the first digits to a number.
99+
Hexadecimal "0xf9", Octal "017" or "0o17", and Binary "0b10"
99100
numbers are recognized (NOTE: when using |scriptversion-4| octal with a
100101
leading "0" is not recognized). If the String doesn't start with digits, the
101102
result is zero.
@@ -2831,7 +2832,7 @@ stridx({haystack}, {needle} [, {start}])
28312832
string({expr}) String String representation of {expr} value
28322833
strlen({expr}) Number length of the String {expr}
28332834
strpart({str}, {start} [, {len}])
2834-
String {len} characters of {str} at {start}
2835+
String {len} bytes of {str} at byte {start}
28352836
strptime({format}, {timestring})
28362837
Number Convert {timestring} to unix timestamp
28372838
strridx({haystack}, {needle} [, {start}])
@@ -9183,7 +9184,8 @@ setqflist({list} [, {action} [, {what}]]) *setqflist()*
91839184
the last quickfix list.
91849185
quickfixtextfunc
91859186
function to get the text to display in the
9186-
quickfix window. Refer to
9187+
quickfix window. The value can be the name of
9188+
a function or a funcref or a lambda. Refer to
91879189
|quickfix-window-function| for an explanation
91889190
of how to write the function and an example.
91899191
title quickfix list title text. See |quickfix-title|

runtime/doc/options.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5913,7 +5913,8 @@ A jump table for the options with a short description can be found at |Q_op|.
59135913
customize the information displayed in the quickfix or location window
59145914
for each entry in the corresponding quickfix or location list. See
59155915
|quickfix-window-function| for an explanation of how to write the
5916-
function and an example.
5916+
function and an example. The value can be the name of a function or a
5917+
lambda.
59175918

59185919
This option cannot be set from a |modeline| or in the |sandbox|, for
59195920
security reasons.

runtime/doc/quickfix.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1964,7 +1964,10 @@ The function should return a single line of text to display in the quickfix
19641964
window for each entry from start_idx to end_idx. The function can obtain
19651965
information about the entries using the |getqflist()| function and specifying
19661966
the quickfix list identifier "id". For a location list, getloclist() function
1967-
can be used with the 'winid' argument.
1967+
can be used with the 'winid' argument. If an empty list is returned, then the
1968+
default format is used to display all the entries. If an item in the returned
1969+
list is an empty string, then the default format is used to display the
1970+
corresponding entry.
19681971

19691972
If a quickfix or location list specific customization is needed, then the
19701973
'quickfixtextfunc' attribute of the list can be set using the |setqflist()| or

src/channel.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,27 +1101,6 @@ channel_open(
11011101
return channel;
11021102
}
11031103

1104-
/*
1105-
* Copy callback from "src" to "dest", incrementing the refcounts.
1106-
*/
1107-
static void
1108-
copy_callback(callback_T *dest, callback_T *src)
1109-
{
1110-
dest->cb_partial = src->cb_partial;
1111-
if (dest->cb_partial != NULL)
1112-
{
1113-
dest->cb_name = src->cb_name;
1114-
dest->cb_free_name = FALSE;
1115-
++dest->cb_partial->pt_refcount;
1116-
}
1117-
else
1118-
{
1119-
dest->cb_name = vim_strsave(src->cb_name);
1120-
dest->cb_free_name = TRUE;
1121-
func_ref(src->cb_name);
1122-
}
1123-
}
1124-
11251104
static void
11261105
free_set_callback(callback_T *cbp, callback_T *callback)
11271106
{

src/evalvars.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3848,6 +3848,27 @@ set_callback(callback_T *dest, callback_T *src)
38483848
dest->cb_partial = src->cb_partial;
38493849
}
38503850

3851+
/*
3852+
* Copy callback from "src" to "dest", incrementing the refcounts.
3853+
*/
3854+
void
3855+
copy_callback(callback_T *dest, callback_T *src)
3856+
{
3857+
dest->cb_partial = src->cb_partial;
3858+
if (dest->cb_partial != NULL)
3859+
{
3860+
dest->cb_name = src->cb_name;
3861+
dest->cb_free_name = FALSE;
3862+
++dest->cb_partial->pt_refcount;
3863+
}
3864+
else
3865+
{
3866+
dest->cb_name = vim_strsave(src->cb_name);
3867+
dest->cb_free_name = TRUE;
3868+
func_ref(src->cb_name);
3869+
}
3870+
}
3871+
38513872
/*
38523873
* Unref/free "callback" returned by get_callback() or set_callback().
38533874
*/

src/optionstr.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2255,6 +2255,14 @@ did_set_string_option(
22552255
# endif
22562256
#endif
22572257

2258+
#ifdef FEAT_QUICKFIX
2259+
else if (varp == &p_qftf)
2260+
{
2261+
if (qf_process_qftf_option() == FALSE)
2262+
errmsg = e_invarg;
2263+
}
2264+
#endif
2265+
22582266
// Options that are a list of flags.
22592267
else
22602268
{

src/proto/evalvars.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,6 @@ void f_setbufvar(typval_T *argvars, typval_T *rettv);
8888
callback_T get_callback(typval_T *arg);
8989
void put_callback(callback_T *cb, typval_T *tv);
9090
void set_callback(callback_T *dest, callback_T *src);
91+
void copy_callback(callback_T *dest, callback_T *src);
9192
void free_callback(callback_T *callback);
9293
/* vim: set ft=c : */

src/proto/quickfix.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ void ex_cclose(exarg_T *eap);
1515
void ex_copen(exarg_T *eap);
1616
void ex_cbottom(exarg_T *eap);
1717
linenr_T qf_current_entry(win_T *wp);
18+
int qf_process_qftf_option(void);
1819
int grep_internal(cmdidx_T cmdidx);
1920
void ex_make(exarg_T *eap);
2021
int qf_get_size(exarg_T *eap);

0 commit comments

Comments
 (0)