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

Re: matcher-list doesn't work with some completers?



On Jan 6, 11:14am, Mikael Magnusson wrote:
} Subject: matcher-list doesn't work with some completers?
} 
} mkdir 'a directory'
} zsh -f
} autoload -Uz compinit; compinit -D
} zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' +'l:|=* r:|=*'
} ls dir<tab> #works
} du dir<tab> #nothing

This is a bug in _du, it's returning a 0 status without ever adding any
matches, which causes _dispatch in turn to report success to _complete
which then skips running the matcher-list.

This in turn is because _du checks for a state transition to handle the
--time and --time-style options, and that case statement masks the
return value from _arguments.

I don't know for sure whether the fix is to save the return value from
_arguments and then return that in a (*) branch of the case statement,
or to return immediately if _arguments fails and not bother checking
the state transition at all.  _mkdir does the former, so ...

Someone with copious free time should do a sweep of the completion
functions and make sure they're correctly propagating return values
from _arguments, _wanted, etc.


Index: Completion/Unix/Command/_du
===================================================================
RCS file: /extra/cvsroot/zsh/zsh-4.0/Completion/Unix/Command/_du,v
retrieving revision 1.4
diff -c -r1.4 _du
--- _du	21 Dec 2010 16:41:15 -0000	1.4
+++ _du	6 Jan 2011 16:38:35 -0000
@@ -1,6 +1,8 @@
 #compdef du
 
 if _pick_variant gnu=Free\ Soft unix --version /dummy/no-such-file; then
+  local ret=1
+
   _arguments -s \
     '(-a --all -s --summarize)'{-a,--all}'[write counts for all files]' \
     '--apparent-size[print apparent sizes rather than disc usage]' \
@@ -27,22 +29,24 @@
     '--time=-[show time of last modification of any file in the
directory]:property:->time' \
     '(* -)--help[display help information]' \
     '(* -)--version[display version information]' \
-    '*:file:_files'
+    '*:file:_files' && ret=0
 
   case $state in
     (time)
       local -a property
       property=(atime access use ctime status)
-      _wanted property expl property compadd -a property
+      _wanted property expl property compadd -a property && ret=0
       ;;
     (timestyle)
       local -a style desc
       style=(full-iso long-iso iso +)
       desc=('full-iso' 'long-iso' 'iso' '+FORMAT like `date'\''')
-      _wanted -V style expl style compadd -d desc -a style
+      _wanted -V style expl style compadd -d desc -a style && ret=0
       ;;
   esac
 
+  return ret
+
 else
   # based on $OSTYPE = solaris2.8
   local xdev='[skip directories on different filesystems]'


-- 



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