Re: RFC: Support for customizing the text displayed in the quickfix window

2019-12-30 Fir de Conversatie skywind3000
Or use one of:

set qbe=*
set qbe=$
set qbe=-
set qbe=?

to distinguish from function names ??

在 2019年12月31日星期二 UTC+8上午2:20:37,skywind3000写道:
>
> Please provide a `raw` reserved option for qfbufexpr, and if it is 
> initialized as:
>
> set qbe=raw
>
> Just keep the original text and don't run any filter function ?? for the 
> speed purpose. And I don't need to write a 
>
> function! ReturnAsItIs(is_qf, qfid, eidx)
> if a:isqf
> let qfl = getqflist({'id' : a:qfid, 'idx' : a:eidx, 'items' : 
> 1}).items
> else
> let qfl = getloclist(0, {'id' : a:qfid, 'idx' : 
> a:eidx,  'items' : 1}).items
> endif
> let e = qfl[0]
> return e.text
> endfunc
>
> set qbe=ReturnAsItIs
>
> It's totally unnecessary for every one to write such function, and it's 
> too slow, so just a 
>
> set qbe=raw
>
> can be much helpful.
>
>

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/729e96f8-92e1-4fed-ad1c-47c5ace9f802%40googlegroups.com.


Re: RFC: Support for customizing the text displayed in the quickfix window

2019-12-30 Fir de Conversatie skywind3000
Please provide a `raw` reserved option for qfbufexpr, and if it is 
initialized as:

set qbe=raw

Just keep the original text and don't run any filter function ?? for the 
speed purpose. And I don't need to write a 

function! ReturnAsItIs(is_qf, qfid, eidx)
if a:isqf
let qfl = getqflist({'id' : a:qfid, 'idx' : a:eidx, 'items' : 
1}).items
else
let qfl = getloclist(0, {'id' : a:qfid, 'idx' : 
a:eidx,  'items' : 1}).items
endif
let e = qfl[0]
return e.text
endfunc

set qbe=ReturnAsItIs

It's totally unnecessary for every one to write such function, and it's too 
slow, so just a 

set qbe=raw

can be much helpful.

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/da1c7c43-5055-4694-9bd3-a47e9a21efe9%40googlegroups.com.


RFC: Support for customizing the text displayed in the quickfix window

2019-12-30 Fir de Conversatie Yegappan Lakshmanan
Hi all,

I have seen several requests for customizing the text displayed
in the quickfix window. I am attaching the updates to the help text
for adding a new "qfbufexpr" option that will support this.
Any comments and suggestions on this approach?

Regards,
Yegappan

diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index 7d8e032cd..6b6614ef0 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -5883,6 +5883,62 @@ A jump table for the options with a short
description can be found at |Q_op|.
  This option cannot be set from a |modeline| or in the |sandbox|, for
  security reasons.

+ *'qfbufexpr'* *'qbe'*
+'qfbufexpr' 'qbe' string (default "")
+ global
+ {only available when compiled with the |+quickfix|
+ feature}
+ Expression for text to display in the quickfix and location list
+ window buffers. The supplied expression should be the name of a Vim
+ function that accepts three arguments. The first argument is set to
+ v:true if the expression is called for a quickfix list. The second
+ argument is the quickfix or location list list identifier. The third
+ argument is the index of the entry in the quickfix or location list.
+ The function should return the text to display in the quickfix buffer.
+ The function is called for each entry in the quickfix list.
+
+ This can be used to customize the information displayed in the
+ quickfix or location buffer for each entry in the corresponding
+ quickfix or location list.
+
+ This option can be overriden by using the |setqflist()| and
+ |setloclist()| functions and setting the 'qfbufexpr' attribute for
+ a quickfix/location list.
+
+ The example below tries to mimic the default behavior for the quickfix
+ and location list buffers.
+ Example: >
+func MyQfExpr(is_qf, qfid, eidx)
+ if a:isqf
+ let qfl = getqflist({'id' : a:qfid, 'idx' : a:eidx,
+ \ 'items' : 1}).items
+ else
+ let qfl = getloclist(0, {'id' : a:qfid, 'idx' : a:eidx,
+ \ 'items' : 1}).items
+ endif
+ let e = qfl[0]
+ let s = ''
+ if e.bufnr != 0
+ let bname = bufname(e.bufnr)
+ let s ..= fnamemodify(bname, ':.')
+ endif
+ let s ..= '|'
+ if e.lnum > 0
+ let s ..= e.lnum
+ if e.col != 0
+ let s ..= ' col ' . e.col
+ endif
+ elseif e.pattern != ''
+ let s ..= e.pattern
+ endif
+ let s ..= '| '
+ let s ..= substitute(e.text, '^\s\+', '', '')
+ return s
+endfunc
+set qfbufexpr=MyQfExpr
+<
+ NOTE: This option is set to "" when 'compatible' is set.
+
  *'quoteescape'* *'qe'*
 'quoteescape' 'qe' string (default "\")
  local to buffer
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index a20f56270..26b677eee 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -5438,8 +5438,9 @@ getqflist([{what}]) *getqflist()*
  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 quickfix
- list specified by 'id' or 'nr'.
+ idx get information for the quickfix entry at this
+ index in the list specified by 'id' or 'nr'.
+ If set to zero, then uses the current entry.
  See |quickfix-index|
  items quickfix list entries
  lines parse a list of lines using 'efm' and return
@@ -5475,7 +5476,7 @@ getqflist([{what}]) *getqflist()*
  If not present, set to "".
  id quickfix list ID |quickfix-ID|. If not
  present, set to 0.
- idx index of the current entry in the list. If not
+ idx index of the quickfix entry in the list. If not
  present, set to 0.
  items quickfix list entries. If not present, set to
  an empty list.
@@ -8658,6 +8659,13 @@ setqflist({list} [, {action} [, {what}]]) *setqflist()*
  nr list number in the quickfix stack; zero
  means the current quickfix list and "$" means
  the last quickfix list.
+ qfbufexpr expression to get the text to display in the
+ quickfix buffer for each entry in the list.
+ This should be set to a Vim function that is
+ called for each entry in the list and should
+ return the text to display. Refer to
+ |'qfbufexpr'| for more information and an
+ example.
  title quickfix list title text. See |quickfix-title|
  Unsupported keys in {what} are ignored.
  If the "nr" item is not present, then the current quickfix list

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/CAAW7x7nu7zjSkdtG8%3DObOeUE2BDDAvK-yHz9hCcPYd47kMMyAA%40mail.gmail.com.