Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: _approximate doesn't work
- X-seq: zsh-workers 24570
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: Re: _approximate doesn't work
- Date: Tue, 19 Feb 2008 00:29:35 -0800
- In-reply-to: <080218013338.ZM15026@xxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <200802171925.m1HJPbE8009696@xxxxxxxxxxxxxxxxxxx> <080218013338.ZM15026@xxxxxxxxxxxxxxxxxxxxxx>
[Redirected to -workers]
On Feb 18, 1:33am, Bart Schaefer wrote:
} Subject: Re: _approximate doesn't work
}
} On Feb 17, 7:25pm, Peter Stephenson wrote:
} }
} } The problem is around this bit that's used if descriptions
} } for the commands are needed (the verbose style is set and at least some
} } commands have descriptions):
} }
} } for cmd in ${(@)commands[(I)$PREFIX*]}; do
} [...]
} } I can see that _path_commands is skipping this loop, indicating the
} } expansion was empty. However, I can't see why this is happening.
}
} Hmm, I get
}
} : _path_commands:15:then then for; line=whatis: -s: unknown option
I tweaked _path_commands to replace "whatis -s" with "apropos" and now
I can reproduce the original failure.
The problem is that at the line above in _path_commands, PREFIX is
always "xsane_g" (using PWS's test) and never "(#a1)xsane_g".
Looking through the output, PREFIX gets set by the replacement compadd
created via _approximate -- but that doesn't happen until *inside* the
call to _wanted, long after the test in _path_commands.
So the solution is to remove the attempt by _path_commands to pre-filter
on PREFIX, and instead simply pass the whole damned array through, as is
done with "compadd -k commands" in the no-descriptions branch.
However, I must say that I'm not all that thrilled with the whole idea
behind _path_commands, now that I look at it. Caching or not, I don't
really want the entire contents of the whatis database dumped into my
shell. Consequently I'm quite happy at the moment that "whatis -s"
does not work correctly on my system, and I'd respectfully ask that
someone else undertake to add a much more specific ztyle than just
(as currently used) "verbose", that must be set to enable this.
Meanwhile, here's the simple patch to fix the prefix matching.
Index: Completion/Unix/Type/_path_commands
--- zsh-forge/current/Completion/Unix/Type/_path_commands 2007-08-19 16:04:10.000000000 -0700
+++ zsh-4.3/Completion/Unix/Type/_path_commands 2008-02-18 20:55:51.000000000 -0800
@@ -52,7 +52,7 @@
if [[ -n $need_desc ]]; then
typeset -a dcmds descs cmds
local desc cmd sep
- for cmd in ${(@)commands[(I)$PREFIX*]}; do
+ for cmd in ${(k)commands}; do
desc=$_command_descriptions[$cmd]
if [[ -z $desc ]]; then
cmds+=$cmd
--
Messages sorted by:
Reverse Date,
Date,
Thread,
Author