<<< Date Index >>>     <<< Thread Index >>>

Re: optional sleep before marking a message as "read" ?



Hi David,

On Thu, May 06, 2004 at 07:37:41PM -0400, David T-G wrote:
> % Nevertheless, few days ago I sent a patch for my idea to
> % mutt-dev@xxxxxxxx (and using this patched Mutt made my life easier).
> 
> Now *this* is the best contribution anyone could make :-)  Thanks!
> 
> Do you have a web site where you can post it?

Yes, but I unfortunately don't have enough time to post it there
before a few days :(. I copy-paste it at the end of this email so
(it's very small).

> Can you maintain it?

Yes; it's a very simple patch (let's hope it's not very wrong as
well).


diff -ru mutt-1.5.6.old/globals.h mutt-1.5.6/globals.h
--- mutt-1.5.6.old/globals.h    2004-02-01 18:15:17.000000000 +0100
+++ mutt-1.5.6/globals.h        2004-04-30 14:30:38.000000000 +0200
@@ -150,6 +150,7 @@
 WHERE short SendmailWait;
 WHERE short SleepTime INITVAL (1);
 WHERE short Timeout;
+WHERE short TimeBeforeRead;
 WHERE short WrapMargin;
 WHERE short WriteInc;

diff -ru mutt-1.5.6.old/init.h mutt-1.5.6/init.h
--- mutt-1.5.6.old/init.h       2004-02-01 18:15:17.000000000 +0100
+++ mutt-1.5.6/init.h   2004-05-01 14:49:47.000000000 +0200
@@ -2523,6 +2523,12 @@
   ** When set, the internal-pager will pad blank lines to the bottom of the
   ** screen with a tilde (~).
   */
+  { "time_before_read",        DT_NUM,  R_NONE, UL &TimeBeforeRead, 0 },
+  /*
+  ** .pp
+  ** When a new message is displayed in the pager, Mutt will mark it "read"
+  ** (i.e. "not new") after it is \fItime_before_read\fP seconds in the pager.
+  */
   { "timeout",         DT_NUM,  R_NONE, UL &Timeout, 600 },
   /*
   ** .pp
diff -ru mutt-1.5.6.old/pager.c mutt-1.5.6/pager.c
--- mutt-1.5.6.old/pager.c      2004-02-01 18:10:57.000000000 +0100
+++ mutt-1.5.6/pager.c  2004-04-30 14:38:06.000000000 +0200
@@ -1495,6 +1495,7 @@
   int indicator = indexlen / 3;        /* the indicator line of the PI */
   int old_PagerIndexLines;             /* some people want to resize it
                                         * while inside the pager... */
+  time_t read_start_time = 0;           /* moment user started reading msg */

   if (!(flags & M_SHOWCOLOR))
     flags |= M_SHOWFLAT;
@@ -1518,7 +1519,7 @@
   if (IsHeader (extra) && !extra->hdr->read)
   {
     Context->msgnotreadyet = extra->hdr->msgno;
-    mutt_set_flag (Context, extra->hdr, M_READ, 1);
+    read_start_time = time (NULL);
   }

   lineInfo = safe_malloc (sizeof (struct line_t) * (maxLine = LINES));
@@ -2613,6 +2614,13 @@
     }
   }

+  if (read_start_time)
+  {
+    if (!TimeBeforeRead ||
+        ( (time (NULL) - read_start_time ) >= TimeBeforeRead ) )
+      mutt_set_flag (Context, extra->hdr, M_READ, 1);
+  }
+
   fclose (fp);
   if (IsHeader (extra))
     Context->msgnotreadyet = -1;


Thank you.

Guilhem