Thursday, October 21, 2010

Mutt 1.5.21 mail_check_recent option

Updated to mutt 1.5.21 recently and one change really was annoying me so far.
Mutt doesn't mark recently visited folder with 'N' (new message) until it
receives new message... even if there are unread messages.
Quick look at mutt 1.5.21 source code gave the following result:

/* returns 1 if maildir has new mail */
static int buffy_maildir_hasnew (BUFFY* mailbox)
{
  char path[_POSIX_PATH_MAX];
  DIR *dirp;
  struct dirent *de;
  char *p;
  int rc = 0;
  struct stat sb;

  snprintf (path, sizeof (path), "%s/new", mailbox->path);

  /* when $mail_check_recent is set, if the new/ directory hasn't been modified since
   * the user last exited the mailbox, then we know there is no recent mail.
   */
  if (option(OPTMAILCHECKRECENT))
  {
    if (stat(path, &sb) == 0 && sb.st_mtime < mailbox->last_visited)
      return 0;
  }

  if ((dirp = opendir (path)) == NULL)
  {
    mailbox->magic = 0;
    return 0;
  }

  while ((de = readdir (dirp)) != NULL)
  {
    if (*de->d_name == '.')
      continue;

    if (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T'))
    {
      if (option(OPTMAILCHECKRECENT))
      {
    char msgpath[_POSIX_PATH_MAX];

    snprintf(msgpath, sizeof(msgpath), "%s/%s", path, de->d_name);
    /* ensure this message was received since leaving this mailbox */
    if (stat(msgpath, &sb) == 0 && (sb.st_ctime <= mailbox->last_visited))
      continue;
      }
      /* one new and undeleted message is enough */
      mailbox->new = 1;
      rc = 1;
      break;
    }
  }

  closedir (dirp);

  return rc;
}

Gotcha! Quick grep:
{"mail_check_recent",DT_BOOL, R_NONE, OPTMAILCHECKRECENT, 1 },
When set, Mutt will only notify you about new mail that has been received
since the last time you opened the mailbox.  When unset, Mutt will notify
you if any new mail exists in the mailbox, regardless of whether you have
visited it recently.

Corresponding lines in change log (diff 1.5.20 - 1.5.21)
2010-09-13 17:25 -0700  Michael Elkins (20b2d496349f)
* init.h: make $mail_check_recent set by default

The solution is to add
unset mail_check_recent

to .muttrc


Why...

No comments:

Post a Comment