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

Re: mkdir completion not offering ignored patterns



So, disregard my previous message (see below).

On Apr 12,  8:52am, Aleksandrina Nikolova wrote:
} Subject: Re: mkdir completion not offering ignored patterns
}
} On 12/04/15 06:44, Bart Schaefer wrote:
} > autoload +X _mkdir
} > functions[_mkdir]="${functions[_mkdir]:s/_wanted/_tags directories;_requested}"
} 
} Hi and thank you for replying! Your suggested solution changes nothing 
} for me though, not sure why it works for you. If it's of any importance, 
} my zsh version is 5.0.7

Hm.  I must have tweaked something else in the course of trying things
that led to that, because *just* that's not sufficient for me either.

I went back through and discovered that I had not fully cleared some test
styles and still had an ignored-patterns with a different context.

Re-reading your original description more closely:

> I have set the 
> completion system to ignore hidden files and only show them when there 
> are no other options (no other files in the listed directory or I 
> explicitly type . at the beginning).

This actually should be the default behavior with no ignored-patterns set
at all.  So that made me confused about this:

>      zstyle ':completion:*:((*-|)files|(*-|)directories)' ignored-patterns '(*/|).[^/]##'
> 
> Commenting the second one disables hiding of hidden files for all 
> commands and I get those offered by mkdir along with non-hidden ones.

The only thing I can figure out is that you must use the GLOB_DOTS option,
which causes _path_files to generate matches for hidden files.  Perhaps
that is an option for which completion should have a style override.

Once I got that straight I was able to find the real reason for:

> It works perfectly with all 
> commands but mkdir, which simply refuses to offer hidden files, ever.

Which turns out to be that _mkdir calls _message which breaks out of the
loop over _completers in _main_complete, so the _ignored completer in your
style is never reached.

This would not happen if you did not have a "format" style for the context
with tag "descriptions" (which is used as a fallback for tag "messages").

_message really ought to be called only when there is no possibility of
other completions being generated, not merely to suggest what ought to
be typed at that point.  Either that or it needs some option (the inverse
of "_message -e"?) that tells _main_complete to continue even though a
message is pending.

There is at least a workaround:

   zstyle ':completion::*:mkdir::messages' format ''



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