zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: MH for Mailboxes (TM)
@ 2001-03-23 17:22 Peter Stephenson
  2001-03-24 18:06 ` Bart Schaefer
  0 siblings, 1 reply; 9+ messages in thread
From: Peter Stephenson @ 2001-03-23 17:22 UTC (permalink / raw)
  To: Zsh hackers list

This makes _mailboxes a bit happier about MH mailboxes.  I don't know
whether to alter _mh_cache directly or change it at the point of use.  The
other change is to allow subfolders, which are already handled by
_multi_parts where _mh_cache is used.

It still doesn't handle the feature of MH (which I don't suppose anyone
actually uses) that @folder is relative to the last folder you were looking
at.  This is why I tacked the + directly on the front, rather than assuming
it's already present in the context --- it may in principle be an @.  But
in some ways it's more natural to forget about the + and assume it's
somewhere in the ignored prefix if it's needed.  MH itself is completely
consistent about requiring + or @, so far as I know, so either way would
probably work.

It's not wired up to _mh.  It's probably more than my job's worth to commit
this.

Index: Completion/User/_mailboxes
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/User/_mailboxes,v
retrieving revision 1.8
diff -u -r1.8 _mailboxes
--- Completion/User/_mailboxes	2000/11/09 13:27:53	1.8
+++ Completion/User/_mailboxes	2001/03/23 17:15:14
@@ -83,7 +83,8 @@
     if [[ -d "$i/cur" ]]; then
       _maildir_cache=( "${_maildir_cache[@]}" "$i" )
     elif j=( "$i"/<1-> ) && [[ -n "$j" ]]; then
-      _mh_cache=( "${_mh_cache[@]}" "$i" )
+      _mh_cache=( "${_mh_cache[@]}" "+${i#$~maildirectory/}" )
+      dirboxes=( $dirboxes "$i"/*(/) )
     else
       _mbox_cache=( "${_mbox_cache[@]}" "$i"/*(.) )
       dirboxes=( $dirboxes "$i"/*(/) )

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK                          Tel: +44 (0)1223 392070


^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: PATCH: MH for Mailboxes (TM)
@ 2001-03-26  8:34 Sven Wischnowsky
  2001-03-28  6:30 ` Bart Schaefer
  0 siblings, 1 reply; 9+ messages in thread
From: Sven Wischnowsky @ 2001-03-26  8:34 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> ...
> 
> By the way (Sven), when I complete after "mutt -f " (with no prefix in
> the current word) I -still- get a blank item as the first menu-selection.
> I thought we fixed that bug a long time ago?

Yes, sounds very familiar.  I don't remember exactly and since I don't 
use anything I could complete with _mailboxes I can't easily try, but
normally that's because one of the expansions leaves an empty element
in an array.  So we could either check all parameter expansions used
to fill the cache (I guess it's the cache) or remove the empty
elements at the end.

Could anyone test if that's the problem?

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: PATCH: MH for Mailboxes (TM)
@ 2001-03-28 10:55 Sven Wischnowsky
  2001-03-28 15:53 ` Bart Schaefer
  0 siblings, 1 reply; 9+ messages in thread
From: Sven Wischnowsky @ 2001-03-28 10:55 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> On Mar 26, 10:34am, Sven Wischnowsky wrote:
> } 
> } Bart Schaefer wrote:
> } 
> } > By the way (Sven), when I complete after "mutt -f " (with no prefix in
> } > the current word) I -still- get a blank item as the first menu-selection.
> } > I thought we fixed that bug a long time ago?
> } 
> } Yes, sounds very familiar.  I don't remember exactly and since I don't 
> } use anything I could complete with _mailboxes I can't easily try, but
> } normally that's because one of the expansions leaves an empty element
> } in an array.
> 
> I've looked through _complete_debug output and not managed to find any
> cases where `compadd' is called with an array containing an empty element.
> 
> However, at _multi_parts line 164-166, the expression
> 
> 	"${(@)${(@M)matches:#*${sep}}%%${sep}*}"
> 
> expands to the empty string.  Could that be the source of the problem?

Yes, that may be.  Even if it doesn't fix this particular problem, the 
patch below should only make things saver.

Can someone try?


Bye
 Sven

Index: Completion/Core/_multi_parts
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_multi_parts,v
retrieving revision 1.5
diff -u -r1.5 _multi_parts
--- Completion/Core/_multi_parts	2001/02/09 14:01:58	1.5
+++ Completion/Core/_multi_parts	2001/03/28 10:53:10
@@ -163,14 +163,14 @@
 
         compadd "$group[@]" "$expl[@]" -r "$sep" -S "$sep" "$opts[@]" \
 	        -p "$pref" "$tmp2[@]" -M "r:|${sep}=* r:|=* $matcher" - \
-                "${(@)${(@M)matches:#*${sep}}%%${sep}*}" && ret=0
+                "${(@)${(@)${(@M)matches:#*${sep}}%%${sep}*}:#}" && ret=0
         (( $matches[(I)${sep}*] )) &&
             compadd "$group[@]" "$expl[@]" -S '' "$opts[@]" \
 	            -p "$pref" \
                     -M "r:|${sep}=* r:|=* $matcher" - "$sep" && ret=0
         compadd "$group[@]" "$expl[@]" -r "$sep" -S "$sep" "$opts[@]" \
                 -p "$pref" "$tmp2[@]" -M "r:|${sep}=* r:|=* $matcher" - \
-                "${(@)${(@M)matches:#*?${sep}?*}%%${sep}*}" && ret=0
+                "${(@)${(@)${(@M)matches:#*?${sep}?*}%%${sep}*}:#}" && ret=0
         compadd "$group[@]" "$expl[@]" -S '' "$opts[@]" -p "$pref" "$tmp2[@]" \
                 -M "r:|${sep}=* r:|=* $matcher" - \
                 "${(@)matches:#*${sep}*}" && ret=0
@@ -182,7 +182,7 @@
         compadd "$group[@]" "$expl[@]" "$opts[@]" \
 	        -p "$pref" -s "${i#*${sep}}" \
                 -M "r:|${sep}=* r:|=* $matcher" - \
-                "${(@)${(@M)matches:#*${sep}*}%%${sep}*}" && ret=0
+                "${(@)${(@)${(@M)matches:#*${sep}*}%%${sep}*}:#}" && ret=0
         compadd "$group[@]" "$expl[@]" -S '' "$opts[@]" -p "$pref" \
                 -M "r:|${sep}=* r:|=* $matcher" - \
                 "${(@)matches:#*${sep}*}" && ret=0

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: PATCH: MH for Mailboxes (TM)
@ 2001-03-29  8:36 Sven Wischnowsky
  2001-03-29  8:52 ` Bart Schaefer
  0 siblings, 1 reply; 9+ messages in thread
From: Sven Wischnowsky @ 2001-03-29  8:36 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> On Mar 28, 12:55pm, Sven Wischnowsky wrote:
> } Subject: Re: PATCH: MH for Mailboxes (TM)
> }
> } > However, at _multi_parts line 164-166, the expression
> } > 
> } > 	"${(@)${(@M)matches:#*${sep}}%%${sep}*}"
> } > 
> } > expands to the empty string.  Could that be the source of the problem?
> } 
> } Yes, that may be.  Even if it doesn't fix this particular problem, the 
> } patch below should only make things saver.
> } 
> } Can someone try?
> 
> I still get the blank item in the list after your patch.  I think maybe
> the problem is that tmp1 gets an empty element at line 94, which then
> gets added as a match at line 120, but I tried duplicating your change
> at line 94 without any better result.

Hm.  After setting up some parameters I was able to reproduce it.  But 
for me changing lines 94 and 97 fixed it.  So I'll commit the patch
below anyway.

> Does `compadd -a array' where the array is empty have a bad effect?

No, that works nicely (having tried it with a simple test completion
function).


That _mailboxes function... there are some wrongly indented parts in
it.  And the `pinedirectory', `maildirectory' and `mailpath'
parameters don't seem to be documented.  Are these standard names?
(In particular, mailpath even isn't a local.)

Bye
 Sven

Index: Completion/Core/_multi_parts
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_multi_parts,v
retrieving revision 1.6
diff -u -r1.6 _multi_parts
--- Completion/Core/_multi_parts	2001/03/28 10:58:02	1.6
+++ Completion/Core/_multi_parts	2001/03/29 08:31:28
@@ -91,10 +91,10 @@
   else
     # No exact match, see how many strings match what's on the line.
 
-    builtin compadd -O tmp1 - "${(@)matches%%${sep}*}"
+    builtin compadd -O tmp1 - "${(@)${(@)matches%%${sep}*}:#}"
 
     [[ $#tmp1 -eq 0 && -n "$_comp_correct" ]] &&
-      compadd -O tmp1 - "${(@)matches%%${sep}*}"
+      compadd -O tmp1 - "${(@)${(@)matches%%${sep}*}:#}"
 
     if [[ $#tmp1 -eq 1 ]]; then
 

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2001-03-29  8:53 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-03-23 17:22 PATCH: MH for Mailboxes (TM) Peter Stephenson
2001-03-24 18:06 ` Bart Schaefer
2001-03-24 23:55   ` Peter Stephenson
2001-03-26  8:34 Sven Wischnowsky
2001-03-28  6:30 ` Bart Schaefer
2001-03-28 10:55 Sven Wischnowsky
2001-03-28 15:53 ` Bart Schaefer
2001-03-29  8:36 Sven Wischnowsky
2001-03-29  8:52 ` Bart Schaefer

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).