]> granicus.if.org Git - neomutt/commitdiff
Add a buffy-list function, and display more information when new
authorRudi Chiarito <nutello@sweetness.com>
Mon, 9 Sep 2002 21:48:19 +0000 (21:48 +0000)
committerRudi Chiarito <nutello@sweetness.com>
Mon, 9 Sep 2002 21:48:19 +0000 (21:48 +0000)
mail arrives.  With some modifications from tlr.

OPS
browser.c
buffy.c
curs_main.c
functions.h
pager.c
protos.h

diff --git a/OPS b/OPS
index a8cdba2e4923b72b3fd7f179ae93343621b81220..17d45fc055518e193ee6294859d704c446532720 100644 (file)
--- a/OPS
+++ b/OPS
@@ -10,6 +10,7 @@ OP_BROWSER_TELL "display the currently selected file's name"
 OP_BROWSER_SUBSCRIBE "subscribe to current mailbox (IMAP only)"
 OP_BROWSER_UNSUBSCRIBE "unsubscribe to current mailbox (IMAP only)"
 OP_BROWSER_TOGGLE_LSUB "toggle view all/subscribed mailboxes (IMAP only)"
+OP_BUFFY_LIST "list mailboxes with new mail"
 OP_CHANGE_DIRECTORY "change directories"
 OP_CHECK_NEW "check mailboxes for new mail"
 OP_COMPOSE_ATTACH_FILE "attach a file(s) to this message"
index 168c4d5f1d6193ee3495cde821b8e7c98863b3b6..34778ac2c38a1cbb6dc9a30d6b21d569667218e3 100644 (file)
--- a/browser.c
+++ b/browser.c
@@ -1106,6 +1106,10 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files, int *num
        init_menu (&state, menu, title, sizeof (title), buffy);
        break;
 
+      case OP_BUFFY_LIST:
+       mutt_buffy_list ();
+       break;
+
       case OP_BROWSER_NEW_FILE:
 
        snprintf (buf, sizeof (buf), "%s/", LastDir);
diff --git a/buffy.c b/buffy.c
index 660075d859f6e35287805ed9be91c8d39ad14ccb..601c338b65a2b4c20c334d9a9316e6aef359bad0 100644 (file)
--- a/buffy.c
+++ b/buffy.c
@@ -21,6 +21,8 @@
 #include "mailbox.h"
 #include "mx.h"
 
+#include "mutt_curses.h"
+
 #ifdef USE_IMAP
 #include "imap.h"
 #endif
@@ -422,29 +424,64 @@ int mutt_buffy_check (int force)
   return (BuffyCount);
 }
 
-int mutt_buffy_notify (void)
+int mutt_buffy_list (void)
 {
   BUFFY *tmp;
   char path[_POSIX_PATH_MAX];
-
-  if (mutt_buffy_check (0) && BuffyNotify)
+  char buffylist[160];
+  int pos;
+  int first;
+
+  pos = 0;
+  first = 1;
+  buffylist[0] = 0;
+  pos += strlen (strncat (buffylist, _("New mail in "), sizeof (buffylist) - 1 - pos));
+  for (tmp = Incoming; tmp; tmp = tmp->next)
   {
-    for (tmp = Incoming; tmp; tmp = tmp->next)
+    /* Is there new mail in this mailbox? */
+    if (!tmp->new)
+      continue;
+
+    strfcpy (path, tmp->path, sizeof (path));
+    mutt_pretty_mailbox (path);
+    
+    if (!first && pos + strlen (path) >= COLS - 7)
+      break;
+    
+    if (!first)
+      pos += strlen (strncat(buffylist + pos, ", ", sizeof(buffylist)-1-pos));
+    
+    /* Prepend an asterisk to mailboxes not already notified */
+    if (!tmp->notified)
     {
-      if (tmp->new && !tmp->notified)
-      {
-       strfcpy (path, tmp->path, sizeof (path));
-       mutt_pretty_mailbox (path);
-       mutt_message (_("New mail in %s."), path);
-       tmp->notified = 1;
-       BuffyNotify--;
-       return (1);
-      }
+      pos += strlen (strncat(buffylist + pos, "*", sizeof(buffylist)-1-pos));
+      tmp->notified = 1;
+      BuffyNotify--;
     }
-    /* there were no mailboxes needing to be notified, so clean up since 
-     * BuffyNotify has somehow gottten out of sync
-     */
-    BuffyNotify = 0;
+    pos += strlen (strncat(buffylist + pos, path, sizeof(buffylist)-1-pos));
+    first = 0;
+  }
+  if (!first && tmp)
+  {
+    strncat (buffylist + pos, ", ...", sizeof (buffylist) - 1 - pos);
+  }
+  if (!first)
+  {
+    mutt_message ("%s", buffylist);
+    return (1);
+  }
+  /* there were no mailboxes needing to be notified, so clean up since 
+   * BuffyNotify has somehow gotten out of sync
+   */
+  BuffyNotify = 0;
+  return (0);
+}
+
+int mutt_buffy_notify (void)
+{
+  if (mutt_buffy_check (0) && BuffyNotify)
+  {
+    return (mutt_buffy_list ());
   }
   return (0);
 }
index c08bac3db70c5dbba60f905a16bab0583a7fce72..61fd0d2f16621e13f5ce6139f8fcbf7e8f84dbf7 100644 (file)
@@ -1969,6 +1969,10 @@ int mutt_index_menu (void)
        mutt_version ();
        break;
 
+      case OP_BUFFY_LIST:
+       mutt_buffy_list ();
+       break;
+
       case OP_VIEW_ATTACHMENTS:
        CHECK_MSGCOUNT;
         CHECK_VISIBLE;
index d38ce8d81d84a7443388c2630d9a43d4c58cf431..eae16756cda8a438d751aa827d816c0b800486db 100644 (file)
@@ -125,6 +125,7 @@ struct binding_t OpMain[] = {
   { "set-flag",                        OP_MAIN_SET_FLAG,               "w" },
   { "clear-flag",              OP_MAIN_CLEAR_FLAG,             "W" },
   { "display-message",         OP_DISPLAY_MESSAGE,             M_ENTER_S },
+  { "buffy-list",              OP_BUFFY_LIST,                  "." },
   { "sync-mailbox",            OP_MAIN_SYNC_FOLDER,            "$" },
   { "display-address",         OP_DISPLAY_ADDRESS,             "@" },
   { "pipe-message",            OP_PIPE,                        "|" },
@@ -212,6 +213,7 @@ struct binding_t OpPager[] = {
   { "sync-mailbox",    OP_MAIN_SYNC_FOLDER,            "$" },
   { "shell-escape",    OP_SHELL_ESCAPE,                "!" },
   { "enter-command",   OP_ENTER_COMMAND,               ":" },
+  { "buffy-list",      OP_BUFFY_LIST,                  "." },
   { "search",          OP_SEARCH,                      "/" },
   { "search-reverse",  OP_SEARCH_REVERSE,              "\033/" },
   { "search-opposite", OP_SEARCH_OPPOSITE,             NULL },
@@ -359,6 +361,7 @@ struct binding_t OpBrowser[] = {
   { "check-new",       OP_CHECK_NEW,           NULL },
   { "toggle-mailboxes", OP_TOGGLE_MAILBOXES,   "\t" },
   { "view-file",       OP_BROWSER_VIEW_FILE,   " " },
+  { "buffy-list",      OP_BUFFY_LIST,          "." },
 #ifdef USE_IMAP
   { "create-mailbox",   OP_CREATE_MAILBOX,      "C" },
   { "delete-mailbox",   OP_DELETE_MAILBOX,      "d" },
diff --git a/pager.c b/pager.c
index d3a74cdb985490a49fcfc11dbb13ae63a41a2ed9..75f06597b1e865bbf70692d132a0b0ec3f51409a 100644 (file)
--- a/pager.c
+++ b/pager.c
@@ -2504,6 +2504,10 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra)
        mutt_version ();
        break;
 
+      case OP_BUFFY_LIST:
+       mutt_buffy_list ();
+       break;
+
       case OP_VIEW_ATTACHMENTS:
         if (flags & M_PAGER_ATTACHMENT)
         {
index 25dc18630c4dd45b93ca443c76fec4655ec51f1b..54e008bb8358852f9f5f88bfa533196a31f746ed 100644 (file)
--- a/protos.h
+++ b/protos.h
@@ -149,6 +149,7 @@ void mutt_block_signals_system (void);
 void mutt_body_handler (BODY *, STATE *);
 void mutt_bounce_message (FILE *fp, HEADER *, ADDRESS *);
 void mutt_buffy (char *, size_t);
+int  mutt_buffy_list (void);
 void mutt_canonical_charset (char *, size_t, const char *);
 void mutt_check_rescore (CONTEXT *);
 void mutt_clear_error (void);