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

Re: site-function for completion from specific directory



On Tue, 26 Aug 2014 15:00:24 +0200
Eric Smith <es@xxxxxxxxxxxx> wrote:
> Oh zshellers,
> 
> This is my use case.
> 
> I want to complete the following command;
> mutt -f [foo]<tab>
> 
> so that it expands nothing or the string `foo' as if they were
> ~/Mail/<tab> or ~/Mail/foo<tab>
> respectively.
> 
> How would I write a compdef site-function for this and also
> ideally for my shell function wrapper around `mutt -f'?

If I've understood the basics of what you're trying to do --- check for
mailboxes in your mail directory and complete the bare name, removing
the common directory part --- then this completion should already work.
However, it looks like the function that handles this, _mailboxes from
Completion/Unix/Type/_mailboxes, makes some assumptions about where to
get the values for your mutt configuration.  Try using ^X? to get some
output and work out which paths it's taking through the function.  My
reading of the code (which I'm just looking at for the first time, at
least that I can remember, I expect I glanced at it years ago) is it
should pick the directories in the code following line 152 of that file.
You'll need to trace back where those variables come from if this isn't
happening.

I haven't worked out when you'd want it to complete nothing, and if the
square brackets are somehow crucial to the completion then I'm missing
the point entirely.

pws



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