Re: getcompletion() and 'wildignore' setting
Yegappan wrote: > >> >> The getcompletion() function applies the 'wildignore' option setting > >> >> and removes all the entries matching the file patterns in > >> >> 'wildignore'. Currently, there is no way to disable this. Do you think > >> >> we should add a 'flag' argument to getcompletion() to ignore/support > >> >> 'wildignore'? > >> > > >> > Yes, that makes sense. Perhaps a generic flag whether to return what > >> > would happen on the command line, or the "full result" without > >> > filtering. We should also document that 'wildignore' is used for > >> > getcompletion(), it only mentions expand() and glob(). > >> > > >> > >> I am attaching a patch to add an optional argument to the > >> getcompletion() function. When the optional argument is set > >> to TRUE, then the 'wildignore' and 'wildignore' settings are > >> applied. Otherwise the unfiltered results are returned. > > > > Hmm, despite the similarity in name, 'wildignore' and 'wildignorecase' > > do very different things. I think 'wildignorecase' should always be > > used. Thus the extra argument only controls 'wildignore'. Thus it's a > > flag to switch between "all results" and "filtered results". While > > 'wildignorecase' changes what matches, which I would think should always > > happen. > > > > An updated patch is attached to do the above. Thanks. I'll add a test case. -- hundred-and-one symptoms of being an internet addict: 15. Your heart races faster and beats irregularly each time you see a new WWW site address in print or on TV, even though you've never had heart problems before. /// Bram Moolenaar -- b...@moolenaar.net -- 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 vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: getcompletion() and 'wildignore' setting
Hi Bram, On Fri, Aug 12, 2016 at 10:17 AM, Bram Moolenaarwrote: > > Yegappan wrote: > >> >> The getcompletion() function applies the 'wildignore' option setting >> >> and removes all the entries matching the file patterns in >> >> 'wildignore'. Currently, there is no way to disable this. Do you think >> >> we should add a 'flag' argument to getcompletion() to ignore/support >> >> 'wildignore'? >> > >> > Yes, that makes sense. Perhaps a generic flag whether to return what >> > would happen on the command line, or the "full result" without >> > filtering. We should also document that 'wildignore' is used for >> > getcompletion(), it only mentions expand() and glob(). >> > >> >> I am attaching a patch to add an optional argument to the >> getcompletion() function. When the optional argument is set >> to TRUE, then the 'wildignore' and 'wildignore' settings are >> applied. Otherwise the unfiltered results are returned. > > Hmm, despite the similarity in name, 'wildignore' and 'wildignorecase' > do very different things. I think 'wildignorecase' should always be > used. Thus the extra argument only controls 'wildignore'. Thus it's a > flag to switch between "all results" and "filtered results". While > 'wildignorecase' changes what matches, which I would think should always > happen. > An updated patch is attached to do the 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 vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 39765d5..fb92e63 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -2092,7 +2092,8 @@ getcmdline() String return the current command-line getcmdpos()Number return cursor position in command-line getcmdtype() String return current command-line type getcmdwintype()String return current command-line window type -getcompletion({pat}, {type}) Listlist of cmdline completion matches +getcompletion({pat}, {type} [, {filtered}]) + Listlist of cmdline completion matches getcurpos()Listposition of the cursor getcwd([{winnr} [, {tabnr}]]) String get the current working directory getfontname([{name}]) String name of font being used @@ -4158,7 +4159,7 @@ getcmdwintype() *getcmdwintype()* values are the same as |getcmdtype()|. Returns an empty string when not in the command-line window. -getcompletion({pat}, {type}) *getcompletion()* +getcompletion({pat}, {type} [, {filtered}])*getcompletion()* Return a list of command-line completion matches. {type} specifies what for. The following completion types are supported: @@ -4198,6 +4199,10 @@ getcompletion({pat}, {type}) *getcompletion()* Otherwise only items matching {pat} are returned. See |wildcards| for the use of special characters in {pat}. + If the optional {filtered} flag is set to 1, then 'wildignore' + is applied to filter the results. Otherwise all the matches + are returned. The 'wildignorecase' option always applies. + If there are no matches, an empty list is returned. An invalid value for {type} produces an error. diff --git a/src/evalfunc.c b/src/evalfunc.c index 8b5ad22..d94ee35 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -581,7 +581,7 @@ static struct fst {"getcmdtype", 0, 0, f_getcmdtype}, {"getcmdwintype", 0, 0, f_getcmdwintype}, #if defined(FEAT_CMDL_COMPL) -{"getcompletion", 2, 2, f_getcompletion}, +{"getcompletion", 2, 3, f_getcompletion}, #endif {"getcurpos", 0, 0, f_getcurpos}, {"getcwd", 0, 2, f_getcwd}, @@ -4220,12 +4220,20 @@ f_getcompletion(typval_T *argvars, typval_T *rettv) { char_u *pat; expand_T xpc; +intfiltered = FALSE; intoptions = WILD_SILENT | WILD_USE_NL | WILD_ADD_SLASH | WILD_NO_BEEP; +if (argvars[2].v_type != VAR_UNKNOWN) + filtered = get_tv_number_chk([2], NULL); + if (p_wic) options |= WILD_ICASE; +/* For filtered results, 'wildignore' is used */ +if (!filtered) + options |= WILD_KEEP_ALL; + ExpandInit(); xpc.xp_pattern = get_tv_string([0]); xpc.xp_pattern_len =
Re: getcompletion() and 'wildignore' setting
Yegappan wrote: > >> The getcompletion() function applies the 'wildignore' option setting > >> and removes all the entries matching the file patterns in > >> 'wildignore'. Currently, there is no way to disable this. Do you think > >> we should add a 'flag' argument to getcompletion() to ignore/support > >> 'wildignore'? > > > > Yes, that makes sense. Perhaps a generic flag whether to return what > > would happen on the command line, or the "full result" without > > filtering. We should also document that 'wildignore' is used for > > getcompletion(), it only mentions expand() and glob(). > > > > I am attaching a patch to add an optional argument to the > getcompletion() function. When the optional argument is set > to TRUE, then the 'wildignore' and 'wildignore' settings are > applied. Otherwise the unfiltered results are returned. Hmm, despite the similarity in name, 'wildignore' and 'wildignorecase' do very different things. I think 'wildignorecase' should always be used. Thus the extra argument only controls 'wildignore'. Thus it's a flag to switch between "all results" and "filtered results". While 'wildignorecase' changes what matches, which I would think should always happen. -- Me? A skeptic? I trust you have proof. /// Bram Moolenaar -- b...@moolenaar.net -- 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 vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: getcompletion() and 'wildignore' setting
Hi Bram, On Tue, Aug 9, 2016 at 12:52 PM, Bram Moolenaarwrote: > > Yegappan wrote: > >> The getcompletion() function applies the 'wildignore' option setting >> and removes all the entries matching the file patterns in >> 'wildignore'. Currently, there is no way to disable this. Do you think >> we should add a 'flag' argument to getcompletion() to ignore/support >> 'wildignore'? > > Yes, that makes sense. Perhaps a generic flag whether to return what > would happen on the command line, or the "full result" without > filtering. We should also document that 'wildignore' is used for > getcompletion(), it only mentions expand() and glob(). > I am attaching a patch to add an optional argument to the getcompletion() function. When the optional argument is set to TRUE, then the 'wildignore' and 'wildignore' settings are applied. Otherwise the unfiltered results are returned. - 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 vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 39765d5..dc88473 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -2092,7 +2092,8 @@ getcmdline() String return the current command-line getcmdpos()Number return cursor position in command-line getcmdtype() String return current command-line type getcmdwintype()String return current command-line window type -getcompletion({pat}, {type}) Listlist of cmdline completion matches +getcompletion({pat}, {type} [, {cmdline}]) + Listlist of cmdline completion matches getcurpos()Listposition of the cursor getcwd([{winnr} [, {tabnr}]]) String get the current working directory getfontname([{name}]) String name of font being used @@ -4158,7 +4159,7 @@ getcmdwintype() *getcmdwintype()* values are the same as |getcmdtype()|. Returns an empty string when not in the command-line window. -getcompletion({pat}, {type}) *getcompletion()* +getcompletion({pat}, {type} [, {cmdline}]) *getcompletion()* Return a list of command-line completion matches. {type} specifies what for. The following completion types are supported: @@ -4198,6 +4199,11 @@ getcompletion({pat}, {type}) *getcompletion()* Otherwise only items matching {pat} are returned. See |wildcards| for the use of special characters in {pat}. + If the optional {cmdline} flag is supplied, then 'wildignore' + and 'wildignorecase' are applied to filter the results. + Otherwise, these options are ignored and all the matches are + returned. + If there are no matches, an empty list is returned. An invalid value for {type} produces an error. diff --git a/src/evalfunc.c b/src/evalfunc.c index 8b5ad22..1c2e364 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -581,7 +581,7 @@ static struct fst {"getcmdtype", 0, 0, f_getcmdtype}, {"getcmdwintype", 0, 0, f_getcmdwintype}, #if defined(FEAT_CMDL_COMPL) -{"getcompletion", 2, 2, f_getcompletion}, +{"getcompletion", 2, 3, f_getcompletion}, #endif {"getcurpos", 0, 0, f_getcurpos}, {"getcwd", 0, 2, f_getcwd}, @@ -4220,12 +4220,23 @@ f_getcompletion(typval_T *argvars, typval_T *rettv) { char_u *pat; expand_T xpc; +intcmdline_flag = FALSE; intoptions = WILD_SILENT | WILD_USE_NL | WILD_ADD_SLASH | WILD_NO_BEEP; -if (p_wic) +if (argvars[2].v_type != VAR_UNKNOWN) + cmdline_flag = get_tv_number_chk([2], NULL); + +/* + * For command line completion like results, 'wildignorecase' and + * 'wildignore' applies + */ +if (cmdline_flag && p_wic) options |= WILD_ICASE; +if (!cmdline_flag) + options |= WILD_KEEP_ALL; + ExpandInit(); xpc.xp_pattern = get_tv_string([0]); xpc.xp_pattern_len = (int)STRLEN(xpc.xp_pattern);
Re: getcompletion() and 'wildignore' setting
Yegappan wrote: > The getcompletion() function applies the 'wildignore' option setting > and removes all the entries matching the file patterns in > 'wildignore'. Currently, there is no way to disable this. Do you think > we should add a 'flag' argument to getcompletion() to ignore/support > 'wildignore'? Yes, that makes sense. Perhaps a generic flag whether to return what would happen on the command line, or the "full result" without filtering. We should also document that 'wildignore' is used for getcompletion(), it only mentions expand() and glob(). -- EXPERIENCE - experience is a wonderful thing. It enables you to recognise a mistake when you make it again. /// Bram Moolenaar -- b...@moolenaar.net -- 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 vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
getcompletion() and 'wildignore' setting
Hi, The getcompletion() function applies the 'wildignore' option setting and removes all the entries matching the file patterns in 'wildignore'. Currently, there is no way to disable this. Do you think we should add a 'flag' argument to getcompletion() to ignore/support 'wildignore'? Thanks, 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 vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.