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

Re: completion but extra options allowed



On Feb 10,  7:51pm, Andy Spiegl wrote:
} Subject: Re: completion but extra options allowed
}
} > This means that you type "mutt -f +<TAB>" and zsh will complete files in
} > your $HOME/Mail directory following the + sign.  Mutt understands the + as
} > an abbreviation for the mail directory.  In the absence of a +, zsh just
} > completes file names after "mutt -f".
} This is exactly what I am trying to teach zsh-3.1.6.pws16 to do.

The follow only sort of accomplishes it.  I now get:

zagzig[166] mutt -f +z<TAB>
zagzig[166] mutt -f /home/schaefer/Mail/z<TAB>
/home/schaefer/Mail/zanshin           /home/schaefer/Mail/zsh-maintenance 
/home/schaefer/Mail/zsh
<BEEP>

That is, the first TAB replaces the + with the $maildirectory path, the
second TAB lists the completions.

There has to be a better way.

One thing that makes this difficult is that _path_files does not accept
the -i option of compadd, only the -P option.  However, even calling

compadd -i + -f -W ~/Mail

directly does not accomplish what I expected it to.  Is this a bug, or am
I missing something?  What IS the compadd equivalent of

compctl -x 's[+] c[-1,-f],s[-f+]' -W ~/Mail -f ...

Index: Completion/User/_mailboxes
===================================================================
@@ -38,5 +38,9 @@
   _mailbox_cache=($_mailbox_cache $mboxes $maildirboxes $MHboxes)
 fi
 
-_wanted files expl 'mailbox specification' &&
+if _wanted files expl 'mailbox specification'; then
+    local opre=$PREFIX
+    [[ $PREFIX = +* ]] && PREFIX="$~maildirectory/${PREFIX#+}"
     compadd "$@" "$expl[@]" - "$_mailbox_cache[@]"
+    PREFIX=$opre
+fi

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com



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