From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: Improved _mailboxes
Date: Mon, 21 Feb 2000 10:34:22 +0000 [thread overview]
Message-ID: <1000221103422.ZM16650@candle.brasslantern.com> (raw)
This works pretty well, following Sven's most recent patches to _multi_parts.
It now can handle mailboxes for elm, mail, mh, mutt, pine, and zmail.
Things I like it to do that it doesn't yet:
(1) The default style should be to make the all-files group be alternate
completions, i.e., not shown unless the -default- group is empty.
(2) The all-files group for pine (currently commented out) should contain
only full paths, not relative ones. How does one accomplish that?
(3) I'm sometimes offered a blank completion -- an empty slot at the top
of the list of all completions. I don't know where that comes from;
it shouldn't be there. Quoting problem somewhere?
And of course, I haven't yet written any actual completion functions to
call this one; it's used only from _mutt, so far.
Index: Completion/User/_mailboxes
===================================================================
@@ -5,43 +5,89 @@
# 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 pinedirectory="${pinedirectory:-~/mail}"
local maildirectory="${maildirectory:-~/Mail}"
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
- mboxes=( ${~maildirectory}/*(^/) ${~pinedirectory}/**/*(.) )
+ [[ -f ${~muttrc:-.} ]] &&
+ _mutt_cache=( ${$(grep mailboxes ${~muttrc})[2,-1]} )
+
+ _mbox_cache=( ${~maildirectory}/*(^/) )
+ _pine_cache=( ${~pinedirectory}/**/*(.) )
+
dirboxes=( ${~maildirectory}/*(/) )
while (( $#dirboxes )); do
- i=$dirboxes[1]
+ i=${dirboxes[1]}
shift dirboxes
if [[ -d "$i/cur" ]]; then
- maildirboxes=( $maildirboxes $i )
+ _maildir_cache=( "${_maildir_cache[@]}" "$i" )
elif j=( $i/<1-> ) && [[ -n "$j" ]]; then
- MHboxes=( $MHboxes $i )
+ _mh_cache=( "${_mh_cache[@]}" "$i" )
else
- mboxes=( $mboxes $i/*(.) )
+ _mbox_cache=( "${_mbox_cache[@]}" "$i"/*(.) )
dirboxes=( $dirboxes $i/*(/) )
fi
done
- [[ -n "$muttboxes" || -d ~/.elm || -d ~/.mutt ]] &&
- _mailbox_cache=(\! \< \> $muttboxes)
+ [[ -n "$_mutt_cache" || -d ~/.elm || -d ~/.mutt ]] &&
+ _mailbox_cache=( \! \< \> )
[[ -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
if _wanted files expl 'mailbox specification'; then
- if compset -P '+|-f+' || [[ $words[CURRENT-1] = -f ]]; then
- _files -W $maildirectory
+ local -U mbox_names
+ case "${curcontext}" in
+ (*:elm:*) # I've probably got this wrong, or at least incomplete
+ 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[@]" - "$_mailbox_cache[@]"
+ 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
Index: Completion/User/_mutt
===================================================================
@@ -8,7 +8,7 @@
'-b:BCC recipient:->userhost' \
'-c:CC recipient:->userhost' \
'-e:post-init configuration:' \
- '-f+:mailbox:_mailboxes' \
+ '-f+:mailbox: _mailboxes' \
'-F+:init file:_files' \
'-h+:help:' \
'-H+:draft file:_files' \
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
next reply other threads:[~2000-02-21 10:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-02-21 10:34 Bart Schaefer [this message]
2000-02-21 12:30 Sven Wischnowsky
2000-02-21 16:41 ` Bart Schaefer
2000-02-21 20:06 ` Peter Stephenson
2000-02-21 21:59 ` Bart Schaefer
2000-02-22 8:52 Sven Wischnowsky
2000-02-22 17:55 ` Peter Stephenson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1000221103422.ZM16650@candle.brasslantern.com \
--to=schaefer@candle.brasslantern.com \
--cc=zsh-workers@sunsite.auc.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).