From MAILER-DAEMON Mon Apr 01 05:18:11 2013
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1UMasV-0006My-7d
	for mharc-commit-mailutils@gnu.org; Mon, 01 Apr 2013 05:18:11 -0400
Received: from eggs.gnu.org ([208.118.235.92]:46295)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1UMasN-0006Lb-9m
	for commit-mailutils@gnu.org; Mon, 01 Apr 2013 05:18:09 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1UMasI-0003xF-8Z
	for commit-mailutils@gnu.org; Mon, 01 Apr 2013 05:18:03 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:33325)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1UMasI-0003x2-4O
	for commit-mailutils@gnu.org; Mon, 01 Apr 2013 05:17:58 -0400
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1UMasH-0004EO-As
	for commit-mailutils@gnu.org; Mon, 01 Apr 2013 09:17:57 +0000
Date: Mon, 01 Apr 2013 09:17:57 +0000
Message-Id: <E1UMasH-0004EO-As@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-647-g796d9ae
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 9be3f81ff2ada509eac8338db68a10a73cf19c51
X-Git-Newrev: 796d9aef17c932732aa9fa79602f8955ac8f7454
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Mon, 01 Apr 2013 09:18:10 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Mailutils".

http://git.savannah.gnu.org/cgit/mailutils.git/commit/?id=796d9aef17c932732aa9fa79602f8955ac8f7454

The branch, master has been updated
       via  796d9aef17c932732aa9fa79602f8955ac8f7454 (commit)
      from  9be3f81ff2ada509eac8338db68a10a73cf19c51 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 796d9aef17c932732aa9fa79602f8955ac8f7454
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Mon Apr 1 12:15:58 2013 +0300

    Bugfix.
    
    * libmailutils/base/amd.c (_amd_update_message): Return
    immediately if the message is not modified. Always use
    initialized value of flg.

-----------------------------------------------------------------------

Summary of changes:
 libmailutils/base/amd.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/libmailutils/base/amd.c b/libmailutils/base/amd.c
index 8e563d2..b259270 100644
--- a/libmailutils/base/amd.c
+++ b/libmailutils/base/amd.c
@@ -1288,7 +1288,9 @@ _amd_update_message (struct _amd_data *amd, struct _amd_message *mhm,
     flg = mu_message_is_modified (mhm->message);
   else if (mhm->attr_flags & MU_ATTRIBUTE_MODIFIED)
     flg = MU_MSG_ATTRIBUTE_MODIFIED;
-
+  else
+    return 0;
+  
   if (!flg)
     return 0;
 


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Mon Apr 01 14:08:19 2013
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1UMj9X-0001fM-I9
	for mharc-commit-mailutils@gnu.org; Mon, 01 Apr 2013 14:08:19 -0400
Received: from eggs.gnu.org ([208.118.235.92]:37687)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1UMj9U-0001e0-0l
	for commit-mailutils@gnu.org; Mon, 01 Apr 2013 14:08:18 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1UMj9R-0007JC-KX
	for commit-mailutils@gnu.org; Mon, 01 Apr 2013 14:08:15 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:38902)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1UMj9R-0007J1-H5
	for commit-mailutils@gnu.org; Mon, 01 Apr 2013 14:08:13 -0400
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1UMj9Q-0006Ns-4U
	for commit-mailutils@gnu.org; Mon, 01 Apr 2013 18:08:12 +0000
Date: Mon, 01 Apr 2013 18:08:12 +0000
Message-Id: <E1UMj9Q-0006Ns-4U@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-648-gd9ddd27
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 796d9aef17c932732aa9fa79602f8955ac8f7454
X-Git-Newrev: d9ddd27acef16ebbb44a0fc096fe86fedab5399d
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Mon, 01 Apr 2013 18:08:18 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Mailutils".

http://git.savannah.gnu.org/cgit/mailutils.git/commit/?id=d9ddd27acef16ebbb44a0fc096fe86fedab5399d

The branch, master has been updated
       via  d9ddd27acef16ebbb44a0fc096fe86fedab5399d (commit)
      from  796d9aef17c932732aa9fa79602f8955ac8f7454 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit d9ddd27acef16ebbb44a0fc096fe86fedab5399d
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Mon Apr 1 21:00:25 2013 +0300

    MH: Synchronize sequences after removal of messages.
    
    * include/mailutils/msgset.h (mu_msgset_sget_mailbox): New proto.
    * include/mailutils/sys/msgset.h (_MU_MSGSET_MODE): New macro.
    * libmailutils/msgset/Makefile.am: Add getmbox.c
    * libmailutils/msgset/getmbox.c: New file.
    * libmailutils/msgset/addset.c: Use _MU_MSGSET_MODE.
    * libmailutils/msgset/create.c: Likewise.
    * libmailutils/msgset/foreachmsg.c: Likewise.
    * libmailutils/msgset/foreachnum.c: Likewise.
    * libmailutils/msgset/negate.c: Likewise.
    * libmailutils/msgset/subset.c: Likewise.
    * libmailutils/msgset/trans.c: Likewise.
    
    * mh/mh.h (mh_private_sequences_iterate): New proto.
    * mh/mh_sequence.c (format_closure) <delim>: New member.
    (format_sequence): Use delim to avoid outputting leading space.
    (save_sequence): Initialize delim.
    (mh_private_sequences_iterate): New function.
    * mh/rmm.c (main): Remove message numbers from sequences.
    * mh/tests/rmm.at: Update.

-----------------------------------------------------------------------

Summary of changes:
 include/mailutils/msgset.h                 |    2 +
 include/mailutils/sys/msgset.h             |    1 +
 libmailutils/msgset/Makefile.am            |    1 +
 libmailutils/msgset/addset.c               |    2 +-
 libmailutils/msgset/create.c               |    2 +-
 libmailutils/msgset/foreachmsg.c           |    2 +-
 libmailutils/msgset/foreachnum.c           |    4 +-
 libmailutils/msgset/{clear.c => getmbox.c} |   10 ++--
 libmailutils/msgset/negate.c               |    9 ++--
 libmailutils/msgset/subset.c               |    2 +-
 libmailutils/msgset/trans.c                |    4 +-
 mh/mh.h                                    |    3 +
 mh/mh_sequence.c                           |   74 ++++++++++++++++++++++++++-
 mh/rmm.c                                   |   26 +++++++++-
 mh/tests/rmm.at                            |    1 -
 15 files changed, 121 insertions(+), 22 deletions(-)
 copy libmailutils/msgset/{clear.c => getmbox.c} (82%)

diff --git a/include/mailutils/msgset.h b/include/mailutils/msgset.h
index 9c4add1..7b0e983 100644
--- a/include/mailutils/msgset.h
+++ b/include/mailutils/msgset.h
@@ -43,6 +43,8 @@ int mu_msgset_create (mu_msgset_t *pmsgset, mu_mailbox_t mbox, int mode);
 int mu_msgset_get_list (mu_msgset_t msgset, mu_list_t *plist);
 int mu_msgset_get_iterator (mu_msgset_t msgset, mu_iterator_t *pitr);
 
+int mu_msgset_sget_mailbox (mu_msgset_t mset, mu_mailbox_t *mbox);
+  
 int mu_msgset_add_range (mu_msgset_t set, size_t beg, size_t end, int mode);
 int mu_msgset_sub_range (mu_msgset_t set, size_t beg, size_t end, int mode);
 int mu_msgset_add (mu_msgset_t a, mu_msgset_t b);
diff --git a/include/mailutils/sys/msgset.h b/include/mailutils/sys/msgset.h
index 0e3e73a..3cf338a 100644
--- a/include/mailutils/sys/msgset.h
+++ b/include/mailutils/sys/msgset.h
@@ -20,6 +20,7 @@
 
 #define _MU_MSGSET_AGGREGATED 0x10
 #define _MU_MSGSET_USERFLAG_MASK 0x0f
+#define _MU_MSGSET_MODE(c) ((c) & _MU_MSGSET_USERFLAG_MASK)
 
 struct _mu_msgset
 {
diff --git a/libmailutils/msgset/Makefile.am b/libmailutils/msgset/Makefile.am
index a8acc59..dbf14d2 100644
--- a/libmailutils/msgset/Makefile.am
+++ b/libmailutils/msgset/Makefile.am
@@ -26,6 +26,7 @@ libmsgset_la_SOURCES = \
  count.c\
  getitr.c\
  getlist.c\
+ getmbox.c\
  foreachnum.c\
  foreachmsgno.c\
  foreachuid.c\
diff --git a/libmailutils/msgset/addset.c b/libmailutils/msgset/addset.c
index 4a2995b..d175e45 100644
--- a/libmailutils/msgset/addset.c
+++ b/libmailutils/msgset/addset.c
@@ -44,7 +44,7 @@ mu_msgset_add (mu_msgset_t a, mu_msgset_t b)
     return EINVAL;
   if (!b)
     return 0;
-  closure.mode = b->flags;
+  closure.mode = _MU_MSGSET_MODE (b->flags);
   closure.dest = a;
   return mu_list_foreach (b->list, add_range, &closure);
 }
diff --git a/libmailutils/msgset/create.c b/libmailutils/msgset/create.c
index 4b90e47..b8a1631 100644
--- a/libmailutils/msgset/create.c
+++ b/libmailutils/msgset/create.c
@@ -54,7 +54,7 @@ mu_msgset_create (mu_msgset_t *pres, mu_mailbox_t mbox, int flags)
   mu_list_set_destroy_item (msgset->list, mu_list_free_item);
   mu_list_set_comparator (msgset->list, compare_msgnum);
   msgset->mbox = mbox;
-  msgset->flags = flags & _MU_MSGSET_USERFLAG_MASK;
+  msgset->flags = _MU_MSGSET_MODE (flags);
   *pres = msgset;
   return 0;
 }
diff --git a/libmailutils/msgset/foreachmsg.c b/libmailutils/msgset/foreachmsg.c
index e80b4b4..ba58b54 100644
--- a/libmailutils/msgset/foreachmsg.c
+++ b/libmailutils/msgset/foreachmsg.c
@@ -38,7 +38,7 @@ call_action (struct action_closure *clos, size_t i)
   mu_message_t msg = NULL;
   size_t n;
 
-  if (clos->msgset->flags == MU_MSGSET_UID)
+  if (_MU_MSGSET_MODE (clos->msgset->flags) == MU_MSGSET_UID)
     {
       rc = mu_mailbox_translate (clos->msgset->mbox, MU_MAILBOX_UID_TO_MSGNO,
 				 i, &n);
diff --git a/libmailutils/msgset/foreachnum.c b/libmailutils/msgset/foreachnum.c
index 1e95dcc..8154340 100644
--- a/libmailutils/msgset/foreachnum.c
+++ b/libmailutils/msgset/foreachnum.c
@@ -37,11 +37,11 @@ call_action (struct action_closure *clos, size_t i)
   size_t n;
   int cmd;
   
-  if (clos->msgset->flags != (clos->flags & MU_MSGSET_MODE_MASK))
+  if (_MU_MSGSET_MODE (clos->msgset->flags) != _MU_MSGSET_MODE (clos->flags))
     {
       int rc;
 
-      switch (clos->flags & MU_MSGSET_MODE_MASK)
+      switch (_MU_MSGSET_MODE (clos->flags))
 	{
 	case MU_MSGSET_NUM:
 	  cmd = MU_MAILBOX_UID_TO_MSGNO;
diff --git a/libmailutils/msgset/clear.c b/libmailutils/msgset/getmbox.c
similarity index 82%
copy from libmailutils/msgset/clear.c
copy to libmailutils/msgset/getmbox.c
index 5554e76..6595609 100644
--- a/libmailutils/msgset/clear.c
+++ b/libmailutils/msgset/getmbox.c
@@ -1,5 +1,5 @@
 /* GNU Mailutils -- a suite of utilities for electronic mail
-   Copyright (C) 2011-2012 Free Software Foundation, Inc.
+   Copyright (C) 2011-2013 Free Software Foundation, Inc.
 
    GNU Mailutils is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -17,16 +17,16 @@
 #include <config.h>
 #include <mailutils/types.h>
 #include <mailutils/errno.h>
-#include <mailutils/list.h>
 #include <mailutils/msgset.h>
 #include <mailutils/sys/msgset.h>
 
 int
-mu_msgset_clear (mu_msgset_t mset)
+mu_msgset_sget_mailbox (mu_msgset_t mset, mu_mailbox_t *mbox)
 {
   if (!mset)
     return EINVAL;
-  mu_list_clear (mset->list);
+  if (!mbox)
+    return MU_ERR_OUT_PTR_NULL;
+  *mbox = mset->mbox;
   return 0;
 }
-
diff --git a/libmailutils/msgset/negate.c b/libmailutils/msgset/negate.c
index d8a4c3e..ad5df7b 100644
--- a/libmailutils/msgset/negate.c
+++ b/libmailutils/msgset/negate.c
@@ -40,7 +40,7 @@ _invert_range (void *item, void *data)
     {
       rc = mu_msgset_add_range (clos->nset,
 				clos->next_num, range->msg_beg - 1,
-				clos->nset->flags);
+				_MU_MSGSET_MODE (clos->nset->flags));
       if (rc)
 	return rc;
     }
@@ -68,7 +68,7 @@ mu_msgset_negate (mu_msgset_t msgset, mu_msgset_t *pnset)
   rc = mu_mailbox_messages_count (msgset->mbox, &total);
   if (rc)
     return rc;
-  if (msgset->flags == MU_MSGSET_UID)
+  if (_MU_MSGSET_MODE (msgset->flags))
     {
       rc = mu_mailbox_translate (msgset->mbox,
 				 MU_MAILBOX_MSGNO_TO_UID,
@@ -76,7 +76,8 @@ mu_msgset_negate (mu_msgset_t msgset, mu_msgset_t *pnset)
       if (rc)
 	return rc;
     }
-  rc = mu_msgset_create (&clos.nset, msgset->mbox, msgset->flags);
+  rc = mu_msgset_create (&clos.nset, msgset->mbox,
+			 _MU_MSGSET_MODE (msgset->flags));
   if (rc)
     return rc;
   clos.next_num = 1;
@@ -85,7 +86,7 @@ mu_msgset_negate (mu_msgset_t msgset, mu_msgset_t *pnset)
     {
       if (clos.next_num < total)
 	rc = mu_msgset_add_range (clos.nset, clos.next_num, total,
-				  clos.nset->flags);
+				  _MU_MSGSET_MODE (clos.nset->flags));
     }
   
   if (rc)
diff --git a/libmailutils/msgset/subset.c b/libmailutils/msgset/subset.c
index 19e89f0..7625149 100644
--- a/libmailutils/msgset/subset.c
+++ b/libmailutils/msgset/subset.c
@@ -44,7 +44,7 @@ mu_msgset_sub (mu_msgset_t a, mu_msgset_t b)
     return EINVAL;
   if (!b)
     return 0;
-  closure.mode = b->flags;
+  closure.mode = _MU_MSGSET_MODE (b->flags);
   closure.dest = a;
   return mu_list_foreach (b->list, sub_range, &closure);
 }
diff --git a/libmailutils/msgset/trans.c b/libmailutils/msgset/trans.c
index 5bee788..9629074 100644
--- a/libmailutils/msgset/trans.c
+++ b/libmailutils/msgset/trans.c
@@ -27,14 +27,14 @@ int
 _mu_msgset_translate_pair (mu_msgset_t mset, int mode,
 			   size_t *pbeg, size_t *pend)
 {
-  if (mode != mset->flags && mset->mbox)
+  if (mode != _MU_MSGSET_MODE (mset->flags) && mset->mbox)
     {
       int cmd, rc;
       size_t n;
       size_t beg = *pbeg;
       size_t end = *pend;
       
-      switch (mset->flags)
+      switch (_MU_MSGSET_MODE (mset->flags))
 	{
 	case MU_MSGSET_NUM:
 	  cmd = MU_MAILBOX_UID_TO_MSGNO;
diff --git a/mh/mh.h b/mh/mh.h
index 697bfde..ac34fbc 100644
--- a/mh/mh.h
+++ b/mh/mh.h
@@ -266,6 +266,9 @@ void mh_global_sequences_drop (mu_mailbox_t mbox);
 
 void mh_global_save_state (void);
 
+int mh_private_sequences_iterate (mu_mailbox_t mbox, mu_mhprop_iterator_t fp,
+				  void *data);
+
 int mh_interactive_mode_p (void);
 int mh_getyn (const char *fmt, ...) MU_PRINTFLIKE(1,2);
 int mh_getyn_interactive (const char *fmt, ...) MU_PRINTFLIKE(1,2);
diff --git a/mh/mh_sequence.c b/mh/mh_sequence.c
index 361e218..171b1e8 100644
--- a/mh/mh_sequence.c
+++ b/mh/mh_sequence.c
@@ -67,6 +67,7 @@ struct format_closure
 {
   mu_stream_t stream;
   mu_mailbox_t mailbox;
+  int delim;
 };
 
 static int
@@ -87,8 +88,10 @@ format_sequence (void *item, void *data)
     }
   else
     beg = r->msg_beg;
+  if (clos->delim)
+    mu_stream_write (clos->stream, " ", 1, NULL);
   if (r->msg_beg == r->msg_end)
-    rc = mu_stream_printf (clos->stream, " %lu", (unsigned long) beg);
+    rc = mu_stream_printf (clos->stream, "%lu", (unsigned long) beg);
   else
     {
       if (clos->mailbox)
@@ -102,14 +105,15 @@ format_sequence (void *item, void *data)
       else
 	end = r->msg_end;
       if (beg + 1 == end)
-	rc = mu_stream_printf (clos->stream, " %lu %lu",
+	rc = mu_stream_printf (clos->stream, "%lu %lu",
 			       (unsigned long) beg,
 			       (unsigned long) end);
       else
-	rc = mu_stream_printf (clos->stream, " %lu-%lu",
+	rc = mu_stream_printf (clos->stream, "%lu-%lu",
 			       (unsigned long) beg,
 			       (unsigned long) end);
     }
+  clos->delim = 1;
   return rc;
 }
 
@@ -136,6 +140,7 @@ save_sequence (mu_mailbox_t mbox, const char *name, mu_msgset_t mset,
 	}
       
       clos.mailbox = mset->mbox;
+      clos.delim = 0;
       rc = mu_list_foreach (list, format_sequence, &clos);
       if (rc)
 	{
@@ -184,3 +189,66 @@ mh_seq_delete (mu_mailbox_t mbox, const char *name,
   return 0;
 }
 
+struct privseq_closure
+{
+  const char *mbox_dir;
+  mu_mhprop_iterator_t fun;
+  void *data;
+  char *namebuf;
+  size_t namelen;
+};
+  
+static int
+privseq_handler (const char *name, const char *value, void *data)
+{
+  struct privseq_closure *pclos = data;
+
+  if (strncmp (name, "atr-", 4) == 0)
+    {
+      char *p = strchr (name + 4, '-');
+      if (p && strcmp (p + 1, pclos->mbox_dir) == 0)
+	{
+	  size_t len = p - name - 4;
+	  if (pclos->namelen < len + 1)
+	    {
+	      pclos->namelen = len + 1;
+	      pclos->namebuf = mu_realloc (pclos->namebuf, pclos->namelen);
+	    }
+	  memcpy (pclos->namebuf, name + 4, len);
+	  pclos->namebuf[len] = 0;
+	}
+	return pclos->fun (pclos->namebuf, value, pclos->data);
+    }
+  return 0;
+}
+
+int
+mh_private_sequences_iterate (mu_mailbox_t mbox,
+			      mu_mhprop_iterator_t fp, void *data)
+{
+  int rc;
+  struct privseq_closure clos;
+  mu_url_t url;
+
+  rc = mu_mailbox_get_url (mbox, &url);
+  if (rc)
+    {
+      mu_diag_funcall (MU_DIAG_ERROR, "mu_mailbox_get_url", NULL, rc);
+      exit (1);
+    }
+  rc = mu_url_sget_path (url, &clos.mbox_dir);
+  if (rc)
+    {
+      mu_diag_funcall (MU_DIAG_ERROR, "mu_url_sget_path",
+		       mu_url_to_string (url), rc);
+      exit (1);
+    }
+  
+  clos.fun = fp;
+  clos.data = data;
+  clos.namebuf = NULL;
+  clos.namelen = 0;
+  rc = mu_mhprop_iterate (mu_mh_context, privseq_handler, &clos);
+  free (clos.namebuf);
+  return rc;
+}
diff --git a/mh/rmm.c b/mh/rmm.c
index d68496a..9a1034a 100644
--- a/mh/rmm.c
+++ b/mh/rmm.c
@@ -58,6 +58,23 @@ rmm (size_t num, mu_message_t msg, void *data)
   return 0;
 }
 
+struct seq_closure
+{
+  mu_msgset_t rmset;
+  int rmflag;
+};
+
+static int
+rmseq (const char *name, const char *value, void *data)
+{
+  struct seq_closure *s = data;
+  mu_mailbox_t mbox;
+
+  mu_msgset_sget_mailbox (s->rmset, &mbox);
+  mh_seq_delete (mbox, name, s->rmset, s->rmflag);
+  return 0;
+}
+
 int
 main (int argc, char **argv)
 {
@@ -65,7 +82,8 @@ main (int argc, char **argv)
   mu_mailbox_t mbox;
   mu_msgset_t msgset;
   int status;
-
+  struct seq_closure clos;
+  
   /* Native Language Support */
   MU_APP_INIT_NLS ();
 
@@ -78,6 +96,12 @@ main (int argc, char **argv)
   mh_msgset_parse (&msgset, mbox, argc - index, argv + index, "cur");
 
   status = mu_msgset_foreach_message (msgset, rmm, NULL);
+  
+  clos.rmset = msgset;
+  clos.rmflag = 0;
+  mh_global_sequences_iterate (mbox, rmseq, &clos);
+  clos.rmflag = SEQ_PRIVATE;
+  mh_private_sequences_iterate (mbox, rmseq, &clos);
 
   mu_mailbox_expunge (mbox);
   mu_mailbox_close (mbox);
diff --git a/mh/tests/rmm.at b/mh/tests/rmm.at
index 69cd815..331200f 100644
--- a/mh/tests/rmm.at
+++ b/mh/tests/rmm.at
@@ -45,7 +45,6 @@ sed '/^$/d' Mail/inbox/.mh_sequences
 [0],
 [Mail/inbox/1
 Mail/inbox/4
-test: 2 3 5 
 cur: 1
 ])
 


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Mon Apr 01 18:21:23 2013
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1UMn6R-0006PS-1W
	for mharc-commit-mailutils@gnu.org; Mon, 01 Apr 2013 18:21:23 -0400
Received: from eggs.gnu.org ([208.118.235.92]:39270)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1UMn6N-0006Ow-3v
	for commit-mailutils@gnu.org; Mon, 01 Apr 2013 18:21:21 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1UMn6K-0005SM-0D
	for commit-mailutils@gnu.org; Mon, 01 Apr 2013 18:21:19 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:59826)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1UMn6J-0005SH-Sq
	for commit-mailutils@gnu.org; Mon, 01 Apr 2013 18:21:15 -0400
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1UMn6I-0001MJ-UK
	for commit-mailutils@gnu.org; Mon, 01 Apr 2013 22:21:15 +0000
Date: Mon, 01 Apr 2013 22:21:15 +0000
Message-Id: <E1UMn6I-0001MJ-UK@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-649-g933bc7a
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: d9ddd27acef16ebbb44a0fc096fe86fedab5399d
X-Git-Newrev: 933bc7a293322f1996c791de7a17bb469b1a79e3
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Mon, 01 Apr 2013 22:21:21 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Mailutils".

http://git.savannah.gnu.org/cgit/mailutils.git/commit/?id=933bc7a293322f1996c791de7a17bb469b1a79e3

The branch, master has been updated
       via  933bc7a293322f1996c791de7a17bb469b1a79e3 (commit)
      from  d9ddd27acef16ebbb44a0fc096fe86fedab5399d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 933bc7a293322f1996c791de7a17bb469b1a79e3
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Tue Apr 2 01:21:45 2013 +0300

    Minor fix in docs

-----------------------------------------------------------------------

Summary of changes:
 doc/texinfo/sieve.texi |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/doc/texinfo/sieve.texi b/doc/texinfo/sieve.texi
index ca1a625..c4a1733 100644
--- a/doc/texinfo/sieve.texi
+++ b/doc/texinfo/sieve.texi
@@ -1021,7 +1021,8 @@ Comma-separated list of keywords, describing the spam checks that
 succeeded for this message.
 @end table
 
-@*Example:
+Example:
+
 @smallexample
 request "test-spamd";
 
@@ -1051,7 +1052,8 @@ keywords.  By default, comma is assumed as list separator.  This can be
 overridden by specifying the @code{:delim} tag, whose value is a
 string consisting of valid list delimiter characters.
 
-@*Example:
+Example:
+
 This test can be used in conjunction with the @code{spamd} test
 described above:
 
@@ -1101,7 +1103,8 @@ If no tagged argument is supplied, @code{:after} is assumed.
 Almost any date format is understood.  @xref{Date Input Formats}, for
 a detailed information on date formats.
 
-@*Example:
+Example:
+
 The test below succeeds if the date in @samp{X-Expire-Timestamp}
 header is more than 5 days older than the current date:
 


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Tue Apr 02 14:46:27 2013
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1UN6Dz-0000ky-7v
	for mharc-commit-mailutils@gnu.org; Tue, 02 Apr 2013 14:46:27 -0400
Received: from eggs.gnu.org ([208.118.235.92]:47358)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1UN6Dv-0000kY-0O
	for commit-mailutils@gnu.org; Tue, 02 Apr 2013 14:46:25 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1UN6Ds-0004GI-8Q
	for commit-mailutils@gnu.org; Tue, 02 Apr 2013 14:46:22 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:32798)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1UN6Ds-0004Fs-5P
	for commit-mailutils@gnu.org; Tue, 02 Apr 2013 14:46:20 -0400
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1UN6DS-0003eK-SQ
	for commit-mailutils@gnu.org; Tue, 02 Apr 2013 18:46:17 +0000
Date: Tue, 02 Apr 2013 18:46:12 +0000
Message-Id: <E1UN6DS-0003eK-SQ@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-651-g8fcdf74
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 933bc7a293322f1996c791de7a17bb469b1a79e3
X-Git-Newrev: 8fcdf7455d1948df3c6ed48cfe10a32d393742dd
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Tue, 02 Apr 2013 18:46:25 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Mailutils".

http://git.savannah.gnu.org/cgit/mailutils.git/commit/?id=8fcdf7455d1948df3c6ed48cfe10a32d393742dd

The branch, master has been updated
       via  8fcdf7455d1948df3c6ed48cfe10a32d393742dd (commit)
       via  734f1b388734becb310f15ca461740cbcb09a67a (commit)
      from  933bc7a293322f1996c791de7a17bb469b1a79e3 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 8fcdf7455d1948df3c6ed48cfe10a32d393742dd
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Tue Apr 2 21:46:28 2013 +0300

    MH send: improve compatibility with MH/nmh.

commit 734f1b388734becb310f15ca461740cbcb09a67a
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Tue Apr 2 17:12:47 2013 +0300

    Rewrite mu_utc_offset in a more portable (hopefully) way.

-----------------------------------------------------------------------

Summary of changes:
 libmailutils/datetime/utcoff.c |   11 ++-
 mh/send.c                      |  216 ++++++++++++++++++++++++++++------------
 2 files changed, 162 insertions(+), 65 deletions(-)

diff --git a/libmailutils/datetime/utcoff.c b/libmailutils/datetime/utcoff.c
index d23fa71..ce31cd2 100644
--- a/libmailutils/datetime/utcoff.c
+++ b/libmailutils/datetime/utcoff.c
@@ -20,10 +20,17 @@
 #endif
 #include <time.h>
 
+#define TMSEC(t) (((t)->tm_hour * 60 + (t)->tm_min) * 60 + (t)->tm_sec)
+
 /* Returns the offset of our timezone from UTC, in seconds. */
 int
 mu_utc_offset (void)
 {
-  tzset ();
-  return - timezone;
+  time_t t = time (NULL);
+  struct tm ltm = *localtime (&t);
+  struct tm gtm = *gmtime (&t);
+  int d = TMSEC (&ltm) - TMSEC (&gtm);
+  if (!(ltm.tm_year = gtm.tm_year && ltm.tm_mon == gtm.tm_mon))
+    d += 86400;
+  return d;
 }
diff --git a/mh/send.c b/mh/send.c
index 2fd1e92..4f15d4c 100644
--- a/mh/send.c
+++ b/mh/send.c
@@ -35,8 +35,8 @@ static struct argp_option options[] = {
    N_("use prepared draft") },
   {"draftfolder",   ARG_DRAFTFOLDER,   N_("FOLDER"), 0,
    N_("specify the folder for message drafts") },
-  {"draftmessage",  ARG_DRAFTMESSAGE,  NULL, 0,
-   N_("treat the arguments as a list of messages from the draftfolder") },
+  {"draftmessage",  ARG_DRAFTMESSAGE,  N_("MSG"), 0,
+   N_("use MSG from the draftfolder as a draft") },
   {"nodraftfolder", ARG_NODRAFTFOLDER, NULL, 0,
    N_("undo the effect of the last --draftfolder option") },
   {"filter",        ARG_FILTER,        N_("FILE"), 0,
@@ -99,9 +99,10 @@ struct mh_option mh_option[] = {
   { NULL }
 };
 
-static int use_draft;            /* Use the prepared draft */
 static const char *draftfolder;  /* Use this draft folder */
-static char *draftmessage = "cur";
+static int use_draftfolder = 1;
+static int use_draft;
+
 static int reformat_recipients;  /* --format option */
 static int forward_notice;       /* Forward the failure notice to the sender,
 				    --forward flag */
@@ -126,6 +127,9 @@ static int keep_files;           /* Keep draft files */
     watch_printf c;\
 } while (0)
 
+static int add_file (char *name);
+static void mesg_list_fixup (void);
+
 static error_t
 opt_handler (int key, char *arg, struct argp_state *state)
 {
@@ -152,14 +156,16 @@ opt_handler (int key, char *arg, struct argp_state *state)
 	
     case ARG_DRAFTFOLDER:
       draftfolder = arg;
+      use_draftfolder = 1;
       break;
       
     case ARG_NODRAFTFOLDER:
       draftfolder = NULL;
+      use_draftfolder = 0;
       break;
       
     case ARG_DRAFTMESSAGE:
-      draftmessage = arg;
+      add_file (arg);
       break;
       
     case ARG_FILTER:
@@ -284,30 +290,58 @@ static mu_list_t mesg_list;
 static mu_property_t mts_profile;
 
 int
-check_file (char *name)
+add_file (char *name)
 {
   struct list_elt *elt;
-  mu_message_t msg;
-  char *file_name = mh_expand_name (draftfolder, name, 0);
-  
-  msg = mh_file_to_message (NULL, file_name);
-  if (!msg)
-    {
-      free (file_name);
-      return 1;
-    }
+
   if (!mesg_list && mu_list_create (&mesg_list))
     {
-      free (file_name);
       mu_error (_("cannot create message list"));
       return 1;
     }
+  
   elt = mu_alloc (sizeof *elt);
-  elt->file_name = file_name;
-  elt->msg = msg;
+  elt->file_name = name;
+  elt->msg = NULL;
   return mu_list_append (mesg_list, elt);
 }
 
+int
+checkdraft (const char *name)
+{
+  struct stat st;
+  
+  if (stat (name, &st))
+    {
+      mu_error (_("unable to stat draft file %s: %s"), name,
+		mu_strerror (errno));
+      return 1;
+    }
+  return 0;
+}
+
+int
+elt_fixup (void *item, void *data)
+{
+  struct list_elt *elt = item;
+  
+  elt->file_name = mh_expand_name (draftfolder, elt->file_name, 0);
+  if (checkdraft (elt->file_name))
+    exit (1);
+  elt->msg = mh_file_to_message (NULL, elt->file_name);
+  if (!elt->msg)
+    return 1;
+
+  return 0;
+}
+
+void
+mesg_list_fixup ()
+{
+  if (mesg_list && mu_list_foreach (mesg_list, elt_fixup, NULL))
+    exit (1);
+}  
+
 void
 read_mts_profile ()
 {
@@ -741,11 +775,25 @@ _add_to_mesg_list (size_t num, mu_message_t msg, void *data)
   struct list_elt *elt;
   size_t uid;
   int rc;
+  char *file_name;
+  
+  if (!mesg_list && mu_list_create (&mesg_list))
+    {
+      mu_error (_("cannot create message list"));
+      return 1;
+    }
+
+  mu_message_get_uid (msg, &uid);
+  file_name = mu_make_file_name (path, mu_umaxtostr (0, uid));
+  if (!use_draft)
+    {
+      if (!mh_usedraft (file_name))
+	exit (0);
+    }
   
   elt = mu_alloc (sizeof *elt);
   elt->msg = msg;
-  mu_message_get_uid (msg, &uid);
-  elt->file_name = mu_make_file_name (path, mu_umaxtostr (0, uid));
+  elt->file_name = file_name;
   rc = mu_list_append (mesg_list, elt);
   if (rc)
     {
@@ -755,6 +803,57 @@ _add_to_mesg_list (size_t num, mu_message_t msg, void *data)
   return 0;
 }
 
+static void
+addfolder (const char *folder, int argc, char **argv)
+{
+  mu_url_t url;
+  const char *path;
+  mu_msgset_t msgset;
+  
+  mu_mailbox_t mbox = mh_open_folder (folder, MU_STREAM_READ);
+  if (!mbox)
+    {
+      mu_error (_("cannot open folder %s: %s"), folder,
+		mu_strerror (errno));
+      exit (1);
+    }
+
+  mh_msgset_parse (&msgset, mbox, argc, argv, "cur");
+  if (!use_draft)
+    {
+      size_t count = 0;
+      mu_msgset_count (msgset, &count);
+      if (count > 1)
+	use_draft = 1;
+    }
+
+  mu_mailbox_get_url (mbox, &url);
+  mu_url_sget_path (url, &path);
+  mu_msgset_foreach_message (msgset, _add_to_mesg_list, (void*)path);
+      
+  mu_msgset_free (msgset);
+}
+
+/* Usage cases:
+ *
+ * 1. send
+ *   a) If Draft-Folder is set: ask whether to use "cur" message from that
+ *      folder as a draft;
+ *   b) If Draft-Folder is not set: ask whether to use $(Path)/draft;
+ * 2. send -draft
+ *   Use $(Path)/draft
+ * 3. send MSG
+ *   Use $(Path)/MSG
+ * 4. send -draftmessage MSG
+ *   Same as (3)
+ * 5. send -draftfolder DIR
+ *   Use "cur" from that folder
+ * 6. send -draftfolder DIR MSG
+ *   Use MSG from folder DIR
+ * 7. send -draftfolder DIR -draftmessage MSG
+ *   Same as 6.
+ */
+
 int
 main (int argc, char **argv)
 {
@@ -768,61 +867,52 @@ main (int argc, char **argv)
   mh_argp_init ();
   mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc,
 		 opt_handler, NULL, &index);
+  argc -= index;
+  argv += index;
 
   mh_read_aliases ();
   /* Process the mtstailor file */
   read_mts_profile ();
  
-  argc -= index;
-  argv += index;
-
-  if (draftfolder)
+  if (!draftfolder)
     {
-      mu_msgset_t msgset;
-      mu_url_t url;
-      const char *path;
-      
-      mbox = mh_open_folder (draftfolder, MU_STREAM_RDWR|MU_STREAM_CREAT);
-      mh_msgset_parse (&msgset, mbox, argc, argv, draftmessage);
-      mu_mailbox_get_url (mbox, &url);
-      mu_url_sget_path (url, &path);
-      if ((rc = mu_list_create (&mesg_list)))
+      if (mu_list_is_empty (mesg_list) && argc == 0)
 	{
-	  mu_error (_("cannot create message list: %s"), mu_strerror (rc));
-	  exit (1);
-	}
-      mu_msgset_foreach_message (msgset, _add_to_mesg_list, (void*)path);
-      
-      mu_msgset_free (msgset);
-    }
-  else
-    {
-      int i;
-      
-      if (argc == 0)
-	{
-	  char *xargv[2];
-	  struct stat st;
-	  
-	  xargv[0] = mh_draft_name ();
+	  char *dfolder =
+	    (!use_draft && use_draftfolder) ?
+	       mh_global_profile_get ("Draft-Folder", NULL) : NULL;
 
-	  if (stat (xargv[0], &st))
+	  if (dfolder)
+	    addfolder (dfolder, 0, NULL);
+	  else
 	    {
-	      mu_diag_funcall (MU_DIAG_ERROR, "stat", xargv[0], errno);
-	      return 1;
+	      char *df = mh_expand_name (mu_folder_directory (), "draft", 0);
+	      if (checkdraft (df))
+		exit (1);
+	      if (!use_draft && !mh_usedraft (df))
+		exit (0);
+	      add_file (df);
+	      mesg_list_fixup ();
 	    }
-
-	  if (!use_draft && !mh_usedraft (xargv[0]))
-	    exit (0);
-	  xargv[1] = NULL;
-	  argv = xargv;
-	  argc = 1;
 	}
-      for (i = 0; i < argc; i++)
-	if (check_file (argv[i]))
-	  return 1;
+      else
+	{
+	  while (argc--)
+	    add_file (*argv++);
+	  mesg_list_fixup ();
+	}
     }
-
+  else
+    {
+      /* -draftfolder is supplied */
+      draftfolder = mh_expand_name (mu_folder_directory (),
+				    draftfolder, 0);
+      use_draft = 1;
+      mesg_list_fixup ();
+      if (mu_list_is_empty (mesg_list) || argc != 0)
+	addfolder (draftfolder, argc, argv);
+    }
+  
   /* Detach from the console if required */
   if (background && daemon (0, 0) < 0)
     {


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Wed Apr 03 06:33:05 2013
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1UNL05-0001zx-LE
	for mharc-commit-mailutils@gnu.org; Wed, 03 Apr 2013 06:33:05 -0400
Received: from eggs.gnu.org ([208.118.235.92]:40781)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1UNKzx-0001lE-W7
	for commit-mailutils@gnu.org; Wed, 03 Apr 2013 06:33:03 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1UNKzr-0004PZ-Cb
	for commit-mailutils@gnu.org; Wed, 03 Apr 2013 06:32:57 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:35149)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1UNKzr-0004PV-8S
	for commit-mailutils@gnu.org; Wed, 03 Apr 2013 06:32:51 -0400
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1UNKzq-0000zO-JX
	for commit-mailutils@gnu.org; Wed, 03 Apr 2013 10:32:51 +0000
Date: Wed, 03 Apr 2013 10:32:50 +0000
Message-Id: <E1UNKzq-0000zO-JX@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-652-gae06384
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 8fcdf7455d1948df3c6ed48cfe10a32d393742dd
X-Git-Newrev: ae06384d11d4b1f6ca576630f833ec2f32e6b05a
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Wed, 03 Apr 2013 10:33:03 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Mailutils".

http://git.savannah.gnu.org/cgit/mailutils.git/commit/?id=ae06384d11d4b1f6ca576630f833ec2f32e6b05a

The branch, master has been updated
       via  ae06384d11d4b1f6ca576630f833ec2f32e6b05a (commit)
      from  8fcdf7455d1948df3c6ed48cfe10a32d393742dd (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit ae06384d11d4b1f6ca576630f833ec2f32e6b05a
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Wed Apr 3 13:33:23 2013 +0300

    Add support for Unseen-Sequence in inc.
    
    * mh/inc.c (main): Append the numbers of incorporated messages to
    Unseen-Sequence, if defined in .mh_profile.

-----------------------------------------------------------------------

Summary of changes:
 mh/inc.c |   23 +++++++++++++++++------
 1 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/mh/inc.c b/mh/inc.c
index 16e1206..a07ddd1 100644
--- a/mh/inc.c
+++ b/mh/inc.c
@@ -351,7 +351,7 @@ incmbx (void *item, void *data)
       mh_audit_close (audit_fp);
       audit_fp = NULL;
     }
-  
+
   mu_mailbox_close (input);
   mu_mailbox_destroy (&input);
 
@@ -365,7 +365,9 @@ main (int argc, char **argv)
   int rc;
   int f_truncate = 0;
   int f_changecur = 0;
-
+  size_t lastseen;
+  char *unseen_seq;
+  
   /* Native Language Support */
   MU_APP_INIT_NLS ();
 
@@ -390,6 +392,7 @@ main (int argc, char **argv)
 		mu_strerror (errno));
       exit (1);
     }
+  lastseen = incdat.lastmsg + 1;
   
   /* Fixup options */
   if (!input_file_list)
@@ -403,12 +406,20 @@ main (int argc, char **argv)
     incmbx (NULL, &incdat);
   else
     mu_list_foreach (input_file_list, incmbx, &incdat);
-    
-  if (!changecur)
+
+  unseen_seq = mh_global_profile_get ("Unseen-Sequence", NULL);
+  if (unseen_seq)
     {
-      mu_property_t prop = mh_mailbox_get_property (incdat.output);
-      mu_property_invalidate (prop);
+      mu_msgset_t unseen;
+
+      mu_msgset_create (&unseen, NULL, MU_MSGSET_NUM);
+      mu_msgset_add_range (unseen, lastseen, incdat.lastmsg, MU_MSGSET_NUM);
+      mh_seq_add (incdat.output,
+		  unseen_seq,
+		  unseen, 0);
+      mu_msgset_free (unseen);
     }
+  
   mh_global_save_state ();
   
   mu_mailbox_close (incdat.output);


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Sun Apr 07 04:22:09 2013
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1UOkrZ-0006AJ-2l
	for mharc-commit-mailutils@gnu.org; Sun, 07 Apr 2013 04:22:09 -0400
Received: from eggs.gnu.org ([208.118.235.92]:36799)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1UOkrR-00069K-87
	for commit-mailutils@gnu.org; Sun, 07 Apr 2013 04:22:07 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1UOkrO-00051x-4W
	for commit-mailutils@gnu.org; Sun, 07 Apr 2013 04:22:01 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:46490)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1UOkrN-00051t-Tk
	for commit-mailutils@gnu.org; Sun, 07 Apr 2013 04:21:58 -0400
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1UOkrN-0005Zv-BO
	for commit-mailutils@gnu.org; Sun, 07 Apr 2013 08:21:57 +0000
Date: Sun, 07 Apr 2013 08:21:57 +0000
Message-Id: <E1UOkrN-0005Zv-BO@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-653-gd7dec96
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: ae06384d11d4b1f6ca576630f833ec2f32e6b05a
X-Git-Newrev: d7dec96841e872ffa6924d6c5f93a1be473bf8ff
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 07 Apr 2013 08:22:08 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Mailutils".

http://git.savannah.gnu.org/cgit/mailutils.git/commit/?id=d7dec96841e872ffa6924d6c5f93a1be473bf8ff

The branch, master has been updated
       via  d7dec96841e872ffa6924d6c5f93a1be473bf8ff (commit)
      from  ae06384d11d4b1f6ca576630f833ec2f32e6b05a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit d7dec96841e872ffa6924d6c5f93a1be473bf8ff
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Sun Apr 7 11:23:18 2013 +0300

    Fix MH sequence parser.
    
    * mh/mh_msgset.c (parse_range): Fix resolving non-existing UIDs.
    * mh/tests/mhseq.at: Add more test cases.

-----------------------------------------------------------------------

Summary of changes:
 mh/mh_msgset.c    |  144 ++++++++++++++++++++++++++++++++++++++---------------
 mh/tests/mhseq.at |  114 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 218 insertions(+), 40 deletions(-)

diff --git a/mh/mh_msgset.c b/mh/mh_msgset.c
index 305143e..47e6e7e 100644
--- a/mh/mh_msgset.c
+++ b/mh/mh_msgset.c
@@ -98,7 +98,6 @@ mh_msgset_single_message (mu_msgset_t msgset)
     }
   return r->msg_beg == r->msg_end;
 }
-
 
 struct msgset_parser
 {
@@ -466,22 +465,42 @@ parse_range (struct msgset_parser *parser)
 	return 0;
       if (!validuid)
 	{
-	  size_t total, lastuid;
-	  msgset_last (parser->msgset->mbox, &total);
-	  mu_mailbox_translate (parser->msgset->mbox,
-				MU_MAILBOX_MSGNO_TO_UID,
-				total, &lastuid);
-	  if (start > lastuid)
+	  if (parser->sign)
 	    {
-	      if (!parser->sign)
-		emptyrange_abort (parser->argv[-1]);
-	      start = total;
+	      while (1)
+		{
+		  if (--start == 0)
+		    emptyrange_abort (parser->argv[-1]);
+		  if (mu_mailbox_translate (parser->msgset->mbox,
+					    MU_MAILBOX_UID_TO_MSGNO,
+					    start, &start) == 0)
+		    break;
+		}
 	    }
 	  else
 	    {
-	      if (parser->sign)
+	      size_t total, lastuid;
+	  
+	      msgset_last (parser->msgset->mbox, &total);
+	      mu_mailbox_translate (parser->msgset->mbox,
+				    MU_MAILBOX_MSGNO_TO_UID,
+				    total, &lastuid);
+	      if (start > lastuid)
 		emptyrange_abort (parser->argv[-1]);
-	      start = 1;
+	      else
+		while (1)
+		  {
+		    if (start == lastuid)
+		      {
+			start = total;
+			break;
+		      }
+		    ++start;
+		    if (mu_mailbox_translate (parser->msgset->mbox,
+					      MU_MAILBOX_UID_TO_MSGNO,
+					      start, &start) == 0)
+		      break;
+		  }
 	    }
 	}
       add_messages (parser, start, parser->number, parser->sign);
@@ -489,47 +508,92 @@ parse_range (struct msgset_parser *parser)
     }
   else if (*parser->curp == '-')
     {
-      size_t lastuid = 0;
       int validuid = parser->validuid;
       int rc;
       
       parser->curp++;
       if (parse_term (parser, 0) == PARSE_EOF)
 	return 0;
-      if (!parser->validuid)
+
+      /* If any of UIDs does not exist, try to find the nearest
+	 existing one: */
+      if (!validuid || !parser->validuid)
 	{
-	  size_t total;
+	  size_t lastuid, num, maxnum;
 
-	  msgset_last (parser->msgset->mbox, &total);
+	  /* Order the limits */
+	  if (!parser->validuid)
+	    maxnum = parser->number;
+	  else
+	    mu_mailbox_translate (parser->msgset->mbox,
+				  MU_MAILBOX_MSGNO_TO_UID,
+				  parser->number, &maxnum);
+	  if (!validuid)
+	    num = start;
+	  else
+	    mu_mailbox_translate (parser->msgset->mbox,
+				  MU_MAILBOX_MSGNO_TO_UID,
+				  start, &num);
+
+	  if (num > maxnum)
+	    {
+	      int v;
+	      size_t n;
+
+	      n = parser->number;
+	      v = parser->validuid;
+	      parser->number = start;
+	      parser->validuid = validuid;
+	      start = n;
+	      validuid = v;
+	    }
+
+	  /* Adjust upper bound */
+	  msgset_last (parser->msgset->mbox, &num);
 	  mu_mailbox_translate (parser->msgset->mbox, MU_MAILBOX_MSGNO_TO_UID,
-				total, &lastuid);
+				num, &lastuid);
 
-	  if (parser->number > lastuid)
-	    parser->number = total;
-	  else if (!validuid)
-	    emptyrange_abort (parser->argv[-1]);
-	}
-      if (!validuid)
-	{
-	  if (!lastuid)
+	  if (!parser->validuid && parser->number > lastuid)
 	    {
-	      size_t total;
-	      msgset_last (parser->msgset->mbox, &total);
-	      mu_mailbox_translate (parser->msgset->mbox,
-				    MU_MAILBOX_MSGNO_TO_UID,
-				    total, &lastuid);
+	      parser->number = num;
+	      parser->validuid = 1;
 	    }
-	  if (start > lastuid && !parser->validuid)
-	    emptyrange_abort (parser->argv[-1]);
-	  start = 1;
-	}
-      rc = mu_msgset_add_range (parser->msgset, start, parser->number,
-				MU_MSGSET_NUM);
-      if (rc)
-	{
-	  mu_diag_funcall (MU_DIAG_ERROR, "mu_msgset_add_range", NULL, rc);
-	  exit (1);
+
+	  /* Shift the bounds towards each other until they resolve to
+	     existing UIDs or clash */
+	  do
+	    {
+	      if (!validuid)
+		{
+		  ++start;
+		  if (start > lastuid)
+		    emptyrange_abort (parser->argv[-1]);
+		  rc = mu_mailbox_translate (parser->msgset->mbox,
+					     MU_MAILBOX_UID_TO_MSGNO,
+					     start, &start);
+		  if (rc == 0)
+		    validuid = 1;
+		}
+	      if (!parser->validuid)
+		{
+		  if (parser->number == 1)
+		    emptyrange_abort (parser->argv[-1]);
+		  --parser->number;
+		  rc = mu_mailbox_translate (parser->msgset->mbox,
+					     MU_MAILBOX_UID_TO_MSGNO,
+					     parser->number, &num);
+		  if (rc == 0)
+		    {
+		      lastuid = parser->number;
+		      parser->number = num;
+		      parser->validuid = 1;
+		    }
+		}
+	    }
+	  while (!validuid || !parser->validuid);
 	}
+      mu_msgset_add_range (parser->msgset, start, parser->number,
+			   MU_MSGSET_NUM);
     }
   else if (!parser->validuid)
     {
diff --git a/mh/tests/mhseq.at b/mh/tests/mhseq.at
index a66b885..a097743 100644
--- a/mh/tests/mhseq.at
+++ b/mh/tests/mhseq.at
@@ -406,5 +406,119 @@ mhseq last:2
 5
 ])
 
+MH_CHECK([mhseq: sparse increasing message range (left fixup in the middle)],
+[mhseq34],[
+MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
+mv Mail/inbox/5 Mail/inbox/20
+mv Mail/inbox/4 Mail/inbox/15
+mv Mail/inbox/3 Mail/inbox/8
+MUT_MBCHMOD(Mail/inbox, 700)
+mhseq 5-15
+],
+[0],
+[8
+15
+])
+
+MH_CHECK([mhseq: sparse increasing message range (right fixup in the middle)],
+[mhseq35],[
+MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
+mv Mail/inbox/5 Mail/inbox/20
+mv Mail/inbox/4 Mail/inbox/15
+mv Mail/inbox/3 Mail/inbox/8
+MUT_MBCHMOD(Mail/inbox, 700)
+mhseq 8-17
+],
+[0],
+[8
+15
+])
+
+MH_CHECK([mhseq: sparse increasing message range (both fixups in the middle)],
+[mhseq36],[
+MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
+mv Mail/inbox/5 Mail/inbox/20
+mv Mail/inbox/4 Mail/inbox/15
+mv Mail/inbox/3 Mail/inbox/8
+MUT_MBCHMOD(Mail/inbox, 700)
+mhseq 5-17
+],
+[0],
+[8
+15
+])
+
+MH_CHECK([mhseq: sparse decreasing message range (left fixup in the middle)],
+[mhseq37],[
+MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
+mv Mail/inbox/5 Mail/inbox/20
+mv Mail/inbox/4 Mail/inbox/15
+mv Mail/inbox/3 Mail/inbox/8
+MUT_MBCHMOD(Mail/inbox, 700)
+mhseq 15-5
+],
+[0],
+[8
+15
+])
+
+MH_CHECK([mhseq: sparse decreasing message range (right fixup in the middle)],
+[mhseq38],[
+MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
+mv Mail/inbox/5 Mail/inbox/20
+mv Mail/inbox/4 Mail/inbox/15
+mv Mail/inbox/3 Mail/inbox/8
+MUT_MBCHMOD(Mail/inbox, 700)
+mhseq 17-8
+],
+[0],
+[8
+15
+])
+
+MH_CHECK([mhseq: sparse decreasing message range (both fixups in the middle)],
+[mhseq39],[
+MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
+mv Mail/inbox/5 Mail/inbox/20
+mv Mail/inbox/4 Mail/inbox/15
+mv Mail/inbox/3 Mail/inbox/8
+MUT_MBCHMOD(Mail/inbox, 700)
+mhseq 17-5
+],
+[0],
+[8
+15
+])
+
+MH_CHECK([mhseq: sparse counted range (positive, fixup)],
+[mhseq40],[
+MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
+mv Mail/inbox/5 Mail/inbox/20
+mv Mail/inbox/4 Mail/inbox/15
+mv Mail/inbox/3 Mail/inbox/8
+MUT_MBCHMOD(Mail/inbox, 700)
+mhseq 3:2
+],
+[0],
+[8
+15
+])
+
+MH_CHECK([mhseq: sparse counted range (negative, fixup)],
+[mhseq41],[
+MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox])
+mv Mail/inbox/5 Mail/inbox/20
+mv Mail/inbox/4 Mail/inbox/15
+mv Mail/inbox/3 Mail/inbox/8
+MUT_MBCHMOD(Mail/inbox, 700)
+mhseq 17:-3
+],
+[0],
+[2
+8
+15
+])
+
+
 m4_popdef([MH_KEYWORDS])
 # End of mhseq.at
\ No newline at end of file


hooks/post-receive
-- 
GNU Mailutils


From MAILER-DAEMON Fri Apr 12 02:28:55 2013
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1UQXTj-000186-OV
	for mharc-commit-mailutils@gnu.org; Fri, 12 Apr 2013 02:28:55 -0400
Received: from eggs.gnu.org ([208.118.235.92]:59183)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1UQXTf-000174-Bt
	for commit-mailutils@gnu.org; Fri, 12 Apr 2013 02:28:54 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1UQXTc-0002Ff-Kp
	for commit-mailutils@gnu.org; Fri, 12 Apr 2013 02:28:51 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:34929)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1UQXTc-0002Fa-Fa
	for commit-mailutils@gnu.org; Fri, 12 Apr 2013 02:28:48 -0400
Received: from gray by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <INVALID.NOREPLY@gnu.org>) id 1UQXRr-0004MA-Jx
	for commit-mailutils@gnu.org; Fri, 12 Apr 2013 06:28:09 +0000
Date: Fri, 12 Apr 2013 06:27:26 +0000
Message-Id: <E1UQXRr-0004MA-Jx@vcs.savannah.gnu.org>
From: "Sergey Poznyakoff" <gray@gnu.org.ua>
To: commit-mailutils@gnu.org
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-654-gec100ee
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: d7dec96841e872ffa6924d6c5f93a1be473bf8ff
X-Git-Newrev: ec100ee63e55ba60369363c72d6d2e1fbc3663a2
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: commit-mailutils@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Commit notices for GNU mailutils <commit-mailutils.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/commit-mailutils>
List-Post: <mailto:commit-mailutils@gnu.org>
List-Help: <mailto:commit-mailutils-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/commit-mailutils>,
	<mailto:commit-mailutils-request@gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 12 Apr 2013 06:28:54 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Mailutils".

http://git.savannah.gnu.org/cgit/mailutils.git/commit/?id=ec100ee63e55ba60369363c72d6d2e1fbc3663a2

The branch, master has been updated
       via  ec100ee63e55ba60369363c72d6d2e1fbc3663a2 (commit)
      from  d7dec96841e872ffa6924d6c5f93a1be473bf8ff (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit ec100ee63e55ba60369363c72d6d2e1fbc3663a2
Author: Sergey Poznyakoff <gray@gnu.org.ua>
Date:   Fri Apr 12 09:20:47 2013 +0300

    Implement MH show utility.
    
    * mh/show.c: New file.
    * NEWS: Document changes.
    * libmailutils/stream/message_stream.c (copy_trimmed_value): Fix
    string length calculation to allow for empty lines.
    * mh/.gitignore: Update.
    * mh/Makefile.am: Build show.
    * mh/TODO: Document show.
    * mh/mh_getopt.h: Add new option codes.
    * mh/mh_init.c (mh_expand_name): Change handling of the
    last argument. All callers updated.
    (mh_draft_name): Remove.

-----------------------------------------------------------------------

Summary of changes:
 NEWS                                 |    6 +-
 libmailutils/stream/message_stream.c |    3 +-
 mh/.gitignore                        |    1 +
 mh/Makefile.am                       |    1 +
 mh/TODO                              |    2 +
 mh/comp.c                            |    4 +-
 mh/folder.c                          |    5 +-
 mh/forw.c                            |    2 +-
 mh/mh.h                              |    6 +-
 mh/mh_alias.l                        |    2 +-
 mh/mh_getopt.h                       |    2 +
 mh/mh_global.c                       |    2 +-
 mh/mh_init.c                         |   35 ++--
 mh/mh_sequence.c                     |    2 +-
 mh/mhn.c                             |    2 +-
 mh/repl.c                            |    4 +-
 mh/rmf.c                             |    2 +-
 mh/send.c                            |    9 +-
 mh/show.c                            |  363 ++++++++++++++++++++++++++++++++++
 mh/whatnow.c                         |    2 +-
 mh/whom.c                            |    4 +-
 21 files changed, 422 insertions(+), 37 deletions(-)
 create mode 100644 mh/show.c

diff --git a/NEWS b/NEWS
index 06632e5..68b7661 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,4 @@
-GNU mailutils NEWS -- history of user-visible changes. 2013-03-21
+GNU mailutils NEWS -- history of user-visible changes. 2013-04-12
 Copyright (C) 2002-2013 Free Software Foundation, Inc.
 See the end of file for copying conditions.
 
@@ -176,6 +176,10 @@ input folders of type IMAP or IMAPS. A sample usage is:
 
 Note the `-truncate' option. 
 
+** MH show and msgchk
+
+Implemented two new programs: show and msgchk.
+
 ** MH: multiple sources
 
 The `inc' command is able to incorporate messages from several
diff --git a/libmailutils/stream/message_stream.c b/libmailutils/stream/message_stream.c
index e05ac6e..b48c4c0 100644
--- a/libmailutils/stream/message_stream.c
+++ b/libmailutils/stream/message_stream.c
@@ -138,7 +138,8 @@ copy_trimmed_value (const char *str)
   size_t len;
   
   str = mu_str_skip_class (str, MU_CTYPE_SPACE);
-  len = strlen (str) - 1;
+  p = mu_str_skip_class_comp (str, MU_CTYPE_ENDLN);
+  len = p - str;
   p = malloc (len + 1);
   memcpy (p, str, len);
   p[len] = 0;
diff --git a/mh/.gitignore b/mh/.gitignore
index 1b897e3..4e2b87b 100644
--- a/mh/.gitignore
+++ b/mh/.gitignore
@@ -33,6 +33,7 @@ repl
 rmf
 rmm
 scan
+show
 send
 sortm
 whatnow
diff --git a/mh/Makefile.am b/mh/Makefile.am
index 9b05c4f..96c99a4 100644
--- a/mh/Makefile.am
+++ b/mh/Makefile.am
@@ -42,6 +42,7 @@ bin_PROGRAMS = \
  rmf\
  rmm\
  scan\
+ show\
  send\
  sortm\
  whatnow\
diff --git a/mh/TODO b/mh/TODO
index 6620fab..ea10be6 100644
--- a/mh/TODO
+++ b/mh/TODO
@@ -42,6 +42,7 @@ State	Nice	Utility		Comments
 +	20	sortm
 +       20      prompter
 *       20      msgchk          --date functionality not implemented
++       20      show            next, prev not implemented
 
 Utilities In Alphabetical Order
 ===============================
@@ -64,6 +65,7 @@ repl
 rmf
 rmm
 send
+show
 sortm
 whatnow
 whom
diff --git a/mh/comp.c b/mh/comp.c
index 36feca4..544a8b2 100644
--- a/mh/comp.c
+++ b/mh/comp.c
@@ -126,7 +126,7 @@ opt_handler (int key, char *arg, struct argp_state *state)
       break;
       
     case ARG_FILE:
-      wh_env.file = mh_expand_name (NULL, arg, 0);
+      wh_env.file = mh_expand_name (NULL, arg, NAME_ANY);
       break;
 	
     case ARG_NODRAFTFOLDER:
@@ -218,7 +218,7 @@ main (int argc, char **argv)
     }
   else if (folder_set)
     {
-      wh_env.file = mh_expand_name (NULL, "draft", 0);
+      wh_env.file = mh_expand_name (NULL, "draft", NAME_ANY);
     }
   else
     {
diff --git a/mh/folder.c b/mh/folder.c
index 19aecc2..25a5c23 100644
--- a/mh/folder.c
+++ b/mh/folder.c
@@ -459,7 +459,7 @@ action_print ()
     }
   else
     {
-      char *p = mh_expand_name (NULL, mh_current_folder (), 0);
+      char *p = mh_expand_name (NULL, mh_current_folder (), NAME_ANY);
       _scan (p, 1);
       free (p);
     }
@@ -854,7 +854,8 @@ fixup_private (const char *name, const char *value, void *data)
 int
 action_pack ()
 {
-  const char *folder_dir = mh_expand_name (NULL, mh_current_folder (), 0);
+  const char *folder_dir = mh_expand_name (NULL, mh_current_folder (), 
+                                           NAME_ANY);
   mu_mailbox_t mbox = mh_open_folder (mh_current_folder (), MU_STREAM_RDWR);
   struct pack_tab *pack_tab;
   size_t i, count, start;
diff --git a/mh/forw.c b/mh/forw.c
index c768756..74b1f68 100644
--- a/mh/forw.c
+++ b/mh/forw.c
@@ -505,7 +505,7 @@ main (int argc, char **argv)
     }
   
   if (build_only || !draftfolder)
-    wh_env.file = mh_expand_name (NULL, "draft", 0);
+    wh_env.file = mh_expand_name (NULL, "draft", NAME_ANY);
   else if (draftfolder)
     {
       if (mh_draft_message (draftfolder, draftmessage, &wh_env.file))
diff --git a/mh/mh.h b/mh/mh.h
index ac34fbc..4ff34d5 100644
--- a/mh/mh.h
+++ b/mh/mh.h
@@ -306,9 +306,13 @@ size_t mh_msgset_first (mu_msgset_t msgset);
 size_t mh_msgset_first_uid (mu_msgset_t msgset);
 int mh_msgset_single_message (mu_msgset_t msgset);
 
+#define NAME_ANY    0
+#define NAME_FOLDER 1
+#define NAME_FILE   2
+char *mh_expand_name (const char *base, const char *name, int what);
+
 char *mh_get_dir (void);
 int mh_find_file (const char *name, char **resolved_name);
-char *mh_expand_name (const char *base, const char *name, int is_folder);
 void mh_quote (const char *in, char **out);
 void mh_expand_aliases (mu_message_t msg, mu_address_t *addr_to,
 			mu_address_t *addr_cc,
diff --git a/mh/mh_alias.l b/mh/mh_alias.l
index 94e5428..932f23e 100644
--- a/mh/mh_alias.l
+++ b/mh/mh_alias.l
@@ -246,7 +246,7 @@ push_source (const char *name, int fail)
   char *filename;
   int ex = 0;
   
-  filename = mh_expand_name (NULL, name, 0);
+  filename = mh_expand_name (NULL, name, NAME_ANY);
   if (stat (filename, &st))
     {
       if (fail)
diff --git a/mh/mh_getopt.h b/mh/mh_getopt.h
index a46ddb2..35a4f3b 100644
--- a/mh/mh_getopt.h
+++ b/mh/mh_getopt.h
@@ -135,6 +135,7 @@ enum mh_arg {
   ARG_NORMALIZE,          
   ARG_NOSERIALONLY,	
   ARG_NOSHOW,		
+  ARG_NOSHOWPROC,
   ARG_NOSTORE,		
   ARG_NOT,		
   ARG_NOTEXTFIELD,	
@@ -168,6 +169,7 @@ enum mh_arg {
   ARG_SEQUENCE,		
   ARG_SERIALONLY,		
   ARG_SHOW,		
+  ARG_SHOWPROC,
   ARG_SOURCE,		
   ARG_SPLIT,		
   ARG_STORE,		
diff --git a/mh/mh_global.c b/mh/mh_global.c
index 4bb4dcc..8a5fefe 100644
--- a/mh/mh_global.c
+++ b/mh/mh_global.c
@@ -76,7 +76,7 @@ _mh_init_global_context ()
   p = getenv ("CONTEXT");
   if (!p)
     p = MH_CONTEXT_FILE;
-  ctx_name = mh_expand_name (NULL, p, 0);
+  ctx_name = mh_expand_name (NULL, p, NAME_ANY);
 
   mu_mh_context = mh_read_property_file (ctx_name, 0);
   
diff --git a/mh/mh_init.c b/mh/mh_init.c
index 8af3c2e..e0b38ca 100644
--- a/mh/mh_init.c
+++ b/mh/mh_init.c
@@ -437,7 +437,7 @@ mh_open_folder (const char *folder, int flags)
   mu_mailbox_t mbox = NULL;
   char *name;
   
-  name = mh_expand_name (NULL, folder, 1);
+  name = mh_expand_name (NULL, folder, NAME_FOLDER);
   if ((flags & MU_STREAM_CREAT) && mh_check_folder (name, 1))
     exit (0);
     
@@ -482,7 +482,7 @@ mh_get_dir ()
 }
 
 char *
-mh_expand_name (const char *base, const char *name, int is_folder)
+mh_expand_name (const char *base, const char *name, int what)
 {
   char *p = NULL;
   char *namep = NULL;
@@ -495,11 +495,13 @@ mh_expand_name (const char *base, const char *name, int is_folder)
       char *cwd = mu_getcwd ();
       char *tmp = mh_safe_make_file_name (cwd, namep);
       free (cwd);
+      if (what == NAME_FILE)
+	return tmp;
       free (namep);
       namep = tmp;
     }
   
-  if (is_folder)
+  if (what == NAME_FOLDER)
     {
       if (memcmp (namep, "mh:/", 4) == 0)
 	return namep;
@@ -510,7 +512,17 @@ mh_expand_name (const char *base, const char *name, int is_folder)
                      namep);
     }
   else if (namep[0] != '/')
-    mu_asprintf (&p, "%s/%s", base ? base : mu_folder_directory (), namep);
+    {
+        if (what == NAME_FILE)
+	  {
+	    char *cwd = mu_getcwd ();
+	    p = mh_safe_make_file_name (cwd, namep);
+	    free (cwd);
+	  }
+	else
+	  p = mh_safe_make_file_name (base ? base : mu_folder_directory (),
+				      namep);
+    }
   else
     return namep;
   
@@ -543,7 +555,7 @@ mh_find_file (const char *name, char **resolved_name)
       return errno;
     }
   
-  s = mh_expand_name (NULL, name, 0);
+  s = mh_expand_name (NULL, name, NAME_ANY);
   if (access (s, R_OK) == 0)
     {
       *resolved_name = s;
@@ -554,7 +566,8 @@ mh_find_file (const char *name, char **resolved_name)
 		    _("cannot access %s: %s"), s, mu_strerror (errno));
   free (s);
 
-  s = mh_expand_name (mh_global_profile_get ("mhetcdir", MHLIBDIR), name, 0);
+  s = mh_expand_name (mh_global_profile_get ("mhetcdir", MHLIBDIR), name,
+                      NAME_ANY);
   if (access (s, R_OK) == 0)
     {
       *resolved_name = s;
@@ -690,7 +703,7 @@ mh_file_to_message (const char *folder, const char *file_name)
   
   if (folder)
     {
-      tmp_name = mh_expand_name (folder, file_name, 0);
+      tmp_name = mh_expand_name (folder, file_name, NAME_ANY);
       msg = _file_to_message (tmp_name);
       free (tmp_name);
     }
@@ -853,14 +866,6 @@ mh_annotate (mu_message_t msg, const char *field, const char *text, int date)
 }
 
 char *
-mh_draft_name ()
-{
-  return mh_expand_name (mh_global_profile_get ("Draft-Folder",
-						mu_folder_directory ()),
-			 "draft", 0);
-}
-
-char *
 mh_create_message_id (int subpart)
 {
   char *p;
diff --git a/mh/mh_sequence.c b/mh/mh_sequence.c
index 171b1e8..41dd075 100644
--- a/mh/mh_sequence.c
+++ b/mh/mh_sequence.c
@@ -22,7 +22,7 @@ static char *
 private_sequence_name (const char *name)
 {
   char *p;
-  char *mbox_dir = mh_expand_name (NULL, mh_current_folder (), 0);
+  char *mbox_dir = mh_expand_name (NULL, mh_current_folder (), NAME_ANY);
   mu_asprintf (&p, "atr-%s-%s", name, mbox_dir);
   free (mbox_dir);
   return p;
diff --git a/mh/mhn.c b/mh/mhn.c
index 6baa579..a95f3d8 100644
--- a/mh/mhn.c
+++ b/mh/mhn.c
@@ -2978,7 +2978,7 @@ main (int argc, char **argv)
 	  return 1;
 	}
       input_file = mh_expand_name (mu_folder_directory (),
-				   argc == 1 ? argv[0] : "draft", 0);
+				   argc == 1 ? argv[0] : "draft", NAME_ANY);
       message = mh_file_to_message (NULL, input_file);
       if (!message)
 	return 1;
diff --git a/mh/repl.c b/mh/repl.c
index 8500966..0012895 100644
--- a/mh/repl.c
+++ b/mh/repl.c
@@ -418,14 +418,14 @@ main (int argc, char **argv)
     }
   
   if (build_only)
-    wh_env.file = mh_expand_name (draftfolder, "reply", 0);
+    wh_env.file = mh_expand_name (draftfolder, "reply", NAME_ANY);
   else if (draftfolder)
     {
       if (mh_draft_message (draftfolder, draftmessage, &wh_env.file))
 	return 1;
     }
   else
-    wh_env.file = mh_expand_name (draftfolder, "draft", 0);
+    wh_env.file = mh_expand_name (draftfolder, "draft", NAME_ANY);
   wh_env.draftfile = wh_env.file;
 
   make_draft (mbox, DISP_REPLACE, &wh_env);
diff --git a/mh/rmf.c b/mh/rmf.c
index 5b733b4..d14a9cd 100644
--- a/mh/rmf.c
+++ b/mh/rmf.c
@@ -196,7 +196,7 @@ main (int argc, char **argv)
       name = cur_folder_path;
     }
   else
-    name = mh_expand_name (NULL, folder_name, 0);
+    name = mh_expand_name (NULL, folder_name, NAME_ANY);
   if (recursive)
     status = recrmf (name);
   else
diff --git a/mh/send.c b/mh/send.c
index 4f15d4c..99fa0eb 100644
--- a/mh/send.c
+++ b/mh/send.c
@@ -325,7 +325,7 @@ elt_fixup (void *item, void *data)
 {
   struct list_elt *elt = item;
   
-  elt->file_name = mh_expand_name (draftfolder, elt->file_name, 0);
+  elt->file_name = mh_expand_name (draftfolder, elt->file_name, NAME_ANY);
   if (checkdraft (elt->file_name))
     exit (1);
   elt->msg = mh_file_to_message (NULL, elt->file_name);
@@ -357,7 +357,7 @@ read_mts_profile ()
     {
       mu_property_t local_profile;
 
-      name = mh_expand_name (MHLIBDIR, "mtstailor", 0);
+      name = mh_expand_name (MHLIBDIR, "mtstailor", NAME_ANY);
       mts_profile = mh_read_property_file (name, 1);
 
       name = mu_tilde_expansion ("~/.mtstailor", MU_HIERARCHY_DELIMITER, NULL);
@@ -886,7 +886,8 @@ main (int argc, char **argv)
 	    addfolder (dfolder, 0, NULL);
 	  else
 	    {
-	      char *df = mh_expand_name (mu_folder_directory (), "draft", 0);
+	      char *df = mh_expand_name (mu_folder_directory (), "draft", 
+	                                 NAME_ANY);
 	      if (checkdraft (df))
 		exit (1);
 	      if (!use_draft && !mh_usedraft (df))
@@ -906,7 +907,7 @@ main (int argc, char **argv)
     {
       /* -draftfolder is supplied */
       draftfolder = mh_expand_name (mu_folder_directory (),
-				    draftfolder, 0);
+				    draftfolder, NAME_ANY);
       use_draft = 1;
       mesg_list_fixup ();
       if (mu_list_is_empty (mesg_list) || argc != 0)
diff --git a/mh/show.c b/mh/show.c
new file mode 100644
index 0000000..13fce75
--- /dev/null
+++ b/mh/show.c
@@ -0,0 +1,363 @@
+/* GNU Mailutils -- a suite of utilities for electronic mail
+   Copyright (C) 2002, 2005, 2007-2012 Free Software Foundation, Inc.
+
+   GNU Mailutils is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
+
+   GNU Mailutils is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. */
+
+/* MH show command */
+
+#include <mh.h>
+
+static char doc[] = N_("GNU MH show")"\v"
+N_("Use -help to obtain the list of traditional MH options.");
+static char args_doc[] = N_("[+FOLDER] [MSGLIST]");
+
+#define ARG_PASS ARG_MAX
+
+static struct argp_option options[] = {
+  {"draft",         ARG_DRAFT,          NULL, 0,
+   N_("show the draft file") },
+  {"file",          ARG_FILE,     N_("FILE"), 0,
+   N_("show this file") },
+  {"header",        ARG_HEADER,   N_("BOOL"), OPTION_ARG_OPTIONAL,
+   N_("display a description of the message before the message itself") },
+  {"noheader",      ARG_HEADER,   NULL, OPTION_HIDDEN, "" },
+  {"showproc",      ARG_SHOWPROC, N_("PROGRAM"), 0,
+   N_("use PROGRAM to show messages")},
+  {"noshowproc",    ARG_NOSHOWPROC, NULL, 0,
+   N_("disable the use of the \"showproc:\" profile component") },
+
+  {"form",          ARG_FORM,     N_("FILE"),   0,
+   N_("read format from given file")},
+  {"moreproc",      ARG_MOREPROC, N_("PROG"),   0,
+   N_("use this PROG as pager"), },
+  {"nomoreproc",    ARG_NOMOREPROC,     NULL,         0,
+   N_("disable the use of moreproc") },
+  {"length",        ARG_LENGTH,   N_("NUMBER"), 0,
+   N_("set output screen length")},
+  {"width",         ARG_WIDTH,    N_("NUMBER"), 0,
+   N_("set output width")},
+  
+  {NULL}
+};
+
+/* Traditional MH options */
+struct mh_option mh_option[] = {
+  { "draft" },
+  { "file", MH_OPT_ARG, "file" },
+  { "header", MH_OPT_BOOL },
+  { "showproc", MH_OPT_ARG, "program" },
+  { "noshowproc" },
+  { "form",       MH_OPT_ARG, "formatfile"},
+  { "width",      MH_OPT_ARG, "number"},
+  { "length",     MH_OPT_ARG, "number"},
+  { "moreproc",   MH_OPT_ARG, "program"},
+  { "nomoreproc" },
+  
+  { NULL }
+};
+
+int use_draft;
+int use_showproc = 1;
+int header_option = 1;
+char *file;
+
+const char *showproc;
+char **showargv;
+size_t showargc;
+size_t showargmax;
+
+const char *mhnproc;
+
+static void
+addarg (const char *arg)
+{
+  if (showargc == showargmax)
+    showargv = mu_2nrealloc (showargv, &showargmax, sizeof showargv[0]);
+  showargv[showargc++] = (char*) arg;
+}
+
+static void
+insarg (char *arg)
+{
+  addarg (arg);
+  if (showargc > 2)
+    {
+      char *p = showargv[showargc-1];
+      memmove (showargv + 2, showargv + 1,
+	       sizeof (showargv[0]) * (showargc - 2));
+      showargv[1] = p;
+    }
+}
+
+static const char *
+findopt (int key)
+{
+  struct argp_option *p;
+
+  for (p = options; p->name; p++)
+    if (p->key == key)
+      return p->name;
+  abort ();
+}
+
+static error_t
+opt_handler (int key, char *arg, struct argp_state *state)
+{
+  switch (key)
+    {
+    case ARG_FOLDER: 
+      mh_set_current_folder (arg);
+      break;
+
+    case ARG_DRAFT:
+      if (use_draft || file)
+	argp_error (state, _("only one file at a time!"));
+      use_draft = 1;
+      break;
+
+    case ARG_FILE:
+      if (use_draft || file)
+	argp_error (state, _("only one file at a time!"));
+      file = mh_expand_name (NULL, arg, NAME_FILE);
+      break;
+      
+    case ARG_HEADER:
+      header_option = is_true (arg);
+      break;
+
+    case ARG_NOHEADER:
+      header_option = 0;
+      break;
+
+    case ARG_SHOWPROC:
+      showproc = arg;
+      break;
+
+    case ARG_NOSHOWPROC:
+      use_showproc = 0;
+      break;
+      
+    case ARG_NOMOREPROC:
+    case ARG_FORM:
+    case ARG_MOREPROC:
+    case ARG_LENGTH:
+    case ARG_WIDTH:
+      addarg (findopt (key));
+      if (arg)
+	addarg (arg);
+      break;
+
+    default:
+      return ARGP_ERR_UNKNOWN;
+    }
+  return 0;
+}
+
+static int
+resolve_mime (size_t num, mu_message_t msg, void *data)
+{
+  int *ismime = data;
+  
+  mu_message_is_multipart (msg, ismime);
+  return *ismime;
+}
+
+static int
+resolve_msg (size_t num, mu_message_t msg, void *data)
+{
+  char *path = data;
+  
+  mh_message_number (msg, &num);
+  addarg (mh_safe_make_file_name (path, mu_umaxtostr (0, num)));
+
+  return 0;
+}
+
+static int
+adduid (size_t num, void *data)
+{
+  addarg (mu_umaxtostr (0, num));
+  return 0;
+}
+
+static int
+printheader (size_t num, void *data)
+{
+  mu_printf ("(Message %s:%lu)\n", (char*) data, (unsigned long)num);
+  return 1;
+}
+
+static void
+checkfile (char *file)
+{
+  int ismime = 0;
+
+  if (!showproc)
+    {
+      mu_message_t msg = mh_file_to_message (NULL, file);
+      mu_message_is_multipart (msg, &ismime);
+      mu_message_unref (msg);
+    }
+  if (ismime)
+    {
+      showproc = mhnproc;
+      insarg ("-show");
+      addarg ("-file");
+    }	      
+  addarg (file);
+}  
+
+int
+main (int argc, char **argv)
+{
+  int index = 0;
+  mu_mailbox_t mbox;
+  mu_msgset_t msgset;
+  const char *p;
+  
+  /* Native Language Support */
+  MU_APP_INIT_NLS ();
+
+  showargmax = 2;
+  showargc = 1;
+  showargv = mu_calloc (showargmax, sizeof showargv[0]);
+  
+  mh_argp_init ();
+  mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc,
+		 opt_handler, NULL, &index);
+  mbox = mh_open_folder (mh_current_folder (), MU_STREAM_RDWR);
+
+  argc -= index;
+  argv += index;
+  
+  if (use_draft || file)
+    {
+      if (argc)
+	{
+	  mu_error (_("only one file at a time!"));
+	  exit (1);
+	}
+    }
+  else
+    mh_msgset_parse (&msgset, mbox, argc, argv, "cur");
+
+  /* 1. If !use_showproc set showproc to /bin/cat and go to X.
+     2. If -file or -draft is given
+     2.a.  If showproc is set, go to 2.c
+     2.b.  If the file is a multipart one, set showproc to mhn with -file
+           and -show options and go to X
+     2.c.  Add file to the argument list and go to X.
+     3. Scan all messages to see if there are MIME ones. If so, set
+        showproc to mhn with the -show option, transfer message UIDs
+	to showproc arguments, and go to X
+     4. Otherwise set showproc from the showproc variable in .mh_profile
+     X. If showproc is not set, set it to PAGER ("/usr/bin/more" by default).
+     Y. Execute showproc with the collected argument list.
+  */
+
+  if (!use_showproc)
+    showproc = "/bin/cat";
+  else
+    showproc = mh_global_profile_get ("showproc", NULL);
+
+  mhnproc = mh_global_profile_get ("mhnproc", "mhn");
+  
+  if (use_draft || file)
+    {
+      if (file)
+	checkfile (file);
+      else
+	{
+	  const char *dfolder = mh_global_profile_get ("Draft-Folder", NULL);
+
+	  if (dfolder)
+	    {
+	      int ismime = 0;
+	      
+	      mu_mailbox_close (mbox);
+	      mu_mailbox_destroy (&mbox);
+	      mbox = mh_open_folder (dfolder, MU_STREAM_RDWR);
+	      mh_msgset_parse (&msgset, mbox, 0, NULL, "cur");
+
+	      mu_msgset_foreach_message (msgset, resolve_mime, &ismime);
+	      if (ismime)
+		{
+		  showproc = mhnproc;
+		  insarg ("-show");
+		  addarg ("-file");
+		}	      
+	      mu_msgset_foreach_message (msgset, resolve_msg,
+					 (void *) dfolder);
+	    }
+	  else
+	    checkfile (mh_expand_name (mu_folder_directory (),
+				       "draft", NAME_ANY));
+	}
+    }
+  else
+    {
+      mu_url_t url;
+      size_t n;
+      int ismime = 0;
+      const char *path;
+      
+      mu_mailbox_get_url (mbox, &url);
+      mu_url_sget_path (url, &path);
+
+      if (!showproc)
+	{
+	  mu_msgset_foreach_message (msgset, resolve_mime, &ismime);
+	  if (ismime)
+	    {
+	      showproc = mhnproc;
+	      insarg ("-show");
+	    }
+	}
+      
+      if (ismime)
+	mu_msgset_foreach_msguid (msgset, adduid, NULL);
+      else
+	mu_msgset_foreach_message (msgset, resolve_msg, (void*) path);
+
+      p = mh_global_profile_get ("Unseen-Sequence", NULL);
+      if (p)
+	{
+	  mh_seq_delete (mbox, p, msgset, 0);
+	  mh_global_save_state ();
+	}
+      
+      if (header_option && mu_msgset_count (msgset, &n) == 0 && n == 1)
+	mu_msgset_foreach_msguid (msgset, printheader, (void*) path);
+    }
+
+  mu_stream_flush (mu_strout);
+  mu_mailbox_close (mbox);
+  mu_mailbox_destroy (&mbox);
+  
+  if (!showproc)
+    {
+      showproc = getenv ("PAGER");
+      if (!showproc)
+	showproc = "/usr/bin/more";
+    }
+
+  addarg (NULL);
+  p = strrchr (showproc, '/');
+  showargv[0] = (char*) (p ? p + 1 : showproc);
+  execvp (showproc, showargv);
+  mu_error (_("unable to exec %s: %s"), showargv[0], mu_strerror (errno));
+  return 1;
+}
+  
+  
diff --git a/mh/whatnow.c b/mh/whatnow.c
index f050c60..a4e304a 100644
--- a/mh/whatnow.c
+++ b/mh/whatnow.c
@@ -108,7 +108,7 @@ main (int argc, char **argv)
 	return 1;
     }
   else
-    wh_env.draftfile = mh_expand_name (draftfolder, "draft", 0);
+    wh_env.draftfile = mh_expand_name (draftfolder, "draft", NAME_ANY);
   wh_env.draftfile = wh_env.file;
 
   return mh_whatnow (&wh_env, initial_edit);
diff --git a/mh/whom.c b/mh/whom.c
index e4422c9..5e3ac2b 100644
--- a/mh/whom.c
+++ b/mh/whom.c
@@ -118,6 +118,6 @@ main (int argc, char **argv)
 					  mu_folder_directory ());
 
   
-  return mh_whom (mh_expand_name (draft_folder, name, 0), check_recipients) ?
-          1 : 0;
+  return mh_whom (mh_expand_name (draft_folder, name, NAME_ANY), 
+                  check_recipients) ? 1 : 0;
 }


hooks/post-receive
-- 
GNU Mailutils


