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

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



On 6 January 2011 19:42, Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> On 6 January 2011 18:24, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>> On Jan 6, Â8:41am, Bart Schaefer wrote:
>>>
>>> > 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 guess I'll have a go at fixing _mkdir then...

Well, this is not my day. First I had _du in site-functions so nothing
I did fixed it (I figured this out before sending the previous mail).
Then as I was trying to fix _mkdir, I just did a cp **/_mkdir
$fpath[3] to save some time. BUT of course I had -test-3 in that shell
and the new shell had -dev-1 so that copy didn't have any effect. Heh.

Anyway here is a patch for _mkdir:
http://git.mika.l3ib.org/?p=zsh-cvs.git;a=patch;h=80fbf4aa928361bb9f60819c7b8d1922f1732487

Subject: [PATCH] _mkdir: don't set ret=0 when _wanted fails to find any matches

---
 Completion/Unix/Command/_mkdir |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/Completion/Unix/Command/_mkdir b/Completion/Unix/Command/_mkdir
index 927b9df..b5f7519 100644
--- a/Completion/Unix/Command/_mkdir
+++ b/Completion/Unix/Command/_mkdir
@@ -60,9 +60,8 @@ case "$state" in
     if (( $ret )) && [[ ! -prefix - ]] || \
       [[ $variant == zsh && ${#${${words[2,-1]}:#-*}} -gt 0 ]]; then
       _wanted directories expl \
-	'parent directory (alternatively specify name of directory)' \
-	_path_files -/ || _message 'name of directory'
-      ret=0
+        'parent directory (alternatively specify name of directory)' \
+        _path_files -/ && ret=0 || _message 'name of directory'
     fi
     ;;
 esac
-- 
1.7.3


-- 
Mikael Magnusson



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