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

Re: Bug in _mailbox_cache function from _mailboxes on Mac OS X



Vincent Lefevre wrote:
> I sent this on 2006-01-26 and didn't get any reply. It seems that
> the bug still isn't fixed. This is quite important since it makes
> Mutt completion completely useless. My current fix is to remove
> anything related to pine from the _mailbox_cache file.
> 
> Under Mac OS X, the _mailbox_cache freezes at the line
> 
>   _pine_cache=(${~pinedirectory}/**/*(.))
> 
> which does ~/mail/**/*(.), but as the filesystem is case-insensitive,
> this searches for files in ~/Mail, and this is really slow (I have
> huge maildir mailboxes there).
> 
> Moreover I don't use pine. So, I don't see why I would waste time to
> set _pine_cache during a Mutt completion.

It seems like whoever was responsible for this code has bunked off.
This fixes the problem by requiring the pine-directory style to be set
for using PINE completion.

I think you could work around it another way by setting the style
pine-directory to a non-existent directory, but it doesn't seem
right to impose something so obscure on people not using PINE.

Index: README
===================================================================
RCS file: /cvsroot/zsh/zsh/README,v
retrieving revision 1.28
diff -u -r1.28 README
--- README	16 Feb 2006 19:05:13 -0000	1.28
+++ README	28 Feb 2006 11:38:20 -0000
@@ -53,6 +53,12 @@
 tests can be used.  This change may be reviewed if no such permanent fix
 is forthcoming.
 
+The completion style pine-directory must now be set to use completion
+for PINE mailbox folders; previously it had the default ~/mail.  This
+change was necessary because otherwise recursive directories under
+~/mail are searched by default, which can be a considerable unnecessary
+hit for anyone not using PINE.
+
 Documentation
 -------------
 
Index: Completion/Unix/Type/_mailboxes
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_mailboxes,v
retrieving revision 1.2
diff -u -r1.2 _mailboxes
--- Completion/Unix/Type/_mailboxes	10 Oct 2001 20:10:44 -0000	1.2
+++ Completion/Unix/Type/_mailboxes	28 Feb 2006 11:38:20 -0000
@@ -5,7 +5,7 @@
   local expl ret=1
   local maildirectory pinedirectory
   zstyle -s ":completion:${curcontext}:" mail-directory maildirectory || maildirectory="~/Mail"
-  zstyle -s ":completion:${curcontext}:" pine-directory pinedirectory || pinedirectory="~/mail"
+  zstyle -s ":completion:${curcontext}:" pine-directory pinedirectory
 
   if (( ! $+_mailbox_cache )) then
     _mailbox_cache "$@"
@@ -68,7 +68,7 @@
   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}:" pine-directory pinedirectory
   zstyle -s ":completion:${curcontext}:" muttrc muttrc || muttrc="~/.muttrc"
 
   [[ -f ${~muttrc:-.} ]] &&
@@ -76,7 +76,11 @@
     _mutt_cache=( ${=${(Xe)_mc_tmp}} )
 
   _mbox_cache=( ${~maildirectory}/*(^/) )
-  _pine_cache=( ${~pinedirectory}/**/*(.) )
+  if [[ -n $pinedirectory ]]; then
+    _pine_cache=( ${~pinedirectory}/**/*(.) )
+  else
+    _pine_cache=()
+  fi
 
   dirboxes=( ${~maildirectory}/*(/) )
 
@@ -107,7 +111,7 @@
 
   local maildirectory pinedirectory
   zstyle -s ":completion:${curcontext}:" mail-directory maildirectory || maildirectory="~/Mail"
-  zstyle -s ":completion:${curcontext}:" pine-directory pinedirectory || pinedirectory="~/mail"
+  zstyle -s ":completion:${curcontext}:" pine-directory pinedirectory
 
   case "${curcontext}:" in
     (*:elm:*) # I've probably got this wrong, or at least incomplete
@@ -157,10 +161,13 @@
       fi
       ;;
     (*:pine:*)
+      mbox_names=( "${_mbox_cache[@]}"
+		   "${_mailbox_cache[@]}" "${_mh_cache[@]}" )
       # 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[@]}"
-		   "${_mailbox_cache[@]}" "${_mh_cache[@]}" )
+      if [[ -n $pinedirectory ]]; then
+	mbox_names+=( "${(@)_pine_cache#$~pinedirectory/}" )
+      fi
       ;;
     (*:tkrat:*) # Has a couple of custom formats I haven't programmed for.
       mbox_names=( "${_mbox_cache[@]}"
Index: Doc/Zsh/compsys.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compsys.yo,v
retrieving revision 1.182
diff -u -r1.182 compsys.yo
--- Doc/Zsh/compsys.yo	8 Jun 2005 12:22:56 -0000	1.182
+++ Doc/Zsh/compsys.yo	28 Feb 2006 11:38:22 -0000
@@ -2039,8 +2039,9 @@
 )
 kindex(pine-directory, completion style)
 item(tt(pine-directory))(
-If set, specifies the directory containing PINE mailbox files.  It
-defaults to `tt(~/mail)'.
+If set, specifies the directory containing PINE mailbox files.  There
+is no default, since recursively searching this directory is inconvenient
+for anyone who doesn't use PINE.
 )
 kindex(ports, completion style)
 item(tt(ports))(

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php



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