zsh-workers
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: Clint Adams <schizo@debian.org>, zsh-workers@sunsite.auc.dk
Subject: Re: PATCH: _mutt, _mailboxes
Date: Sat, 18 Sep 1999 23:27:29 +0000	[thread overview]
Message-ID: <990918232730.ZM6698@candle.brasslantern.com> (raw)
In-Reply-To: <19990915173039.A15772@dman.com>

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


  reply	other threads:[~1999-09-18 23:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-09-15 21:30 Clint Adams
1999-09-18 23:27 ` Bart Schaefer [this message]
1999-09-20  4:48   ` Clint Adams
1999-09-16 13:11 Sven Wischnowsky
1999-09-16 15:38 ` Adam Spiers
1999-09-17  9:04 Sven Wischnowsky
1999-09-17 11:22 Sven Wischnowsky

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=990918232730.ZM6698@candle.brasslantern.com \
    --to=schaefer@candle.brasslantern.com \
    --cc=schizo@debian.org \
    --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).