Hi Bram,
On Fri, Aug 12, 2016 at 10:17 AM, Bram Moolenaar <[email protected]> wrote:
>
> 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 [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 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}) List list of cmdline completion matches
+getcompletion({pat}, {type} [, {filtered}])
+ List list of cmdline completion matches
getcurpos() List position 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;
+ int filtered = FALSE;
int options = WILD_SILENT | WILD_USE_NL | WILD_ADD_SLASH
| WILD_NO_BEEP;
+ if (argvars[2].v_type != VAR_UNKNOWN)
+ filtered = get_tv_number_chk(&argvars[2], NULL);
+
if (p_wic)
options |= WILD_ICASE;
+ /* For filtered results, 'wildignore' is used */
+ if (!filtered)
+ options |= WILD_KEEP_ALL;
+
ExpandInit(&xpc);
xpc.xp_pattern = get_tv_string(&argvars[0]);
xpc.xp_pattern_len = (int)STRLEN(xpc.xp_pattern);