Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Completion problems on cygwin when nocaseglob is set

"Vin Shelton" wrote:
> I'm very confused.  Running zsh built from the latest CVS sources,
> here's what I see:

... even with NO_CASE_GLOB set, completion doesn't match
case-insensitively unless there's a matcher spec to do it.

Oh dear, I hate it when people are confused about completion because
that invariably means a hard time.

It looks like _path_files is doing the right thing internally (via
compfiles, which understands glob settings), but it then passes the
matched string to compadd without the -U flag, which says "sorry mate,
it's more than my job's worth to match case-insensitively".  _path_files
does most of its file handling itself or via compfiles, but it doesn't
do the special matching stuff, hence we can't pass -U in that case.

We could make a rule that we use case-insensitive matching with
NO_CASE_GLOB unless an explicit matcher spec is in force, I suppose, but
we can't actually have the combined effect of nocaseglob and matchers
without either some kind of internal rewrite, or editing the matchers
passed down through _path_files.  If the former is acceptable, this is
fairly straightforward.

Index: Completion/Unix/Type/_path_files
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_path_files,v
retrieving revision 1.25
diff -u -r1.25 _path_files
--- Completion/Unix/Type/_path_files	7 Mar 2006 12:52:27 -0000	1.25
+++ Completion/Unix/Type/_path_files	24 Oct 2007 15:08:14 -0000
@@ -101,7 +101,16 @@
   (( $mopts[(I)-F] )) || mopts=( "$mopts[@]" -F _comp_ignore )
-(( $#matcher )) && mopts=( "$mopts[@]" "$matcher[@]" )
+if [[ $#matcher -eq 0 && -o nocaseglob ]]; then
+  # If globbing is case insensitive and there's no matcher,
+  # do case-insensitive matching.
+  matcher=( -M 'm:{a-zA-Z}={A-Za-z}' )
+if (( $#matcher )); then
+  # Add the current matcher to the options to compadd.
+  mopts=( "$mopts[@]" "$matcher[@]" )
 if zstyle -s ":completion:${curcontext}:" file-sort tmp1; then
   case "$tmp1" in
Index: Doc/Zsh/compsys.yo
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compsys.yo,v
retrieving revision 1.202
diff -u -r1.202 compsys.yo
--- Doc/Zsh/compsys.yo	19 Jun 2007 09:28:06 -0000	1.202
+++ Doc/Zsh/compsys.yo	24 Oct 2007 15:08:22 -0000
@@ -1968,6 +1968,11 @@
 one to three strings will give acceptable performance.  On the other
 hand, putting multiple space-separated values into the same string does
 not have an appreciable impact on performance.
+If there is no current matcher or it is empty, and the option
+tt(NO_CASE_GLOB) is in effect, the matching for files is performed
+case-insensitively in any case.  However, any matcher must
+explicitly specify case-insensitive matching if that is required.
 kindex(max-errors, completion style)

Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070

Messages sorted by: Reverse Date, Date, Thread, Author