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

Re: mail paths and IMAP



On 2006-06-21 at 13:23 +0200, Phil Pennock wrote:
> I'm having trouble twisting the new completion system to another of my
> whims.  I'd like to be able to tab-complete IMAP mail-folders.  I have
> GSSAPI authentication, so no password prompt is needed, and I have a
> tool which will list all subscribed folders, one per line.  I can make
> this work interactively, but want to automate it.  Could someone please
> point me to which bit of the completion system I need to be using to do
> this (preferably a snippet, if it's "just" configuration):

Solved.

The key is to keep the data from being overriden, which can be done by
zstyle'ing muttrc to /nonexistant.

~/.zshrc contains (inter alia):

-----------------------------< cut here >-------------------------------
export IMAP_SERVER=host.example.net
# ...
function smutt { mutt "${(@)argv[1,-2]}" -f "+Shared Folders/shared/$argv[-1]" }

function init_mua_completion {
        typeset -aU -g imap_folders _mutt_cache
        imap_folders=(${(@f):-"$(mailcheck -B -l 2>/dev/null)"})

        zstyle ':completion:*' muttrc /nonexistant      # override _mutt_cache
        zstyle ':completion:*' mail-directory imap://$IMAP_SERVER/

        mailpath=(imap://$IMAP_SERVER/$imap_folders)	# not used yet
        _mutt_cache=(+$imap_folders)
        compdef '_values ${${(M)imap_folders:#Shared Folders/shared/*}#Shared Folders/shared/}' smutt
# 'mutt -f +<x>' actually relative to $(mutt -Q folder)
}
klist -t && init_mua_completion
-----------------------------< cut here >-------------------------------

and I can choose my own method for calling init_mua_completion in the
window which calls kinit.
-- 
VISTA: Viruses, Infections, Spyware, Trojans & Adware



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