mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-14 11:41:07 +02:00
manual/9812
This commit is contained in:
parent
e662d7f0eb
commit
986bdad22e
2 changed files with 63 additions and 16 deletions
|
@ -5,42 +5,89 @@ setopt localoptions nullglob
|
||||||
|
|
||||||
# This is still needlessly mutt-biased and should be fixed.
|
# This is still needlessly mutt-biased and should be fixed.
|
||||||
|
|
||||||
local -U muttboxes mboxes dirboxes MHboxes maildirboxes
|
local -U dirboxes
|
||||||
local i j expl muttrc="${muttrc:-~/.muttrc}"
|
local i j expl muttrc="${muttrc:-~/.muttrc}"
|
||||||
local pinedirectory="${pinedirectory:-~/mail}"
|
local pinedirectory="${pinedirectory:-~/mail}"
|
||||||
local maildirectory="${maildirectory:-~/Mail}"
|
local maildirectory="${maildirectory:-~/Mail}"
|
||||||
|
|
||||||
if (( ! $+_mailbox_cache )) then
|
if (( ! $+_mailbox_cache )) then
|
||||||
|
|
||||||
[[ -f ${~muttrc:-.} ]] && muttboxes=( ${$(grep mailboxes ${~muttrc})[2,-1]} )
|
typeset -U -g _mailbox_cache
|
||||||
|
typeset -U -g _maildir_cache _mbox_cache _mh_cache _mutt_cache _pine_cache
|
||||||
|
|
||||||
|
[[ -f ${~muttrc:-.} ]] &&
|
||||||
|
_mutt_cache=( ${$(grep mailboxes ${~muttrc})[2,-1]} )
|
||||||
|
|
||||||
|
_mbox_cache=( ${~maildirectory}/*(^/) )
|
||||||
|
_pine_cache=( ${~pinedirectory}/**/*(.) )
|
||||||
|
|
||||||
mboxes=( ${~maildirectory}/*(^/) ${~pinedirectory}/**/*(.) )
|
|
||||||
dirboxes=( ${~maildirectory}/*(/) )
|
dirboxes=( ${~maildirectory}/*(/) )
|
||||||
|
|
||||||
while (( $#dirboxes )); do
|
while (( $#dirboxes )); do
|
||||||
i=$dirboxes[1]
|
i=${dirboxes[1]}
|
||||||
shift dirboxes
|
shift dirboxes
|
||||||
if [[ -d "$i/cur" ]]; then
|
if [[ -d "$i/cur" ]]; then
|
||||||
maildirboxes=( $maildirboxes $i )
|
_maildir_cache=( "${_maildir_cache[@]}" "$i" )
|
||||||
elif j=( $i/<1-> ) && [[ -n "$j" ]]; then
|
elif j=( $i/<1-> ) && [[ -n "$j" ]]; then
|
||||||
MHboxes=( $MHboxes $i )
|
_mh_cache=( "${_mh_cache[@]}" "$i" )
|
||||||
else
|
else
|
||||||
mboxes=( $mboxes $i/*(.) )
|
_mbox_cache=( "${_mbox_cache[@]}" "$i"/*(.) )
|
||||||
dirboxes=( $dirboxes $i/*(/) )
|
dirboxes=( $dirboxes $i/*(/) )
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
[[ -n "$muttboxes" || -d ~/.elm || -d ~/.mutt ]] &&
|
[[ -n "$_mutt_cache" || -d ~/.elm || -d ~/.mutt ]] &&
|
||||||
_mailbox_cache=(\! \< \> $muttboxes)
|
_mailbox_cache=( \! \< \> )
|
||||||
[[ -n "$mailpath" ]] &&
|
[[ -n "$mailpath" ]] &&
|
||||||
_mailbox_cache=($_mailbox_cache ${mailpath//\?*/})
|
_mailbox_cache=( "${_mailbox_cache[@]}" "${(@)mailpath%%\?*}" )
|
||||||
|
|
||||||
_mailbox_cache=($_mailbox_cache $mboxes $maildirboxes $MHboxes)
|
_mailbox_cache=( "${_mailbox_cache[@]}" $MAIL )
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if _wanted files expl 'mailbox specification'; then
|
if _wanted files expl 'mailbox specification'; then
|
||||||
local opre=$PREFIX
|
local -U mbox_names
|
||||||
[[ $PREFIX = +* ]] && PREFIX="$~maildirectory/${PREFIX#+}"
|
case "${curcontext}" in
|
||||||
compadd "$@" "$expl[@]" - "$_mailbox_cache[@]"
|
(*:elm:*) # I've probably got this wrong, or at least incomplete
|
||||||
PREFIX=$opre
|
compadd "${expl[@]}" - \! \< \>
|
||||||
|
mbox_names=( "${_mbox_cache[@]}" "${_mailbox_cache[@]}" )
|
||||||
|
_multi_parts "${expl[@]}" / mbox_names;;
|
||||||
|
(*:mail:*)
|
||||||
|
if compset -P '+|-f+'; then
|
||||||
|
mbox_names=( "${(@)_mbox_cache#$~maildirectory/}" )
|
||||||
|
_multi_parts "${expl[@]}" / mbox_names
|
||||||
|
else
|
||||||
|
mbox_names=( +"${(@)^_mbox_cache#$~maildirectory/}" "${_mailbox_cache[@]}" )
|
||||||
|
_multi_parts "${expl[@]}" / mbox_names
|
||||||
|
_path_files -J all-files
|
||||||
|
fi;;
|
||||||
|
(*:mh:*) # I've probably got this wrong, or at least incomplete
|
||||||
|
(( $#_mh_cache )) && _multi_parts "${expl[@]}" / _mh_cache;;
|
||||||
|
(*:mutt:*)
|
||||||
|
mbox_names=( "${_mutt_cache[@]}" "${_mailbox_cache[@]}" "${_maildir_cache[@]}" )
|
||||||
|
compadd "${expl[@]}" - \! \< \>
|
||||||
|
_multi_parts "${expl[@]}" / mbox_names;;
|
||||||
|
(*:pine:*)
|
||||||
|
# Pine is like mail but with no leading `+' to disambiguate;
|
||||||
|
# any files not in $pinedirectory must be absolute paths.
|
||||||
|
mbox_names=( "${(@)_pine_cache#$~pinedirectory/}" "${_mbox_cache[@]}" )
|
||||||
|
_multi_parts "${expl[@]}" / mbox_names
|
||||||
|
# _path_files -J all-files -g '/*'
|
||||||
|
;;
|
||||||
|
(*:(zmail|zmlite):*)
|
||||||
|
if compset -P '+|-f+'; then
|
||||||
|
mbox_names=( "${(@)_mbox_cache#$~maildirectory/}" )
|
||||||
|
_multi_parts "${expl[@]}" / mbox_names
|
||||||
|
else
|
||||||
|
compadd "${expl[@]}" - % \&
|
||||||
|
mbox_names=( +"${(@)^_mbox_cache#$~maildirectory/}"
|
||||||
|
"${_mailbox_cache[@]}" "${_mh_cache[@]}" )
|
||||||
|
_multi_parts "${expl[@]}" / mbox_names
|
||||||
|
_path_files -J all-files
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
(*) # Some other program wants mailbox names? Use them all?
|
||||||
|
mbox_names=( "${_mailbox_cache[@]}" "${_mbox_cache[@]}"
|
||||||
|
"${_mh_cache[@]}" "${_mutt_cache[@]}" "${_pine_cache[@]}" )
|
||||||
|
_multi_parts "${expl[@]}" / mbox_names;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -8,7 +8,7 @@ local curcontext="$curcontext" state line ret=1
|
||||||
'-b:BCC recipient:->userhost' \
|
'-b:BCC recipient:->userhost' \
|
||||||
'-c:CC recipient:->userhost' \
|
'-c:CC recipient:->userhost' \
|
||||||
'-e:post-init configuration:' \
|
'-e:post-init configuration:' \
|
||||||
'-f+:mailbox:_mailboxes' \
|
'-f+:mailbox: _mailboxes' \
|
||||||
'-F+:init file:_files' \
|
'-F+:init file:_files' \
|
||||||
'-h+:help:' \
|
'-h+:help:' \
|
||||||
'-H+:draft file:_files' \
|
'-H+:draft file:_files' \
|
||||||
|
|
Loading…
Reference in a new issue