On 24-Jun-08 12:07, Bram Moolenaar wrote: > > Ingo Karkat wrote: > >> On 20-Jun-08 18:34, Ingo Karkat wrote: >>> On 20-Jun-08 17:59, Ben Fritz wrote: >>>> I have a script that creates files like this: >>>> >>>> file.ext -> file.ext.ann_out.ext >>>> >>>> I don't want to see these files when I do filename completion, because >>>> they clutter up my wildmenu. For this reason, I put: >>>> >>>> set wildignore+=*.ann_out.* >>>> >>>> into my .vimrc. >>>> >>>> Now, when I do this: >>>> >>>> gvim --remote-tab-silent file.ext.ann_out.ext >>>> >>>> I get "E479: No match" >>>> >>>> When I just do gvim file.ext.ann_out.ext, the file opens fine. >>>> >>>> When I remove the setting of wildignore from my vimrc, both methods >>>> work fine. >>>> >>>> VIM - Vi IMproved 7.1 (2007 May 12, compiled Jun 18 2008 07:22:20) >>>> MS-Windows 32 bit GUI version with OLE support >>>> Included patches: 1-315 >>>> Compiled by [EMAIL PROTECTED] >>>> Big version with GUI. Features included (+) or not (-): >>>> +arabic +autocmd +balloon_eval +browse ++builtin_terms +byte_offset >>>> +cindent >>>> +clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info >>>> +comments >>>> +cryptv +cscope +cursorshape +dialog_con_gui +diff +digraphs -dnd - >>>> ebcdic >>>> +emacs_tags +eval +ex_extra +extra_search +farsi +file_in_path >>>> +find_in_path >>>> +folding -footer +gettext/dyn -hangul_input +iconv/dyn +insert_expand >>>> +jumplist >>>> +keymap +langmap +libcall +linebreak +lispindent +listcmds +localmap >>>> +menu >>>> +mksession +modify_fname +mouse +mouseshape +multi_byte_ime/dyn >>>> +multi_lang >>>> +mzscheme/dyn +netbeans_intg +ole -osfiletype +path_extra +perl/dyn - >>>> postscript >>>> +printer -profile +python/dyn +quickfix +reltime +rightleft +ruby/ >>>> dyn >>>> +scrollbind +signs +smartindent -sniff +statusline -sun_workshop >>>> +syntax >>>> +tag_binary +tag_old_static -tag_any_white +tcl/dyn -tgetent - >>>> termresponse >>>> +textobjects +title +toolbar +user_commands +vertsplit +virtualedit >>>> +visual >>>> +visualextra +viminfo +vreplace +wildignore +wildmenu +windows >>>> +writebackup >>>> -xfontset -xim -xterm_save -xpm_w32 >>>> system vimrc file: "$VIM\vimrc" >>>> user vimrc file: "$HOME\_vimrc" >>>> 2nd user vimrc file: "$VIM\_vimrc" >>>> user exrc file: "$HOME\_exrc" >>>> 2nd user exrc file: "$VIM\_exrc" >>>> system gvimrc file: "$VIM\gvimrc" >>>> user gvimrc file: "$HOME\_gvimrc" >>>> 2nd user gvimrc file: "$VIM\_gvimrc" >>>> system menu file: "$VIMRUNTIME\menu.vim" >>>> Compilation: gcc -O3 -fomit-frame-pointer -freg-struct-return -fno- >>>> strength-reduce -DWIN32 -DHAVE_PATHDEF -DFEAT_BIG -DWINVER=0x0400 - >>>> D_WIN32_WINNT=0x0400 -DFEAT_PERL -DDYNAMIC_PERL - >>>> DDYNAMIC_PERL_DLL="perl58.dll" -DFEAT_PYTHON -DDYNAMIC_PYTHON - >>>> DDYNAMIC_PYTHON_DLL="python25.dll" -DFEAT_RUBY -DDYNAMIC_RUBY - >>>> DDYNAMIC_RUBY_DLL="msvcrt-ruby18.dll" -DDYNAMIC_RUBY_VER=18 - >>>> DFEAT_MZSCHEME -DDYNAMIC_MZSCHEME - >>>> DDYNAMIC_MZSCH_DLL="libmzsch370.dll" - >>>> DDYNAMIC_MZGC_DLL="libmzgc370.dll" -DFEAT_TCL -DDYNAMIC_TCL - >>>> DDYNAMIC_TCL_DLL="tcl84.dll" -DDYNAMIC_GETTEXT -DDYNAMIC_ICONV - >>>> DFEAT_MBYTE -DFEAT_MBYTE_IME -DDYNAMIC_IME -DFEAT_CSCOPE - >>>> DFEAT_NETBEANS_INTG -DFEAT_GUI_W32 -DFEAT_CLIPBOARD -DFEAT_OLE - >>>> march=i386 -Iproto -I/cygdrive/c/PERL/lib/CORE -I/cygdrive/c/PYTHON25/ >>>> include -I/cygdrive/c/RUBY/lib/ruby/1.8/i386-mswin32 -I/cygdrive/c/ >>>> PROGRA~1/MzScheme/include -I/cygdrive/c/Tcl/include -s -mno-cygwin >>>> Linking: gcc -s -o gvim.exe -luuid -lole32 /cygdrive/c/Tcl/lib/ >>>> tclstub84.lib -lwsock32 -mwindows -lcomctl32 -lversion -loleaut32 - >>>> lstdc++ >>> I have made an observation that may be related to this: >>> The 'wildignore' option influences / filters the output of glob(): >>> >>> gvim -N -u NONE >>> :cd $VIMRUNTIME/tools >>> :echo glob("efm*") >>> efm_filter.pl >>> efm_filter.txt >>> efm_perl.pl >>> :set wildignore=*.txt >>> :echo glob("efm*") >>> efm_filter.pl >>> efm_perl.pl >>> >>> I didn't expect this. :help 'wildignore' mentions: >>> A file that matches with one of these patterns is ignored when >>> completing >>> file or directory names. >>> But it isn't obvious that glob() is doing filename completion; its >>> documented >>> purpose is to "*expand* the file wildcards in {expr}". >>> >>> So, does this work as expected, or is it a bug that the implementation of >>> glob() >>> is affected by 'wildignore'? In the first case, I would appreciate it if a >>> note >>> is added to the help texts for 'wildignore' and glob(). >>> >>> -- regards, ingo >>> >>> PS: Sorry for potentially hijacking this thread; I don't know whether this >>> actually is related. >>> >>> /^-- Ingo Karkat -- /^-- /^-- /^-- /^-- /^-- /^-- http://ingo-karkat.de/ -- >> Nobody has commented yet; are there any opinions? Bram? >>> So, does this work as expected, or is it a bug that the implementation of >>> glob() is affected by 'wildignore'? >> I'd rather classify this as a bug. I had to temporarily reset >> 'wildignore' once in a script to get around this; on the other hand, >> if I want filtering of filenames, I can always filter() the glob() >> output. > > Glob() has always worked this way, changing it might break something. > So let's document it. Perhaps an extra option to glob() and globpath > can be used to, ehm, ignore 'wildignore'.
You're right on, Bram, expand() already has this extra option. Please see attached patch 'wildignore.diff', which adds this optional flag to glob() and globpath(), too. (Additionally, I've renamed the local variable 'flag' to 'expand_options' in f_expand() for consistency, fixed a wrong comment statement about 'suffixes' in there, and added the missing optional expand({expr} [, {flag}]) argument in the :help functions documentation.) In case you don't want to introduce this change in VIM 7.2 any more, I've done a documentation-only update in 'wildignore_doconly.diff', which mentions the glob()-connection at :help 'wildignore' and clarifies the effects of 'wildignore' and 'suffixes' at :help glob() and :help globpath(). -- regards, ingo PS: My initial statement was wrong, the glob - wildignore connection _was_ documented, but only in the latest runtime files. It's not very intuitive that the latest runtime isn't in the CVS / Subversion repository, but I've learned that by now ;-) --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_dev" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---
Index: src/eval.c =================================================================== *** src/eval.c (revision 1075) --- src/eval.c (working copy) *************** *** 7144,7151 **** {"getwinposx", 0, 0, f_getwinposx}, {"getwinposy", 0, 0, f_getwinposy}, {"getwinvar", 2, 2, f_getwinvar}, ! {"glob", 1, 1, f_glob}, ! {"globpath", 2, 2, f_globpath}, {"has", 1, 1, f_has}, {"has_key", 2, 2, f_has_key}, {"haslocaldir", 0, 0, f_haslocaldir}, --- 7144,7151 ---- {"getwinposx", 0, 0, f_getwinposx}, {"getwinposy", 0, 0, f_getwinposy}, {"getwinvar", 2, 2, f_getwinvar}, ! {"glob", 1, 2, f_glob}, ! {"globpath", 2, 3, f_globpath}, {"has", 1, 1, f_has}, {"has_key", 2, 2, f_has_key}, {"haslocaldir", 0, 0, f_haslocaldir}, *************** *** 8972,8978 **** char_u *s; int len; char_u *errormsg; ! int flags = WILD_SILENT|WILD_USE_NL|WILD_LIST_NOTFOUND; expand_T xpc; int error = FALSE; --- 8972,8978 ---- char_u *s; int len; char_u *errormsg; ! int expand_options = WILD_SILENT|WILD_USE_NL|WILD_LIST_NOTFOUND; expand_T xpc; int error = FALSE; *************** *** 8987,9001 **** else { /* When the optional second argument is non-zero, don't remove matches ! * for 'suffixes' and 'wildignore' */ if (argvars[1].v_type != VAR_UNKNOWN && get_tv_number_chk(&argvars[1], &error)) ! flags |= WILD_KEEP_ALL; if (!error) { ExpandInit(&xpc); xpc.xp_context = EXPAND_FILES; ! rettv->vval.v_string = ExpandOne(&xpc, s, NULL, flags, WILD_ALL); } else rettv->vval.v_string = NULL; --- 8987,9001 ---- else { /* When the optional second argument is non-zero, don't remove matches ! * for 'wildignore' and don't put matches for 'suffixes' at the end. */ if (argvars[1].v_type != VAR_UNKNOWN && get_tv_number_chk(&argvars[1], &error)) ! expand_options |= WILD_KEEP_ALL; if (!error) { ExpandInit(&xpc); xpc.xp_context = EXPAND_FILES; ! rettv->vval.v_string = ExpandOne(&xpc, s, NULL, expand_options, WILD_ALL); } else rettv->vval.v_string = NULL; *************** *** 10709,10721 **** typval_T *argvars; typval_T *rettv; { expand_T xpc; ! ExpandInit(&xpc); ! xpc.xp_context = EXPAND_FILES; ! rettv->v_type = VAR_STRING; ! rettv->vval.v_string = ExpandOne(&xpc, get_tv_string(&argvars[0]), ! NULL, WILD_USE_NL|WILD_SILENT, WILD_ALL); } /* --- 10709,10733 ---- typval_T *argvars; typval_T *rettv; { + int expand_options = WILD_SILENT|WILD_USE_NL; expand_T xpc; + int error = FALSE; ! /* When the optional second argument is non-zero, don't remove matches ! * for 'wildignore' and don't put matches for 'suffixes' at the end. */ ! if (argvars[1].v_type != VAR_UNKNOWN ! && get_tv_number_chk(&argvars[1], &error)) ! expand_options |= WILD_KEEP_ALL; ! rettv->v_type = VAR_STRING; ! if (!error) ! { ! ExpandInit(&xpc); ! xpc.xp_context = EXPAND_FILES; ! rettv->vval.v_string = ExpandOne(&xpc, get_tv_string(&argvars[0]), ! NULL, expand_options, WILD_ALL); ! } ! else ! rettv->vval.v_string = NULL; } /* *************** *** 10726,10739 **** typval_T *argvars; typval_T *rettv; { char_u buf1[NUMBUFLEN]; char_u *file = get_tv_string_buf_chk(&argvars[1], buf1); rettv->v_type = VAR_STRING; ! if (file == NULL) rettv->vval.v_string = NULL; else ! rettv->vval.v_string = globpath(get_tv_string(&argvars[0]), file); } /* --- 10738,10758 ---- typval_T *argvars; typval_T *rettv; { + int expand_options = 0; char_u buf1[NUMBUFLEN]; char_u *file = get_tv_string_buf_chk(&argvars[1], buf1); + int error = FALSE; + /* When the optional second argument is non-zero, don't remove matches + * for 'wildignore' and don't put matches for 'suffixes' at the end. */ + if (argvars[2].v_type != VAR_UNKNOWN + && get_tv_number_chk(&argvars[2], &error)) + expand_options |= WILD_KEEP_ALL; rettv->v_type = VAR_STRING; ! if (file == NULL || error) rettv->vval.v_string = NULL; else ! rettv->vval.v_string = globpath(get_tv_string(&argvars[0]), file, expand_options); } /* Index: src/ex_getln.c =================================================================== *** src/ex_getln.c (revision 1075) --- src/ex_getln.c (working copy) *************** *** 4851,4857 **** if (s == NULL) return FAIL; sprintf((char *)s, "%s/%s*.vim", dirname, pat); ! all = globpath(p_rtp, s); vim_free(s); if (all == NULL) return FAIL; --- 4851,4857 ---- if (s == NULL) return FAIL; sprintf((char *)s, "%s/%s*.vim", dirname, pat); ! all = globpath(p_rtp, s, 0); vim_free(s); if (all == NULL) return FAIL; *************** *** 4892,4900 **** * newlines. Returns NULL for an error or no matches. */ char_u * ! globpath(path, file) char_u *path; char_u *file; { expand_T xpc; char_u *buf; --- 4892,4901 ---- * newlines. Returns NULL for an error or no matches. */ char_u * ! globpath(path, file, expand_options) char_u *path; char_u *file; + int expand_options; { expand_T xpc; char_u *buf; *************** *** 4923,4932 **** { add_pathsep(buf); STRCAT(buf, file); ! if (ExpandFromContext(&xpc, buf, &num_p, &p, WILD_SILENT) != FAIL && num_p > 0) { ! ExpandEscape(&xpc, buf, num_p, p, WILD_SILENT); for (len = 0, i = 0; i < num_p; ++i) len += (int)STRLEN(p[i]) + 1; --- 4924,4933 ---- { add_pathsep(buf); STRCAT(buf, file); ! if (ExpandFromContext(&xpc, buf, &num_p, &p, WILD_SILENT|expand_options) != FAIL && num_p > 0) { ! ExpandEscape(&xpc, buf, num_p, p, WILD_SILENT|expand_options); for (len = 0, i = 0; i < num_p; ++i) len += (int)STRLEN(p[i]) + 1; Index: src/proto/ex_getln.pro =================================================================== *** src/proto/ex_getln.pro (revision 1075) --- src/proto/ex_getln.pro (working copy) *************** *** 31,37 **** void set_cmd_context __ARGS((expand_T *xp, char_u *str, int len, int col)); int expand_cmdline __ARGS((expand_T *xp, char_u *str, int col, int *matchcount, char_u ***matches)); int ExpandGeneric __ARGS((expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***file, char_u *((*func)(expand_T *, int)))); ! char_u *globpath __ARGS((char_u *path, char_u *file)); void init_history __ARGS((void)); int get_histtype __ARGS((char_u *name)); void add_to_history __ARGS((int histype, char_u *new_entry, int in_map, int sep)); --- 31,37 ---- void set_cmd_context __ARGS((expand_T *xp, char_u *str, int len, int col)); int expand_cmdline __ARGS((expand_T *xp, char_u *str, int col, int *matchcount, char_u ***matches)); int ExpandGeneric __ARGS((expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***file, char_u *((*func)(expand_T *, int)))); ! char_u *globpath __ARGS((char_u *path, char_u *file, int expand_options)); void init_history __ARGS((void)); int get_histtype __ARGS((char_u *name)); void add_to_history __ARGS((int histype, char_u *new_entry, int in_map, int sep)); *** runtime/doc/eval.txt.orig 2008-06-25 15:39:49.000000000 +0200 --- runtime/doc/eval.txt 2008-06-25 15:43:58.000000000 +0200 *************** *** 1690,1696 **** exists( {expr}) Number TRUE if {expr} exists extend({expr1}, {expr2} [, {expr3}]) List/Dict insert items of {expr2} into {expr1} ! expand( {expr}) String expand special keywords in {expr} feedkeys( {string} [, {mode}]) Number add key sequence to typeahead buffer filereadable( {file}) Number TRUE if {file} is a readable file filewritable( {file}) Number TRUE if {file} is a writable file --- 1690,1696 ---- exists( {expr}) Number TRUE if {expr} exists extend({expr1}, {expr2} [, {expr3}]) List/Dict insert items of {expr2} into {expr1} ! expand( {expr} [, {flag}]) String expand special keywords in {expr} feedkeys( {string} [, {mode}]) Number add key sequence to typeahead buffer filereadable( {file}) Number TRUE if {file} is a readable file filewritable( {file}) Number TRUE if {file} is a writable file *************** *** 1742,1749 **** getwinposx() Number X coord in pixels of GUI Vim window getwinposy() Number Y coord in pixels of GUI Vim window getwinvar( {nr}, {varname}) any variable {varname} in window {nr} ! glob( {expr}) String expand file wildcards in {expr} ! globpath( {path}, {expr}) String do glob({expr}) for all dirs in {path} has( {feature}) Number TRUE if feature {feature} supported has_key( {dict}, {key}) Number TRUE if {dict} has entry {key} haslocaldir() Number TRUE if current window executed |:lcd| --- 1742,1750 ---- getwinposx() Number X coord in pixels of GUI Vim window getwinposy() Number Y coord in pixels of GUI Vim window getwinvar( {nr}, {varname}) any variable {varname} in window {nr} ! glob( {expr} [, {flag}]) String expand file wildcards in {expr} ! globpath( {path}, {expr} [, {flag}]) ! String do glob({expr}) for all dirs in {path} has( {feature}) Number TRUE if feature {feature} supported has_key( {dict}, {key}) Number TRUE if {dict} has entry {key} haslocaldir() Number TRUE if current window executed |:lcd| *************** *** 3255,3268 **** :let list_is_on = getwinvar(2, '&list') :echo "myvar = " . getwinvar(1, 'myvar') < ! *glob()* ! glob({expr}) Expand the file wildcards in {expr}. See |wildcards| for the use of special characters. The result is a String. When there are several matches, they are separated by <NL> characters. ! The 'wildignore' option applies: Names matching one of the ! patterns in 'wildignore' will be skipped. If the expansion fails, the result is an empty string. A name for a non-existing file is not included. --- 3256,3271 ---- :let list_is_on = getwinvar(2, '&list') :echo "myvar = " . getwinvar(1, 'myvar') < ! glob({expr} [, {flag}]) *glob()* ! Expand the file wildcards in {expr}. See |wildcards| for the use of special characters. The result is a String. When there are several matches, they are separated by <NL> characters. ! Unless the optional {flag} argument is given and is non-zero, ! the 'suffixes' and 'wildignore' options apply: Names matching ! one of the patterns in 'wildignore' will be skipped; ! 'suffixes' affect the ordering of matches. If the expansion fails, the result is an empty string. A name for a non-existing file is not included. *************** *** 3276,3282 **** See |expand()| for expanding special Vim variables. See |system()| for getting the raw output of an external command. ! globpath({path}, {expr}) *globpath()* Perform glob() on all directories in {path} and concatenate the results. Example: > :echo globpath(&rtp, "syntax/c.vim") --- 3279,3285 ---- See |expand()| for expanding special Vim variables. See |system()| for getting the raw output of an external command. ! globpath({path}, {expr} [, {flag}]) *globpath()* Perform glob() on all directories in {path} and concatenate the results. Example: > :echo globpath(&rtp, "syntax/c.vim") *************** *** 3288,3295 **** trailing backslash, remove it if you put a comma after it. If the expansion fails for one of the directories, there is no error message. ! The 'wildignore' option applies: Names matching one of the ! patterns in 'wildignore' will be skipped. The "**" item can be used to search in a directory tree. For example, to find all "README.txt" files in the directories --- 3291,3300 ---- trailing backslash, remove it if you put a comma after it. If the expansion fails for one of the directories, there is no error message. ! Unless the optional {flag} argument is given and is non-zero, ! the 'suffixes' and 'wildignore' options apply: Names matching ! one of the patterns in 'wildignore' will be skipped; ! 'suffixes' affect the ordering of matches. The "**" item can be used to search in a directory tree. For example, to find all "README.txt" files in the directories *** runtime/doc/options.txt.orig 2008-06-25 13:50:53.000000000 +0200 --- runtime/doc/options.txt 2008-06-25 14:21:33.000000000 +0200 *************** *** 7484,7490 **** {not available when compiled without the |+wildignore| feature} A list of file patterns. A file that matches with one of these ! patterns is ignored when completing file or directory names. The pattern is used like with |:autocmd|, see |autocmd-patterns|. Also see 'suffixes'. Example: > --- 7484,7491 ---- {not available when compiled without the |+wildignore| feature} A list of file patterns. A file that matches with one of these ! patterns is ignored when completing file or directory names, and can ! be omitted from the result of |expand()|, |glob()| and |globpath()|. The pattern is used like with |:autocmd|, see |autocmd-patterns|. Also see 'suffixes'. Example: >
*** runtime/doc/eval.txt.orig 2008-06-25 13:57:00.000000000 +0200 --- runtime/doc/eval.txt 2008-06-25 14:09:59.000000000 +0200 *************** *** 3261,3268 **** The result is a String. When there are several matches, they are separated by <NL> characters. ! The 'wildignore' option applies: Names matching one of the ! patterns in 'wildignore' will be skipped. If the expansion fails, the result is an empty string. A name for a non-existing file is not included. --- 3261,3269 ---- The result is a String. When there are several matches, they are separated by <NL> characters. ! The 'suffixes' and 'wildignore' options apply: Names matching ! one of the patterns in 'wildignore' will be skipped; ! 'suffixes' affect the ordering of matches. If the expansion fails, the result is an empty string. A name for a non-existing file is not included. *************** *** 3288,3295 **** trailing backslash, remove it if you put a comma after it. If the expansion fails for one of the directories, there is no error message. ! The 'wildignore' option applies: Names matching one of the ! patterns in 'wildignore' will be skipped. The "**" item can be used to search in a directory tree. For example, to find all "README.txt" files in the directories --- 3289,3297 ---- trailing backslash, remove it if you put a comma after it. If the expansion fails for one of the directories, there is no error message. ! The 'suffixes' and 'wildignore' options apply: Names matching ! one of the patterns in 'wildignore' will be skipped; ! 'suffixes' affect the ordering of matches. The "**" item can be used to search in a directory tree. For example, to find all "README.txt" files in the directories *** runtime/doc/options.txt.orig 2008-06-25 13:50:53.000000000 +0200 --- runtime/doc/options.txt 2008-06-25 14:15:55.000000000 +0200 *************** *** 7484,7490 **** {not available when compiled without the |+wildignore| feature} A list of file patterns. A file that matches with one of these ! patterns is ignored when completing file or directory names. The pattern is used like with |:autocmd|, see |autocmd-patterns|. Also see 'suffixes'. Example: > --- 7484,7491 ---- {not available when compiled without the |+wildignore| feature} A list of file patterns. A file that matches with one of these ! patterns is ignored when completing file or directory names, and is ! omitted from the result of |expand()|, |glob()| and |globpath()|. The pattern is used like with |:autocmd|, see |autocmd-patterns|. Also see 'suffixes'. Example: >