I've found the following bugs in how mail(x) accounts for the status of
messages:

1.  The "preserve" command should do more than just undo the "mbox" command.
    In fact, it needs its own status bit, since there are three possible
    states associated with the preserve and mbox commands:  preserved,
    mboxed, or neither (in the latter case, whether a message in the inbox
    is moved to the mbox depends on whether the message was read in the
    present invocation of mail).

2.  Assuming there are no preserve, mbox, save, etc. commands, a message
    in the inbox should only be moved to the mbox if it was read during
    *this* invocation of mail.

3.  The POSIX description of the "touch" command makes no mention of moving
    a message to the "read" state, so the touch command needs its own
    status bit.

4.  In all other versions of mailx that I've used, old messages that had been
    read already are indicated in from/header lines with ' ' as the status,
    not 'R'.  I find this more useful, since there are tons of such messages
    in my inbox and this allows all other messages to stand out more.

5.  The "undelete" command should unset a message's "preserved" and "mboxed"
    status bits, since it is supposed to leave a message in the state "read".

6.  If the current mailbox is not the system mailbox, then the "quit" command
    should not delete saved messages.

(In each case the bug is that mailx does not act as it should.)

I have attached a patch, and hope that you will consider including it in
the next release of the Gnu mailtools.

--Paul Vojta, [email protected]
diff -ur mail.prev/from.c mailutils/mail/from.c
--- mail.prev/from.c    2009-02-21 12:03:19.000000000 -0800
+++ mailutils/mail/from.c       2009-03-07 12:30:53.000000000 -0800
@@ -88,16 +88,18 @@
   
   if (mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_MBOXED))
     cflag = 'M';
+  else if (mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_PRESERVED))
+    cflag = 'P';
   else if (mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_SAVED))
     cflag = '*';
   else if (mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_TAGGED))
     cflag = 'T';
-  else if (mu_attribute_is_read (attr))
+  else if (mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_SHOWN))
     cflag = 'R';
-  else if (mu_attribute_is_seen (attr))
-    cflag = 'U';
   else if (mu_attribute_is_recent (attr))
     cflag = 'N';
+  else if (!mu_attribute_is_read (attr))
+    cflag = 'U';
   else
     cflag = ' ';
 
diff -ur mail.prev/hold.c mailutils/mail/hold.c
--- mail.prev/hold.c    2009-02-21 12:03:19.000000000 -0800
+++ mailutils/mail/hold.c       2009-03-07 12:21:06.000000000 -0800
@@ -30,6 +30,7 @@
 
   mu_message_get_attribute (msg, &attr);
   mu_attribute_unset_userflag (attr, MAIL_ATTRIBUTE_MBOXED);
+  mu_attribute_set_userflag (attr, MAIL_ATTRIBUTE_PRESERVED);
 
   set_cursor (mspec->msg_part[0]);
   
diff -ur mail.prev/mail.h mailutils/mail/mail.h
--- mail.prev/mail.h    2009-02-21 12:03:19.000000000 -0800
+++ mailutils/mail/mail.h       2009-03-07 16:32:54.000000000 -0800
@@ -428,9 +428,11 @@
 
 /* Message attributes */
 #define MAIL_ATTRIBUTE_MBOXED   0x0001
-#define MAIL_ATTRIBUTE_SAVED    0x0002
-#define MAIL_ATTRIBUTE_TAGGED   0x0004
-#define MAIL_ATTRIBUTE_SHOWN    0x0008
+#define MAIL_ATTRIBUTE_PRESERVED 0x0002
+#define MAIL_ATTRIBUTE_SAVED    0x0004
+#define MAIL_ATTRIBUTE_TAGGED   0x0008
+#define MAIL_ATTRIBUTE_SHOWN    0x0010
+#define MAIL_ATTRIBUTE_TOUCHED  0x0020
 
 #ifdef WITH_READLINE
 extern char **file_compl (int argc, char **argv, int ws);
diff -ur mail.prev/mbox.c mailutils/mail/mbox.c
--- mail.prev/mbox.c    2009-02-21 12:03:19.000000000 -0800
+++ mailutils/mail/mbox.c       2009-03-07 12:21:33.000000000 -0800
@@ -28,8 +28,8 @@
   mu_attribute_t attr;
 
   mu_message_get_attribute (msg, &attr);
+  mu_attribute_unset_userflag (attr, MAIL_ATTRIBUTE_PRESERVED);
   mu_attribute_set_userflag (attr, MAIL_ATTRIBUTE_MBOXED);
-  util_mark_read (msg);
   
   set_cursor (mspec->msg_part[0]);
   
diff -ur mail.prev/quit.c mailutils/mail/quit.c
--- mail.prev/quit.c    2009-02-21 12:03:19.000000000 -0800
+++ mailutils/mail/quit.c       2009-03-14 22:46:24.000000000 -0700
@@ -87,6 +87,7 @@
        /* The mailbox we are closing is not a system one (%). Raise
           hold flag */
        hold = 1;
+       keepsave = 1;   /* only the second occurrence of this matters now */
       }
     mu_mailbox_destroy (&mb);
   }
@@ -102,7 +103,12 @@
          && (mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_MBOXED)
              || (!hold
                  && !mu_attribute_is_deleted (attr)
-                 && mu_attribute_is_read (attr))))
+                 && !mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_PRESERVED)
+                 && ((mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_SAVED)
+                      && keepsave)
+                     || (!mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_SAVED)
+                         && (mu_attribute_is_userflag (attr, 
MAIL_ATTRIBUTE_SHOWN)
+                             || mu_attribute_is_userflag (attr, 
MAIL_ATTRIBUTE_TOUCHED)))))))
        {
          int status;
          
@@ -136,7 +142,9 @@
        }
       else if (mu_attribute_is_deleted (attr))
        /* Skip this one */;
-      else if (!keepsave && mu_attribute_is_userflag (attr, 
MAIL_ATTRIBUTE_SAVED))
+      else if (!keepsave
+              && !mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_PRESERVED)
+              && mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_SAVED))
        mu_attribute_set_deleted (attr);
       else if (mu_attribute_is_read (attr))
        mu_attribute_set_seen (attr);
diff -ur mail.prev/touch.c mailutils/mail/touch.c
--- mail.prev/touch.c   2009-02-21 12:03:19.000000000 -0800
+++ mailutils/mail/touch.c      2009-03-07 12:19:53.000000000 -0800
@@ -30,11 +30,7 @@
   mu_attribute_t attr = NULL;
   
   mu_message_get_attribute (msg, &attr);
-  if (!mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_SAVED))
-    {
-      mu_attribute_set_userflag (attr, MAIL_ATTRIBUTE_MBOXED);
-      util_mark_read (msg);
-    }
+  mu_attribute_set_userflag (attr, MAIL_ATTRIBUTE_TOUCHED);
   
   set_cursor (mspec->msg_part[0]);
   return 0;
diff -ur mail.prev/undelete.c mailutils/mail/undelete.c
--- mail.prev/undelete.c        2009-02-21 12:03:19.000000000 -0800
+++ mailutils/mail/undelete.c   2009-03-10 19:19:45.000000000 -0700
@@ -29,6 +29,8 @@
 
   mu_message_get_attribute (msg, &attr);
   mu_attribute_unset_deleted (attr);
+  mu_attribute_unset_userflag (attr, MAIL_ATTRIBUTE_PRESERVED);
+  mu_attribute_unset_userflag (attr, MAIL_ATTRIBUTE_MBOXED);
   util_mark_read (msg);
   cond_page_invalidate (mspec->msg_part[0]);
 
_______________________________________________
Bug-mailutils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-mailutils

Reply via email to