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

Re: Dynamic named directories and completion



On Sat, Feb 24, 2018 at 8:34 PM, Peter Stephenson
<p.w.stephenson@xxxxxxxxxxxx> wrote:
> On Fri, 23 Feb 2018 09:42:37 -0500
> Scott Frazer <frazer.scott@xxxxxxxxx> wrote:
>> >> cd ~[ccc]/<TAB>
>> >>
>> >> zsh doesn't give me options for directories under ccc, it thinks '/' is
>> >> the command I'm trying to complete.  Is there a way to make this work?
>> >
>> > I don't see anything wrong in your code and for me, it works as you
>> > expect (zsh 5.4.2). Does "echo ~[ccc]" returns the right value?
>> >
>>
>> Yes, "echo ~[ccc]" works correctly.  I'm using zsh 5.3 so maybe there is some
>> difference there.  Perhaps there is some difference in options/modules/etc.  If
>> I cut my .zshrc down to a minimum:
>
> There's something screwy here, certainly.  I don't think it should be
> necessary to modify _path_files in 5.3, though, there are certainly
> cases where you get the right answer, and I think the logic that currently
> handles ~ at the start should do the right thing here.
>
> I've a theory it's down to the completion widget in use, i.e. how
> completion gets started up.  If instead of hitting tab, you type <Esc>x
> complete-word<Enter> --- or instead bind that widget,
>
> bindkey '^i' complete-word
>
> and then use tab --- does it start working?  The default is
> expand-or-complete, and I believe the expand bit is nixing the
> completion in this case.  (Except we don't really have the word "nix"
> this side of the Atlantic, so I may be talking nonsense, but it sounded
> good.)

I have some patches I was working on related to this, but I assume
there was still some problem, or I would have committed them...
There's two patches in this thread,
http://www.zsh.org/mla/workers/2015/msg01439.html and then I think I
never sent the third one,

diff --git a/Completion/Unix/Type/_files b/Completion/Unix/Type/_files
index 2b0c5580a5..067f68d9d9 100644
--- a/Completion/Unix/Type/_files
+++ b/Completion/Unix/Type/_files
@@ -103,7 +103,7 @@ for def in "$pats[@]"; do
         if [[ -n "$end" ]]; then
           if _path_files -g "$pat" "$opts[@]" "$expl[@]"; then
         ret=0
-      elif [[ $PREFIX$SUFFIX != */* ]] && zstyle -a
":completion:${curcontext}:$tag" recursive-files rfiles; then
+      elif [[ ${${:-$PREFIX$SUFFIX}#\~\[[^]]#]} != */* ]] && zstyle
-a ":completion:${curcontext}:$tag" recursive-files rfiles; then
         local subtree
         for rfile in $rfiles; do
           if [[ $PWD/ = ${~rfile} ]]; then


-- 
Mikael Magnusson



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