From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13279 invoked from network); 18 Sep 1999 23:27:53 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 18 Sep 1999 23:27:53 -0000 Received: (qmail 826 invoked by alias); 18 Sep 1999 23:27:45 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7932 Received: (qmail 819 invoked from network); 18 Sep 1999 23:27:43 -0000 From: "Bart Schaefer" Message-Id: <990918232730.ZM6698@candle.brasslantern.com> Date: Sat, 18 Sep 1999 23:27:29 +0000 In-Reply-To: <19990915173039.A15772@dman.com> Comments: In reply to Clint Adams "PATCH: _mutt, _mailboxes" (Sep 15, 5:30pm) References: <19990915173039.A15772@dman.com> X-Mailer: Z-Mail (5.0.0 30July97) To: Clint Adams , zsh-workers@sunsite.auc.dk Subject: Re: PATCH: _mutt, _mailboxes MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Sep 15, 5:30pm, Clint Adams wrote: } Subject: PATCH: _mutt, _mailboxes } } This is my stab at completion for mutt. I imagine that the } _mailboxes function would be useful for completing the -f arguments } of elm and pine, after some tweaking. } } + test -f "$compconfig[muttrc_path]" && muttrc=$compconfig[muttrc_path] } + test -f "$compconfig[maildirectory]" && maildirectory=$compconfig[maildirectory] The following are updates to _mailboxes to make it somewhat more generic. Other completers don't use compconfig for anything as application-specific as "muttrc_path", so instead I've simply made it recognize the existing settings of $muttrc and $maildirectory if there are any. I've added the paramter $pinedirectory to that set, as Pine by default uses ~/mail where mutt, mush, zmail, and plain ol' mail all use ~/Mail; I could have stabbed at ~/nsmail (netscape communicator) and various other programs' directory names; but I don't really even like the idea of _mailboxes handling the maildir and MH formats, so I didn't. Nevertheless, I did improve (I hope) the handling of MH format as well, to do a better job of recognizing nested mailbox hierarchy. I don't use mutt, so I don't know what ( \! \< \> ) are; do they really represent mailbox names? If not, they should be in _mutt and not here. As I didn't know, I simply relegated them to the same collection of names as those grepped from the .muttrc file, and didn't include them at all if there is no such collection. One thing I didn't do yet is handle a leading "+" in the word that is being completed and treat it as referring to the maildirectory. Index: Completion/User/_mailboxes =================================================================== RCS file: /extra/cvsroot/zsh/zsh-3.1/Completion/User/_mailboxes,v retrieving revision 1.1 diff -u -r1.1 _mailboxes --- _mailboxes 1999/09/18 17:26:25 1.1 +++ _mailboxes 1999/09/18 23:22:02 @@ -1,30 +1,41 @@ #autoload -# This is needlessly mutt-biased and should be fixed. +emulate -L zsh +setopt nullglob -local expl muttboxes mboxes dirboxes MHboxes maildirboxes muttrc="~/.muttrc" maildirectory="~/Mail" +# This is still needlessly mutt-biased and should be fixed. -test -f "$compconfig[muttrc_path]" && muttrc=$compconfig[muttrc_path] -test -f "$compconfig[maildirectory]" && maildirectory=$compconfig[maildirectory] +local -U muttboxes mboxes dirboxes MHboxes maildirboxes +local i j expl muttrc="${muttrc:-~/.muttrc}" +local pinedirectory="${pinedirectory:-~/mail}" +local maildirectory="${maildirectory:-~/Mail}" if (( ! $+_mailbox_cache )) then -test ${muttrc} || test -f ${~muttrc} && muttboxes=( ${(@)$(grep mailboxes ${~muttrc})[2,-1]} ) +[[ -f "${~muttrc}" ]] && muttboxes=( ${$(grep mailboxes ${~muttrc})[2,-1]} ) -mboxes=(${~maildirectory}/*(^/)) -dirboxes=(${~maildirectory}/*(/)) +mboxes=( ${~maildirectory}/*(^/) ${~pinedirectory}/**/*(.) ) +dirboxes=( ${~maildirectory}/*(/) ) -for i in $dirboxes +while (( $#dirboxes )) do -if test -d "${i}/cur" -then -maildirboxes=($maildirboxes $i) -else -MHboxes=($MHboxes $i) -fi + i=$dirboxes[1] + shift dirboxes + if [[ -d "$i/cur" ]] + then + maildirboxes=( $maildirboxes $i ) + elif j=( $i/<1-> ) && [[ -n "$j" ]] + then + MHboxes=( $MHboxes $i ) + else + mboxes=( $mboxes $i/*(.) ) + dirboxes=( $dirboxes $i/*(/) ) + fi done -_mailbox_cache=(\! \< \> $muttboxes $mboxes $maildirboxes $MHboxes) +[[ -n "$muttboxes" ]] && + _mailbox_cache=(\! \< \> $muttboxes) +_mailbox_cache=($_mailbox_cache $mboxes $maildirboxes $MHboxes) fi -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com