zsh-workers
 help / color / mirror / code / Atom feed
* 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-28 10:55 PATCH: MH for Mailboxes (TM) Sven Wischnowsky
@ 2001-03-28 15:53 ` Bart Schaefer
  0 siblings, 0 replies; 9+ messages in thread
From: Bart Schaefer @ 2001-03-28 15:53 UTC (permalink / raw)
  To: zsh-workers

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.

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

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


^ 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, 0 replies; 9+ messages in thread
From: Bart Schaefer @ 2001-03-29  8:52 UTC (permalink / raw)
  To: zsh-workers

On Mar 29, 10:36am, Sven Wischnowsky wrote:
}
} Hm.  After setting up some parameters I was able to reproduce it.  But 
} for me changing lines 94 and 97 fixed it.

Ah, I didn't change line 97.  Maybe that was it.

} That _mailboxes function... there are some wrongly indented parts in
} it.

Yes, somebody (maybe me) generated a patch with "diff -bwu".

} And the `pinedirectory', `maildirectory' and `mailpath'
} parameters don't seem to be documented.  Are these standard names?

$mailpath is zsh special variable, the array form for $MAILPATH.

The other two (pinedirectory and maildirectory) should be converted to
zstyles, as I think I mentioned elsewhere on this thread.  They were
modeled after some early (pre-zstyle) completion function and have never
caught up.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


^ 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

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

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?

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


^ 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-24 18:06 ` Bart Schaefer
@ 2001-03-24 23:55   ` Peter Stephenson
  0 siblings, 0 replies; 9+ messages in thread
From: Peter Stephenson @ 2001-03-24 23:55 UTC (permalink / raw)
  To: Zsh hackers list

"Bart Schaefer" wrote:
> Where does one obtain the name of the last folder?  Fill it in to the
> `lastmhbox' parameter below, and uncomment the corresponding lines.

Er, OK.  Tear along dotted line and enclose self-addressed envelope?

Index: Completion/User/_mailboxes
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/User/_mailboxes,v
retrieving revision 1.9
diff -u -r1.9 _mailboxes
--- Completion/User/_mailboxes	2001/03/24 18:22:55	1.9
+++ Completion/User/_mailboxes	2001/03/24 23:53:06
@@ -118,14 +118,14 @@
       fi
       ;;
     (*:mh:*)
-#     local lastmhbox=???	# Where does this come from?
+      local lastmhbox=$(mhpath)
       if compset -P +; then
 	mbox_names=( "${(@)_mh_cache#$~maildirectory/}" )
-#     elif compset -P @; then
-#	mbox_names=( "${(@)${(@M)_mh_cache:#$~lastmhbox/*}#$~lastmhbox/}" )
+      elif compset -P @; then
+	mbox_names=( "${(@)${(@M)_mh_cache:#$~lastmhbox/*}#$~lastmhbox/}" )
       else
 	mbox_names=( +"${(@)^_mh_cache#$~maildirectory/}"
-#		     @"${(@)^${(@M)_mh_cache:#$~lastmhbox/*}#$~lastmhbox/}"
+		     @"${(@)^${(@M)_mh_cache:#$~lastmhbox/*}#$~lastmhbox/}"
 		     "${_mh_cache[@]}" )
       fi
       ;;

-- 
Peter Stephenson <pws@pwstephenson.fsnet.co.uk>
Work: pws@csr.com
Web: http://www.pwstephenson.fsnet.co.uk


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

* Re: PATCH: MH for Mailboxes (TM)
  2001-03-23 17:22 Peter Stephenson
@ 2001-03-24 18:06 ` Bart Schaefer
  2001-03-24 23:55   ` Peter Stephenson
  0 siblings, 1 reply; 9+ messages in thread
From: Bart Schaefer @ 2001-03-24 18:06 UTC (permalink / raw)
  To: zsh-workers

On Fri, 23 Mar 2001, Peter Stephenson wrote:
}
} 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.

It needs to be changed at point of use, because other programs may use
_mailboxes that understand MH directory format without understanding the
MH `+folder' naming convention.  So _mh_cache needs to contain full path
names.

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

Where does one obtain the name of the last folder?  Fill it in to the
`lastmhbox' parameter below, and uncomment the corresponding lines.

The following patch is INSTEAD OF Peter's, because Peter hasn't committed
his yet.

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?

Index: Completion/User/_mailboxes
===================================================================
--- Completion/User/_mailboxes	2000/11/11 21:49:59	1.20
+++ Completion/User/_mailboxes	2001/03/24 18:00:29
@@ -84,6 +84,7 @@
       _maildir_cache=( "${_maildir_cache[@]}" "$i" )
     elif j=( "$i"/<1-> ) && [[ -n "$j" ]]; then
       _mh_cache=( "${_mh_cache[@]}" "$i" )
+      dirboxes=( $dirboxes "$i"/*(/) )
     else
       _mbox_cache=( "${_mbox_cache[@]}" "$i"/*(.) )
       dirboxes=( $dirboxes "$i"/*(/) )
@@ -116,8 +117,17 @@
 		    "${_mailbox_cache[@]}" )
       fi
       ;;
-    (*:mh:*) # I've probably got this wrong, or at least incomplete
-      (( $#_mh_cache )) && _multi_parts "${expl[@]}" / _mh_cache && ret=0
+    (*:mh:*)
+#     local lastmhbox=???	# Where does this come from?
+      if compset -P +; then
+	mbox_names=( "${(@)_mh_cache#$~maildirectory/}" )
+#     elif compset -P @; then
+#	mbox_names=( "${(@)${(@M)_mh_cache:#$~lastmhbox/*}#$~lastmhbox/}" )
+      else
+	mbox_names=( +"${(@)^_mh_cache#$~maildirectory/}"
+#		     @"${(@)^${(@M)_mh_cache:#$~lastmhbox/*}#$~lastmhbox/}"
+		     "${_mh_cache[@]}" )
+      fi
       ;;
     (*:mush:*)
       if compset -P %; then

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


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

* 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

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-28 10:55 PATCH: MH for Mailboxes (TM) Sven Wischnowsky
2001-03-28 15:53 ` Bart Schaefer
  -- strict thread matches above, loose matches on Subject: below --
2001-03-29  8:36 Sven Wischnowsky
2001-03-29  8:52 ` Bart Schaefer
2001-03-26  8:34 Sven Wischnowsky
2001-03-28  6:30 ` Bart Schaefer
2001-03-23 17:22 Peter Stephenson
2001-03-24 18:06 ` Bart Schaefer
2001-03-24 23:55   ` Peter Stephenson

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