Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: mail-directory (was Re: compctl whitespace changes)



>     _lmutt () { local maildirectory=~/Mail/Lists; _mutt "$@" }
> 
> (That maildirectory variable really ought to get changed to a style ...)

Here goes.

Index: Completion/Unix/Type/_mailboxes
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_mailboxes,v
retrieving revision 1.1
diff -u -r1.1 _mailboxes
--- Completion/Unix/Type/_mailboxes	2001/04/02 11:38:17	1.1
+++ Completion/Unix/Type/_mailboxes	2001/10/10 20:08:29
@@ -3,14 +3,15 @@
 _mailboxes() {
   #emulate -L zsh
   local expl ret=1
-  local pinedirectory="${pinedirectory:-~/mail}"
-  local maildirectory="${maildirectory:-~/Mail}"
+  local maildirectory pinedirectory
+  zstyle -s ":completion:${curcontext}:" mail-directory maildirectory || maildirectory="~/Mail"
+  zstyle -s ":completion:${curcontext}:" pine-directory pinedirectory || pinedirectory="~/mail"
 
   if (( ! $+_mailbox_cache )) then
     _mailbox_cache "$@"
   fi
 
-  case "${curcontext}" in
+  case "${curcontext}:" in
     (*:mail:*)
       if [[ "$PREFIX" == +* ]]; then
 	_tags mailboxes
@@ -49,7 +50,7 @@
     _requested mailboxes expl 'mailbox specification' _mua_mailboxes && ret=0
 
     if _requested files expl 'mailbox file'; then
-      [[ "${curcontext}" != *:(mail|mush|mutt|zmail|zmlite):* ]] &&
+      [[ "${curcontext}:" != *:(mail|mush|mutt|zmail|zmlite):* ]] &&
 	compset -P -f
       _files "$expl[@]" && ret=0
     fi
@@ -60,13 +61,15 @@
 }
 
 _mailbox_cache () {
-  # Depends on $maildirectory and $pinedirectory from _mailboxes!
-
-  local i j _mc_tmp muttrc="${muttrc:-~/.muttrc}"
+  local i j _mc_tmp
   local -aU dirboxes
+  local maildirectory pinedirectory muttrc
   typeset -aU -g _mailbox_cache
   typeset -aU -g _maildir_cache _mbox_cache _mh_cache _mutt_cache _pine_cache
 
+  zstyle -s ":completion:${curcontext}:" mail-directory maildirectory || maildirectory="~/Mail"
+  zstyle -s ":completion:${curcontext}:" pine-directory pinedirectory || pinedirectory="~/mail"
+  zstyle -s ":completion:${curcontext}:" muttrc muttrc || muttrc="~/.muttrc"
 
   [[ -f ${~muttrc:-.} ]] &&
     _mc_tmp=${=${(M)${(f)"$(<${~muttrc})"}:#mailboxes *}#mailboxes *} &&
@@ -98,13 +101,15 @@
 }
 
 _mua_mailboxes() {
-  # Depends on $maildirectory and $pinedirectory from _mailboxes!
-
   local -a mbox_short
   local -aU mbox_names
   local ret=1
+
+  local maildirectory pinedirectory
+  zstyle -s ":completion:${curcontext}:" mail-directory maildirectory || maildirectory="~/Mail"
+  zstyle -s ":completion:${curcontext}:" pine-directory pinedirectory || pinedirectory="~/mail"
 
-  case "${curcontext}" in
+  case "${curcontext}:" in
     (*:elm:*) # I've probably got this wrong, or at least incomplete
       mbox_names=( "${_mbox_cache[@]}" "${_mailbox_cache[@]}" )
       mbox_short=( \! \< \> )
Index: Doc/Zsh/compsys.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compsys.yo,v
retrieving revision 1.136
diff -u -r1.136 compsys.yo
--- Doc/Zsh/compsys.yo	2001/10/09 12:56:03	1.136
+++ Doc/Zsh/compsys.yo	2001/10/10 20:08:30
@@ -1590,6 +1590,11 @@
 style, and if successful will look in the directory under tt(~yousir) given
 by the third argument to the style for possible completions.
 )
+kindex(mail-directory, completion style)
+item(tt(mail-directory))(
+If set, zsh will assume that mailbox files can be found in
+the directory specified.  It defaults to `tt(~/Mail)'.
+)
 kindex(match-original, completion style)
 item(tt(match-original))(
 This is used by the tt(_match) completer.  If it is set to
@@ -1740,6 +1745,11 @@
 screen, both of `tt(yes=)' and `tt(select=)' can be given twice, once
 with a number and once with `tt(long)' or `tt(long-list)'.
 )
+kindex(muttrc, completion style)
+item(tt(muttrc))(
+If set, zsh will assume that the local mutt configuration can be found
+in the file specified.  It defaults to `tt(~/.muttrc)'.
+)
 kindex(numbers, completion style)
 item(tt(numbers))(
 This is used with the tt(jobs) tag.  If it is `true', the shell will
@@ -1834,6 +1844,11 @@
 containing color names in the format of an X11 tt(rgb.txt) file.  If
 the style is not set but this file is found in one of various standard
 locations it will be used as the default.
+)
+kindex(pine-directory, completion style)
+item(tt(pine-directory))(
+If set, zsh will assume that PINE mailbox files can be found in
+the directory specified.  It defaults to `tt(~/mail)'.
 )
 kindex(ports, completion style)
 item(tt(ports))(



Messages sorted by: Reverse Date, Date, Thread, Author