Hi,

On Thu, Aug 31, 2017 at 11:58 AM, Bram Moolenaar <[email protected]> wrote:
>
> Lcd47 wrote:
>
>> On 27 August 2017, Bram Moolenaar <[email protected]> wrote:
>> >
>> > Patch 8.0.1006
>> > Problem:    Cannot parse text with 'erroformat' without changing a quickfix
>> >             list.
>> > Solution:   Add the "text" argument to getqflist(). (Yegappan Lakshmanan)
>> > Files:      runtime/doc/eval.txt, src/evalfunc.c, src/proto/quickfix.pro,
>> >             src/quickfix.c, src/testdir/test_quickfix.vim
>>
>>     It's awesome that this feature has been added, however the interface
>> is confusing:
>>
>> [...]
>> > +                   text    use 'errorformat' to extract items from the
>> > +                           text and return the resulting entries. The
>> > +                           value can be a string with one line or a list
>> > +                           with multiple lines. The current quickfix list
>> > +                           is not modified.
>> [...]
>> > +           When 'text' is specified, all the other items are ignored. The
>> > +           returned dictionary contains the entry 'items' with the list
>> > +           of entries.
>> >             In case of error processing {what}, an empty dictionary is
>> >             returned.
>> [...]
>>
>>     What is the point in reusing getqflist() for this instead of writing
>> a new function?  It makes no sense: when "text" is used the other
>> arguments are silently ignored, and the {"items": ...} around the qflist
>> is useless.  Why not a function getexpr(list), that returns a list?
>
> As Yegappan mentioned, using a separate function means a lot of the
> arguments need to be duplicated.  It's not idea, but considering these
> functions will be used in scripts and won't be typed it's not that
> important.
>
>
>>     Finally, there's also a confusion about "text" being a key on
>> input, and also a key with a completely different meaning on output.
>
> "text" is indeed very generic.  We could always require passing a list
> (one item would be the same as passing a string), and then the item
> could be called "lines".  Would that work better?
>

I am attaching a patch to change 'text' to 'lines' and to accept only
List values.

- 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 ecb41c4b8..a2b7295c1 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -4639,11 +4639,10 @@ getqflist([{what}])                                     
*getqflist()*
                        nr      get information for this quickfix list; zero
                                means the current quickfix list and '$' means
                                the last quickfix list
-                       text    use 'errorformat' to extract items from the
-                               text and return the resulting entries. The
-                               value can be a string with one line or a list
-                               with multiple lines. The current quickfix list
-                               is not modified.
+                       lines   use 'errorformat' to extract items from a list
+                               of lines and return the resulting entries.
+                               Only a |List| type is accepted.  The current
+                               quickfix list is not modified.
                        title   get the list title
                        winid   get the |window-ID| (if opened)
                        all     all of the above quickfix properties
@@ -4671,6 +4670,7 @@ getqflist([{what}])                                       
*getqflist()*
                Examples: >
                        :echo getqflist({'all': 1})
                        :echo getqflist({'nr': 2, 'title': 1})
+                       :echo getqflist({'lines' : ["F1:10:L10"]})
 <
 
 getreg([{regname} [, 1 [, {list}]]])                   *getreg()*
diff --git a/src/quickfix.c b/src/quickfix.c
index 1082fbd37..d7ee8b1b4 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -4643,15 +4643,13 @@ enum {
  * Parse text from 'di' and return the quickfix list items
  */
     static int
-qf_get_list_from_text(dictitem_T *di, dict_T *retdict)
+qf_get_list_from_lines(dictitem_T *di, dict_T *retdict)
 {
     int                status = FAIL;
     qf_info_T  *qi;
 
-    /* Only string and list values are supported */
-    if ((di->di_tv.v_type == VAR_STRING && di->di_tv.vval.v_string != NULL)
-           || (di->di_tv.v_type == VAR_LIST
-               && di->di_tv.vval.v_list != NULL))
+    /* Only list values are supported */
+    if (di->di_tv.v_type == VAR_LIST && di->di_tv.vval.v_list != NULL)
     {
        list_T  *l = list_alloc();
 
@@ -4693,8 +4691,8 @@ get_errorlist_properties(win_T *wp, dict_T *what, dict_T 
*retdict)
     dictitem_T *di;
     int                flags = QF_GETLIST_NONE;
 
-    if ((di = dict_find(what, (char_u *)"text", -1)) != NULL)
-       return qf_get_list_from_text(di, retdict);
+    if ((di = dict_find(what, (char_u *)"lines", -1)) != NULL)
+       return qf_get_list_from_lines(di, retdict);
 
     if (wp != NULL)
        qi = GET_LOC_LIST(wp);
diff --git a/src/testdir/test_quickfix.vim b/src/testdir/test_quickfix.vim
index d6b65e339..30d2a1022 100644
--- a/src/testdir/test_quickfix.vim
+++ b/src/testdir/test_quickfix.vim
@@ -2523,28 +2523,26 @@ endfunc
 
 " Test for getting the quickfix list items from some text without modifying
 " the quickfix stack
-func XgetListFromText(cchar)
+func XgetListFromLines(cchar)
   call s:setup_commands(a:cchar)
   call g:Xsetlist([], 'f')
 
-  let l = g:Xgetlist({'text' : "File1:10:Line10"}).items
-  call assert_equal(1, len(l))
-  call assert_equal('Line10', l[0].text)
-
-  let l = g:Xgetlist({'text' : ["File2:20:Line20", "File2:30:Line30"]}).items
+  let l = g:Xgetlist({'lines' : ["File2:20:Line20", "File2:30:Line30"]}).items
   call assert_equal(2, len(l))
   call assert_equal(30, l[1].lnum)
 
-  call assert_equal({}, g:Xgetlist({'text' : 10}))
-  call assert_equal([], g:Xgetlist({'text' : []}).items)
+  call assert_equal({}, g:Xgetlist({'lines' : 10}))
+  call assert_equal({}, g:Xgetlist({'lines' : 'File1:10:Line10'}))
+  call assert_equal([], g:Xgetlist({'lines' : []}).items)
+  call assert_equal([], g:Xgetlist({'lines' : [10, 20]}).items)
 
   " Make sure that the quickfix stack is not modified
   call assert_equal(0, g:Xgetlist({'nr' : '$'}).nr)
 endfunc
 
-func Test_get_list_from_text()
-  call XgetListFromText('c')
-  call XgetListFromText('l')
+func Test_get_list_from_lines()
+  call XgetListFromLines('c')
+  call XgetListFromLines('l')
 endfunc
 
 " Tests for the quickfix list id

Raspunde prin e-mail lui