summary refs log tree commit diff
path: root/Completion/User/_mailboxes
blob: c49aa818565d67c45b220fcc104a6d3646ebb764 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#autoload

# This is needlessly mutt-biased and should be fixed.

local expl muttboxes mboxes dirboxes MHboxes maildirboxes muttrc="~/.muttrc" maildirectory="~/Mail"

test -f "$compconfig[muttrc_path]" && muttrc=$compconfig[muttrc_path]
test -f "$compconfig[maildirectory]" && maildirectory=$compconfig[maildirectory]

if (( ! $+_mailbox_cache )) then

test ${muttrc} || test -f ${~muttrc} && muttboxes=( ${(@)$(grep mailboxes ${~muttrc})[2,-1]} )

mboxes=(${~maildirectory}/*(^/))
dirboxes=(${~maildirectory}/*(/))

for i in $dirboxes
do 
if test -d "${i}/cur"
then
maildirboxes=($maildirboxes $i)
else
MHboxes=($MHboxes $i)
fi
done

_mailbox_cache=(\! \< \> $muttboxes $mboxes $maildirboxes $MHboxes)

fi

_description expl 'mailbox specification'
compadd "$@" "$expl[@]" - "$_mailbox_cache[@]"