Patch 8.0.1384
Problem: Not enough quickfix help; confusing winid.
Solution: Add more examples in the help. When the quickfix window is not
present, return zero for getqflist() with 'winid'. Add more tests
for jumping to quickfix list entries. (Yegappan Lakshmanan, closes
#2427)
Files: runtime/doc/eval.txt, runtime/doc/quickfix.txt, src/quickfix.c,
src/testdir/test_quickfix.vim
*** ../vim-8.0.1383/runtime/doc/eval.txt 2017-12-02 15:43:28.498450632
+0100
--- runtime/doc/eval.txt 2017-12-10 15:18:29.392726339 +0100
***************
*** 4657,4667 ****
following string items are supported in {what}:
context get the context stored with |setqflist()|
efm errorformat to use when parsing "lines". If
! not present, then the 'erroformat' option
value is used.
id get information for the quickfix list with
|quickfix-ID|; zero means the id for the
! current list or the list specifed by "nr"
idx index of the current entry in the list
items quickfix list entries
lines use 'errorformat' to extract items from a list
--- 4667,4677 ----
following string items are supported in {what}:
context get the context stored with |setqflist()|
efm errorformat to use when parsing "lines". If
! not present, then the 'errorformat' option
value is used.
id get information for the quickfix list with
|quickfix-ID|; zero means the id for the
! current list or the list specified by "nr"
idx index of the current entry in the list
items quickfix list entries
lines use 'errorformat' to extract items from a list
***************
*** 4673,4681 ****
the last quickfix list
size number of entries in the quickfix list
title get the list title
! 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 both "nr" and a non-zero "id" are specified, then the list
specified by "id" is used.
--- 4683,4692 ----
the last quickfix list
size number of entries in the quickfix list
title get the list title
! winid get the quickfix |window-ID|
all all of the above quickfix properties
! Non-string items in {what} are ignored. To get the value of a
! particular item, set it to one.
If "nr" is not present then the current quickfix list is used.
If both "nr" and a non-zero "id" are specified, then the list
specified by "id" is used.
***************
*** 4696,4702 ****
nr quickfix list number
size number of entries in the quickfix list
title quickfix list title text
! winid quickfix |window-ID| (if opened)
Examples: >
:echo getqflist({'all': 1})
--- 4707,4713 ----
nr quickfix list number
size number of entries in the quickfix list
title quickfix list title text
! winid quickfix |window-ID|. If not present, set to 0
Examples: >
:echo getqflist({'all': 1})
***************
*** 4807,4813 ****
Each List item is a Dictionary with the following entries:
bufnr number of buffer in the window
! height window height
loclist 1 if showing a location list
{only with the +quickfix feature}
quickfix 1 if quickfix or location list window
--- 4818,4826 ----
Each List item is a Dictionary with the following entries:
bufnr number of buffer in the window
! height window height (excluding winbar)
! winbar 1 if the window has a toolbar, 0
! otherwise
loclist 1 if showing a location list
{only with the +quickfix feature}
quickfix 1 if quickfix or location list window
***************
*** 6992,7000 ****
:for [n, l] in [[5, 'aaa'], [6, 'bbb'], [7, 'ccc']]
: call setline(n, l)
:endfor
< Note: The '[ and '] marks are not set.
! setloclist({nr}, {list}[, {action}[, {what}]]) *setloclist()*
Create or replace or add to the location list for window {nr}.
{nr} can be the window number or the |window-ID|.
When {nr} is zero the current window is used.
--- 7012,7021 ----
:for [n, l] in [[5, 'aaa'], [6, 'bbb'], [7, 'ccc']]
: call setline(n, l)
:endfor
+
< Note: The '[ and '] marks are not set.
! setloclist({nr}, {list} [, {action} [, {what}]]) *setloclist()*
Create or replace or add to the location list for window {nr}.
{nr} can be the window number or the |window-ID|.
When {nr} is zero the current window is used.
***************
*** 7062,7070 ****
also set the preferred column. Also see the "curswant" key in
|winrestview()|.
! setqflist({list} [, {action}[, {what}]]) *setqflist()*
Create or replace or add to the quickfix list.
!
When {what} is not present, use the items in {list}. Each
item must be a dictionary. Non-dictionary items in {list} are
ignored. Each dictionary item can contain the following
--- 7083,7091 ----
also set the preferred column. Also see the "curswant" key in
|winrestview()|.
! setqflist({list} [, {action} [, {what}]]) *setqflist()*
Create or replace or add to the quickfix list.
!
When {what} is not present, use the items in {list}. Each
item must be a dictionary. Non-dictionary items in {list} are
ignored. Each dictionary item can contain the following
***************
*** 7103,7114 ****
'a' The items from {list} are added to the existing
quickfix list. If there is no existing list, then a
new list is created.
!
'r' The items from the current quickfix list are replaced
with the items from {list}. This can also be used to
clear the list: >
:call setqflist([], 'r')
! <
'f' All the quickfix lists in the quickfix stack are
freed.
--- 7124,7135 ----
'a' The items from {list} are added to the existing
quickfix list. If there is no existing list, then a
new list is created.
!
'r' The items from the current quickfix list are replaced
with the items from {list}. This can also be used to
clear the list: >
:call setqflist([], 'r')
! <
'f' All the quickfix lists in the quickfix stack are
freed.
*** ../vim-8.0.1383/runtime/doc/quickfix.txt 2017-09-11 19:30:58.585288878
+0200
--- runtime/doc/quickfix.txt 2017-12-10 15:18:29.392726339 +0100
***************
*** 1,4 ****
! *quickfix.txt* For Vim version 8.0. Last change: 2016 Jul 17
VIM REFERENCE MANUAL by Bram Moolenaar
--- 1,4 ----
! *quickfix.txt* For Vim version 8.0. Last change: 2017 Sep 13
VIM REFERENCE MANUAL by Bram Moolenaar
***************
*** 47,57 ****
*quickfix-ID*
Each quickfix list has a unique identifier called the quickfix ID and this
number will not change within a Vim session. The getqflist() function can be
- used to get the identifier assigned to a list.
-
- *quickfix-ID*
- Each quickfix list has a unique identifier called the quickfix ID and this
- number will not change within a Vim session. The getqflist() function can be
used to get the identifier assigned to a list. There is also a quickfix list
number which may change whenever more than ten lists are added to a quickfix
stack.
--- 47,52 ----
***************
*** 346,351 ****
--- 341,390 ----
au QuickfixCmdPost make call QfMakeConv()
Another option is using 'makeencoding'.
+ *quickfix-title*
+ Every quickfix and location list has a title. By default the title is set to
+ the command that created the list. The |getqflist()| and |getloclist()|
+ functions can be used to get the title of a quickfix and a location list
+ respectively. The |setqflist()| and |setloclist()| functions can be used to
+ modify the title of a quickfix and location list respectively. Examples: >
+ call setqflist([], 'a', {'title' : 'Cmd output'})
+ echo getqflist({'title' : 1})
+ call setloclist(3, [], 'a', {'title' : 'Cmd output'})
+ echo getloclist(3, {'title' : 1})
+ <
+ *quickfix-size*
+ You can get the number of entries (size) in a quickfix and a location list
+ using the |getqflist()| and |getloclist()| functions respectively. Examples: >
+ echo getqflist({'size' : 1})
+ echo getloclist(5, {'size' : 1})
+ <
+ *quickfix-context*
+ Any Vim type can be associated as a context with a quickfix or location list.
+ The |setqflist()| and the |setloclist()| functions can be used to associate a
+ context with a quickfix and a location list respectively. The |getqflist()|
+ and the |getloclist()| functions can be used to retrieve the context of a
+ quickifx and a location list respectively. This is useful for a Vim plugin
+ dealing with multiple quickfix/location lists.
+ Examples: >
+
+ let somectx = {'name' : 'Vim', 'type' : 'Editor'}
+ call setqflist([], 'a', {'context' : somectx})
+ echo getqflist({'context' : 1})
+
+ let newctx = ['red', 'green', 'blue']
+ call setloclist(2, [], 'a', {'id' : qfid, 'context' : newctx})
+ echo getloclist(2, {'id' : qfid, 'context' : 1})
+ <
+ *quickfix-parse*
+ You can parse a list of lines using 'erroformat' without creating or modifying
+ a quickfix list using the |getqflist()| function. Examples: >
+ echo getqflist({'lines' : ["F1:10:Line10", "F2:20:Line20"]})
+ echo getqflist({'lines' : systemlist('grep -Hn quickfix *')})
+ This returns a dictionary where the 'items' key contains the list of quickfix
+ entries parsed from lines. The following shows how to use a custom
+ 'errorformat' to parse the lines without modifying the 'erroformat' option: >
+ echo getqflist({'efm' : '%f#%l#%m', 'lines' : ['F1#10#Line']})
+ <
EXECUTE A COMMAND IN ALL THE BUFFERS IN QUICKFIX OR LOCATION LIST:
*:cdo*
***************
*** 547,552 ****
--- 586,598 ----
yet set, then it is set to the location list displayed in the location list
window.
+ *quickfix-window-ID*
+ You can use the |getqflist()| and |getloclist()| functions to obtain the
+ window ID of the quickfix window and location list window respectively (if
+ present). Examples: >
+ echo getqflist({'winid' : 1}).winid
+ echo getloclist(2, {'winid' : 1}).winid
+ <
=============================================================================
3. Using more than one list of errors *quickfix-error-lists*
***************
*** 591,596 ****
--- 637,650 ----
browsing with ":grep" |grep|. If you want to keep the more recent error
lists, use ":cnewer 99" first.
+ To get the number of lists in the quickfix and location list stack, you can
+ use the |getqflist()| and |getloclist()| functions respectively with the list
+ number set to the special value '$'. Examples: >
+ echo getqflist({'nr' : '$'}).nr
+ echo getloclist(3, {'nr' : '$'}).nr
+ To get the number of the current list in the stack: >
+ echo getqflist({'nr' : 0}).nr
+ <
=============================================================================
4. Using :make *:make_makeprg*
*** ../vim-8.0.1383/src/quickfix.c 2017-11-28 18:03:39.932084408 +0100
--- src/quickfix.c 2017-12-10 15:18:29.396726319 +0100
***************
*** 4949,4957 ****
if ((status == OK) && (flags & QF_GETLIST_WINID))
{
win_T *win;
win = qf_find_win(qi);
if (win != NULL)
! status = dict_add_nr_str(retdict, "winid", win->w_id, NULL);
}
if ((status == OK) && (flags & QF_GETLIST_ITEMS))
{
--- 4949,4960 ----
if ((status == OK) && (flags & QF_GETLIST_WINID))
{
win_T *win;
+ int win_id = 0;
+
win = qf_find_win(qi);
if (win != NULL)
! win_id = win->w_id;
! status = dict_add_nr_str(retdict, "winid", win_id, NULL);
}
if ((status == OK) && (flags & QF_GETLIST_ITEMS))
{
*** ../vim-8.0.1383/src/testdir/test_quickfix.vim 2017-11-28
18:03:39.932084408 +0100
--- src/testdir/test_quickfix.vim 2017-12-10 15:18:29.396726319 +0100
***************
*** 28,34 ****
command! -count -nargs=* -bang Xprev <mods><count>cprev<bang> <args>
command! -nargs=* -bang Xfirst <mods>cfirst<bang> <args>
command! -nargs=* -bang Xlast <mods>clast<bang> <args>
! command! -nargs=* -bang Xnfile <mods>cnfile<bang> <args>
command! -nargs=* -bang Xpfile <mods>cpfile<bang> <args>
command! -nargs=* Xexpr <mods>cexpr <args>
command! -range -nargs=* Xvimgrep <mods><count>vimgrep <args>
--- 28,34 ----
command! -count -nargs=* -bang Xprev <mods><count>cprev<bang> <args>
command! -nargs=* -bang Xfirst <mods>cfirst<bang> <args>
command! -nargs=* -bang Xlast <mods>clast<bang> <args>
! command! -nargs=* -bang -range Xnfile <mods><count>cnfile<bang> <args>
command! -nargs=* -bang Xpfile <mods>cpfile<bang> <args>
command! -nargs=* Xexpr <mods>cexpr <args>
command! -range -nargs=* Xvimgrep <mods><count>vimgrep <args>
***************
*** 36,41 ****
--- 36,42 ----
command! -nargs=* Xgrep <mods> grep <args>
command! -nargs=* Xgrepadd <mods> grepadd <args>
command! -nargs=* Xhelpgrep helpgrep <args>
+ command! -nargs=0 -count Xcc <count>cc
let g:Xgetlist = function('getqflist')
let g:Xsetlist = function('setqflist')
call setqflist([], 'f')
***************
*** 60,66 ****
command! -count -nargs=* -bang Xprev <mods><count>lprev<bang> <args>
command! -nargs=* -bang Xfirst <mods>lfirst<bang> <args>
command! -nargs=* -bang Xlast <mods>llast<bang> <args>
! command! -nargs=* -bang Xnfile <mods>lnfile<bang> <args>
command! -nargs=* -bang Xpfile <mods>lpfile<bang> <args>
command! -nargs=* Xexpr <mods>lexpr <args>
command! -range -nargs=* Xvimgrep <mods><count>lvimgrep <args>
--- 61,67 ----
command! -count -nargs=* -bang Xprev <mods><count>lprev<bang> <args>
command! -nargs=* -bang Xfirst <mods>lfirst<bang> <args>
command! -nargs=* -bang Xlast <mods>llast<bang> <args>
! command! -nargs=* -bang -range Xnfile <mods><count>lnfile<bang> <args>
command! -nargs=* -bang Xpfile <mods>lpfile<bang> <args>
command! -nargs=* Xexpr <mods>lexpr <args>
command! -range -nargs=* Xvimgrep <mods><count>lvimgrep <args>
***************
*** 68,73 ****
--- 69,75 ----
command! -nargs=* Xgrep <mods> lgrep <args>
command! -nargs=* Xgrepadd <mods> lgrepadd <args>
command! -nargs=* Xhelpgrep lhelpgrep <args>
+ command! -nargs=0 -count Xcc <count>ll
let g:Xgetlist = function('getloclist', [0])
let g:Xsetlist = function('setloclist', [0])
call setloclist(0, [], 'f')
***************
*** 382,393 ****
func Xtest_browse(cchar)
call s:setup_commands(a:cchar)
" Jumping to first or next location list entry without any error should
" result in failure
! if a:cchar == 'l'
! call assert_fails('lfirst', 'E776:')
! call assert_fails('lnext', 'E776:')
endif
call s:create_test_file('Xqftestfile1')
call s:create_test_file('Xqftestfile2')
--- 384,401 ----
func Xtest_browse(cchar)
call s:setup_commands(a:cchar)
+ call g:Xsetlist([], 'f')
" Jumping to first or next location list entry without any error should
" result in failure
! if a:cchar == 'c'
! let err = 'E42:'
! else
! let err = 'E776:'
endif
+ call assert_fails('Xnext', err)
+ call assert_fails('Xprev', err)
+ call assert_fails('Xnfile', err)
+ call assert_fails('Xpfile', err)
call s:create_test_file('Xqftestfile1')
call s:create_test_file('Xqftestfile2')
***************
*** 408,413 ****
--- 416,427 ----
Xpfile
call assert_equal('Xqftestfile1', bufname('%'))
call assert_equal(6, line('.'))
+ 5Xcc
+ call assert_equal(5, g:Xgetlist({'idx':0}).idx)
+ 2Xcc
+ call assert_equal(2, g:Xgetlist({'idx':0}).idx)
+ 10Xcc
+ call assert_equal(6, g:Xgetlist({'idx':0}).idx)
Xlast
Xprev
call assert_equal('Xqftestfile2', bufname('%'))
***************
*** 425,430 ****
--- 439,461 ----
call assert_equal('Xqftestfile1', bufname('%'))
call assert_equal(5, line('.'))
+ " Jumping to an error from the error window using cc command
+ Xgetexpr ['Xqftestfile1:5:Line5',
+ \ 'Xqftestfile1:6:Line6',
+ \ 'Xqftestfile2:10:Line10',
+ \ 'Xqftestfile2:11:Line11']
+ Xopen
+ 10Xcc
+ call assert_equal(11, line('.'))
+ call assert_equal('Xqftestfile2', bufname('%'))
+
+ " Jumping to an error from the error window (when only the error window is
+ " present)
+ Xopen | only
+ Xlast 1
+ call assert_equal(5, line('.'))
+ call assert_equal('Xqftestfile1', bufname('%'))
+
Xexpr ""
call assert_fails('Xnext', 'E42:')
***************
*** 1497,1509 ****
set switchbuf=usetab
tabedit Xqftestfile1
tabedit Xqftestfile2
tabfirst
cfirst | cnext
call assert_equal(2, tabpagenr())
2cnext
call assert_equal(3, tabpagenr())
! 2cnext
! call assert_equal(3, tabpagenr())
tabfirst | tabonly | enew
set switchbuf=split
--- 1528,1545 ----
set switchbuf=usetab
tabedit Xqftestfile1
tabedit Xqftestfile2
+ tabedit Xqftestfile3
tabfirst
cfirst | cnext
call assert_equal(2, tabpagenr())
2cnext
call assert_equal(3, tabpagenr())
! 6cnext
! call assert_equal(4, tabpagenr())
! 2cpfile
! call assert_equal(2, tabpagenr())
! 2cnfile
! call assert_equal(4, tabpagenr())
tabfirst | tabonly | enew
set switchbuf=split
***************
*** 2320,2326 ****
Xclose
endfunc
! " Tests for the quickifx free functionality
func Test_qf_free()
call XfreeTests('c')
call XfreeTests('l')
--- 2356,2362 ----
Xclose
endfunc
! " Tests for the quickfix free functionality
func Test_qf_free()
call XfreeTests('c')
call XfreeTests('l')
***************
*** 2747,2749 ****
--- 2783,2882 ----
call Xqfid_tests('c')
call Xqfid_tests('l')
endfunc
+
+ func Xqfjump_tests(cchar)
+ call s:setup_commands(a:cchar)
+
+ call writefile(["Line1\tFoo", "Line2"], 'F1')
+ call writefile(["Line1\tBar", "Line2"], 'F2')
+ call writefile(["Line1\tBaz", "Line2"], 'F3')
+
+ call g:Xsetlist([], 'f')
+
+ " Tests for
+ " Jumping to a line using a pattern
+ " Jumping to a column greater than the last column in a line
+ " Jumping to a line greater than the last line in the file
+ let l = []
+ for i in range(1, 7)
+ call add(l, {})
+ endfor
+ let l[0].filename='F1'
+ let l[0].pattern='Line1'
+ let l[1].filename='F2'
+ let l[1].pattern='Line1'
+ let l[2].filename='F3'
+ let l[2].pattern='Line1'
+ let l[3].filename='F3'
+ let l[3].lnum=1
+ let l[3].col=9
+ let l[3].vcol=1
+ let l[4].filename='F3'
+ let l[4].lnum=99
+ let l[5].filename='F3'
+ let l[5].lnum=1
+ let l[5].col=99
+ let l[5].vcol=1
+ let l[6].filename='F3'
+ let l[6].pattern='abcxyz'
+
+ call g:Xsetlist([], ' ', {'items' : l})
+ Xopen | only
+ 2Xnext
+ call assert_equal(3, g:Xgetlist({'idx' : 0}).idx)
+ call assert_equal('F3', bufname('%'))
+ Xnext
+ call assert_equal(7, col('.'))
+ Xnext
+ call assert_equal(2, line('.'))
+ Xnext
+ call assert_equal(9, col('.'))
+ 2
+ Xnext
+ call assert_equal(2, line('.'))
+
+ if a:cchar == 'l'
+ " When jumping to a location list entry in the location list window and
+ " no usable windows are available, then a new window should be opened.
+ enew! | new | only
+ call g:Xsetlist([], 'f')
+ setlocal buftype=nofile
+ new
+ call g:Xsetlist([], ' ', {'lines' : ['F1:1:1:Line1', 'F1:2:2:Line2',
'F2:1:1:Line1', 'F2:2:2:Line2', 'F3:1:1:Line1', 'F3:2:2:Line2']})
+ Xopen
+ let winid = win_getid()
+ wincmd p
+ close
+ call win_gotoid(winid)
+ Xnext
+ call assert_equal(3, winnr('$'))
+ call assert_equal(1, winnr())
+ call assert_equal(2, line('.'))
+
+ " When jumping to an entry in the location list window and the window
+ " associated with the location list is not present and a window containing
+ " the file is already present, then that window should be used.
+ close
+ belowright new
+ call g:Xsetlist([], 'f')
+ edit F3
+ call win_gotoid(winid)
+ Xlast
+ call assert_equal(3, winnr())
+ call assert_equal(6, g:Xgetlist({'size' : 1}).size)
+ call assert_equal(winid, g:Xgetlist({'winid' : 1}).winid)
+ endif
+
+ " Cleanup
+ enew!
+ new | only
+
+ call delete('F1')
+ call delete('F2')
+ call delete('F3')
+ endfunc
+
+ func Test_qfjump()
+ call Xqfjump_tests('c')
+ call Xqfjump_tests('l')
+ endfunc
*** ../vim-8.0.1383/src/version.c 2017-12-09 21:10:09.610735718 +0100
--- src/version.c 2017-12-10 15:20:55.563927459 +0100
***************
*** 773,774 ****
--- 773,776 ----
{ /* Add new patch number below this line */
+ /**/
+ 1384,
/**/
--
% cat /usr/include/life.h
void life(void);
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
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.