From 1c904be64dbb53fc5558bed2f942b795de2fc2a2 Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Sat, 4 Jun 2016 11:32:12 -0700 Subject: [PATCH] Start to fix sidebar buffy modifications. The extended buffy for mh had incorrect placement of the loop brackets. The counters weren't being incremented in the loop. Fix extended buffy for maildir to count a maildir message as new if it doesn't have the info delimeter. Remove shortcircuits added to the basic buffy stating there is new mail when (msg_unread > 0). This is not necessarily true, depending on $mail_check_recent. Note: the extended buffy still needs more fixes, which will be done when it is refactored into its own option. --- buffy.c | 13 ++----------- mh.c | 47 +++++++++++++++++++++++------------------------ 2 files changed, 25 insertions(+), 35 deletions(-) diff --git a/buffy.c b/buffy.c index babc824f..21917740 100644 --- a/buffy.c +++ b/buffy.c @@ -336,13 +336,6 @@ static int buffy_maildir_dir_hasnew(BUFFY* mailbox, const char *dir_name) return 0; } -#ifdef USE_SIDEBAR - if (option (OPTSIDEBAR) && mailbox->msg_unread > 0) { - mailbox->new = 1; - return 1; - } -#endif - if ((dirp = opendir (path)) == NULL) { mailbox->magic = 0; @@ -441,6 +434,8 @@ buffy_maildir_update_dir (BUFFY *mailbox, const char *dir) if (strchr (p, 'F')) mailbox->msg_flagged++; } + else + mailbox->msg_unread++; } closedir (dirp); @@ -485,11 +480,7 @@ static int buffy_mbox_hasnew (BUFFY* mailbox, struct stat *sb) else statcheck = sb->st_mtime > sb->st_atime || (mailbox->newly_created && sb->st_ctime == sb->st_mtime && sb->st_ctime == sb->st_atime); -#ifdef USE_SIDEBAR - if ((!option (OPTSIDEBAR) && statcheck) || (option (OPTSIDEBAR) && mailbox->msg_unread > 0)) -#else if (statcheck) -#endif { if (!option(OPTMAILCHECKRECENT) || sb->st_mtime > mailbox->last_visited) { diff --git a/mh.c b/mh.c index 23b7502a..7b04305a 100644 --- a/mh.c +++ b/mh.c @@ -309,36 +309,35 @@ void mh_buffy(BUFFY *b) void mh_buffy_update (BUFFY *mailbox) { - if (!mailbox) - return; + int i; + struct mh_sequences mhs; - if (!option (OPTSIDEBAR)) - return; + if (!mailbox) + return; - struct mh_sequences mhs; - memset (&mhs, 0, sizeof (mhs)); + if (!option (OPTSIDEBAR)) + return; - if (mh_read_sequences (&mhs, mailbox->path) < 0) - return; + memset (&mhs, 0, sizeof (mhs)); - mailbox->msg_count = 0; - mailbox->msg_unread = 0; - mailbox->msg_flagged = 0; + if (mh_read_sequences (&mhs, mailbox->path) < 0) + return; - int i; - for (i = 0; i <= mhs.max; i++) { - mailbox->msg_count++; - } - if (mhs_check (&mhs, i) & MH_SEQ_UNSEEN) { - mailbox->msg_unread++; - } - if (mhs_check (&mhs, i) & MH_SEQ_FLAGGED) { - mailbox->msg_flagged++; - } - mhs_free_sequences (&mhs); - mailbox->sb_last_checked = time (NULL); -} + mailbox->msg_count = 0; + mailbox->msg_unread = 0; + mailbox->msg_flagged = 0; + for (i = 0; i <= mhs.max; i++) + { + mailbox->msg_count++; + if (mhs_check (&mhs, i) & MH_SEQ_UNSEEN) + mailbox->msg_unread++; + if (mhs_check (&mhs, i) & MH_SEQ_FLAGGED) + mailbox->msg_flagged++; + } + mhs_free_sequences (&mhs); + mailbox->sb_last_checked = time (NULL); +} #endif static int mh_mkstemp (CONTEXT * dest, FILE ** fp, char **tgt) -- 2.40.0