From: Rene Kita <g...@rkta.de>

-nonotify allows to disable notifications for mailboxes.

-notify can be used to re-enable notifications for a previously disabled
mailbox.

A typical use case are mailboxes for mailing lists. The User may want to
get notified about new mail in their work mailbox, but not get disrupted
by new mail received from the mailing list.

This patch allows individual configuration for all mailboxes.
---

There is still a problem with muttrc(5). The line describing the
mailboxes command goes way beyond 80 chars now. Unfortunately I was not
able to get it working to split this line and keep correct indenting.

Maybe someone here is able to help.


 buffy.c             | 16 +++++++++++++---
 buffy.h             |  3 ++-
 doc/manual.xml.head | 16 ++++++++++++++++
 doc/muttrc.man.head |  2 +-
 imap/command.c      |  2 +-
 imap/imap.c         |  2 +-
 6 files changed, 34 insertions(+), 7 deletions(-)

diff --git a/buffy.c b/buffy.c
index cfb163bf..f86443f4 100644
--- a/buffy.c
+++ b/buffy.c
@@ -272,8 +272,9 @@ static BUFFY **find_buffy_slot (const char *path)
 /* To avoid overwriting existing values:
  * - label should be NULL if unspecified
  * - nopoll should be -1 if unspecified
+ * - nonotify should be -1 if unspecified
  */
-void mutt_buffy_add (const char *path, const char *label, int nopoll)
+void mutt_buffy_add (const char *path, const char *label, int nopoll, int 
nonotify)
 {
   BUFFY **tmp;
   struct stat sb;
@@ -314,6 +315,9 @@ void mutt_buffy_add (const char *path, const char *label, 
int nopoll)
 #endif
   }
 
+  if (nonotify != -1)
+      (*tmp)->nonotify = nonotify;
+
   (*tmp)->new = 0;
   (*tmp)->notified = 1;
   (*tmp)->newly_created = 0;
@@ -371,7 +375,7 @@ int mutt_parse_mailboxes (BUFFER *path, BUFFER *s, union 
pointer_long_t udata,
 {
   BUFFER *label = NULL;
   BUFFER *mailbox = NULL;
-  int nopoll = -1, rc = -1;
+  int nonotify = -1, nopoll = -1, rc = -1;
   int label_set = 0, mailbox_set = 0;
 
   mailbox = mutt_buffer_pool_get ();
@@ -387,6 +391,10 @@ int mutt_parse_mailboxes (BUFFER *path, BUFFER *s, union 
pointer_long_t udata,
         nopoll = 0;
       else if (mutt_strcmp (mutt_b2s (path), "-nopoll") == 0)
         nopoll = 1;
+      else if (mutt_strcmp (mutt_b2s (path), "-notify") == 0)
+        nonotify = 0;
+      else if (mutt_strcmp (mutt_b2s (path), "-nonotify") == 0)
+        nonotify = 1;
       else if (mutt_strcmp (mutt_b2s (path), "-label") == 0)
       {
         if (!MoreArgs (s))
@@ -421,7 +429,7 @@ int mutt_parse_mailboxes (BUFFER *path, BUFFER *s, union 
pointer_long_t udata,
     }
     else
       mutt_buffy_add (mutt_b2s (mailbox), label_set ? mutt_b2s (label) : NULL,
-                      nopoll);
+                      nopoll, nonotify);
 
     mutt_buffer_clear (mailbox);
     mutt_buffer_clear (label);
@@ -766,6 +774,8 @@ int mutt_buffy_check (int force)
 
     if (!tmp->new)
       tmp->notified = 0;
+    if (tmp->nonotify)
+      tmp->notified = 1;
     else if (!tmp->notified)
       BuffyNotify++;
   }
diff --git a/buffy.h b/buffy.h
index a40f5772..6b05052f 100644
--- a/buffy.h
+++ b/buffy.h
@@ -35,6 +35,7 @@ typedef struct buffy_t
   int msg_unread;              /* number of unread messages */
   int msg_flagged;             /* number of flagged messages */
 
+  short nonotify;               /* if set, don't notify for new mail */
   short nopoll;                 /* if set, don't poll for new mail */
   short notified;              /* user has been notified */
   short magic;                 /* mailbox type */
@@ -50,7 +51,7 @@ WHERE short BuffyCheckStatsInterval INITVAL (60);
 
 extern time_t BuffyDoneTime;   /* last time we knew for sure how much mail 
there was */
 
-void mutt_buffy_add (const char *path, const char *label, int nopoll);
+void mutt_buffy_add (const char *path, const char *label, int nopoll, int 
nonotify);
 void mutt_buffy_remove (const char *path);
 
 void mutt_buffer_buffy (BUFFER *);
diff --git a/doc/manual.xml.head b/doc/manual.xml.head
index 7433423d..99e0aecc 100644
--- a/doc/manual.xml.head
+++ b/doc/manual.xml.head
@@ -3803,6 +3803,14 @@ to save read mail in more than a single mailbox).
 <cmdsynopsis>
 <command>mailboxes</command>
 <arg choice="opt">
+  <group choice="opt">
+    <arg choice="plain">
+      <option>-notify</option>
+    </arg>
+    <arg choice="plain">
+      <option>-nonotify</option>
+    </arg>
+  </group>
   <group choice="opt">
     <arg choice="plain">
       <option>-poll</option>
@@ -3842,6 +3850,14 @@ This command specifies folders which can receive mail 
and which will be
 checked for new messages periodically.
 </para>
 
+<para>
+Use <literal>-nonotify</literal> to disable notifying when new mail
+arrives.  The <literal>-notify</literal> argument can be used to reenable
+notifying for an existing mailbox.  If unspecified: a new
+mailbox will notify by default, while an existing mailbox will be
+unchanged.
+</para>
+
 <para>
 To disable polling, specify <literal>-nopoll</literal> before the
 mailbox name.  The <literal>-poll</literal> argument can be used to
diff --git a/doc/muttrc.man.head b/doc/muttrc.man.head
index 589a2463..e7d0f0a2 100644
--- a/doc/muttrc.man.head
+++ b/doc/muttrc.man.head
@@ -360,7 +360,7 @@ The first matching \fBmbox-hook\fP applies.
 .
 .PP
 .nf
-\fBmailboxes\fP [[\fB-poll\fP | \fB-nopoll\fP] [[\fB-label\fP \fIlabel\fP] | 
\fB-nolabel\fP] \fIfilename\fP] [ ... ]
+\fBmailboxes\fP [[\fB-notify\fP | \fB-nonotify\fP] [\fB-poll\fP | 
\fB-nopoll\fP] [[\fB-label\fP \fIlabel\fP] | \fB-nolabel\fP] \fIfilename\fP] [ 
... ]
 \fBunmailboxes\fP [ \fB*\fP | \fIfilename\fP ... ]
 .fi
 .IP
diff --git a/imap/command.c b/imap/command.c
index 5ff45499..d9450852 100644
--- a/imap/command.c
+++ b/imap/command.c
@@ -1037,7 +1037,7 @@ static void cmd_parse_lsub (IMAP_DATA* idata, char* s)
   mailbox = mutt_buffer_pool_get ();
   url_ciss_tobuffer (&url, mailbox, 0);
 
-  mutt_buffy_add (mutt_b2s (mailbox), NULL, -1);
+  mutt_buffy_add (mutt_b2s (mailbox), NULL, -1, -1);
   mutt_buffer_pool_release (&mailbox);
 }
 
diff --git a/imap/imap.c b/imap/imap.c
index ba018205..2376abb7 100644
--- a/imap/imap.c
+++ b/imap/imap.c
@@ -2282,7 +2282,7 @@ int imap_subscribe (char *path, int subscribe)
   if (option (OPTIMAPCHECKSUBSCRIBED))
   {
     if (subscribe)
-      mutt_buffy_add (path, NULL, -1);
+      mutt_buffy_add (path, NULL, -1, -1);
     else
       mutt_buffy_remove (path);
   }
-- 
2.25.1

Reply via email to