Hi,
On Fri, Sep 16, 2016 at 11:32 PM, LCD 47 <[email protected]> wrote:
> On 16 September 2016, Yegappan Lakshmanan <[email protected]> wrote:
>> Hi,
>>
>> On Sun, Sep 11, 2016 at 4:08 AM, LCD 47 <[email protected]> wrote:
>> > On 12 August 2016, Bram Moolenaar <[email protected]> wrote:
>> >>
>> >> Patch 7.4.2200
>> >> Problem: Cannot get all information about a quickfix list.
>> >> Solution: Add an optional argument to get/set loc/qf list(). (Yegappan
>> >> Lakshmanan)
>> >
>> > Another possible solution would be to track the current loclist
>> > using the "nr" above, which is essentially the index of the current
>> > loclist in the loclist stack. This is more problematic, as the
>> > current interface is incomplete. It isn't possible to get the
>> > current depth of the stack, and the only way to get the "nr" for
>> > the current loclist is to query for "all" and ignore the irrelevant
>> > fields in the result.
>> >
>>
>> You can set the 'nr' key to -1 when calling the
>> getqflist()/getloclist() function to use the current list.
>
> This doesn't seem to work, getloclist(0, {'nr': -1}) always seems
> to return an error:
>
> :echo getloclist(0, {'all': 1})
> {'nr': 2, 'winid': 1001, 'title': ':SyntasticCheck gcc (c)'}
>
> :echo getloclist(0, {'nr': -1})
> {}
>
I am attaching a patch to return information about the current
quickfix/location list, if the 'nr' field is set to zero.
Without this change, to get the current quickfix/location list
number, you need to set 'all' to 1, leave out 'nr' and then parse the
returned information (as you suggested above).
- Yegappan
--
--
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 a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 43d1883..4e01477 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -4521,7 +4521,8 @@ getqflist([{what}])
*getqflist()*
winid get the |window-ID| (if opened)
all all of the above quickfix properties
Non-string items in {what} are ignored.
- If "nr" is not present then the current quickfix list is used.
+ If "nr" is zero or is not present then the current quickfix
+ list is used.
In case of error processing {what}, an empty dictionary is
returned.
diff --git a/src/quickfix.c b/src/quickfix.c
index 51c894b..d2bac05 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -4591,9 +4591,14 @@ get_errorlist_properties(win_T *wp, dict_T *what, dict_T
*retdict)
/* Use the specified quickfix/location list */
if (di->di_tv.v_type == VAR_NUMBER)
{
- qf_idx = di->di_tv.vval.v_number - 1;
- if (qf_idx < 0 || qf_idx >= qi->qf_listcount)
- return FAIL;
+ if (di->di_tv.vval.v_number == 0)
+ qf_idx = qi->qf_curlist; /* use the current list */
+ else
+ {
+ qf_idx = di->di_tv.vval.v_number - 1;
+ if (qf_idx < 0 || qf_idx >= qi->qf_listcount)
+ return FAIL;
+ }
flags |= QF_GETLIST_NR;
}
else