Hi, attached is a patch that makes the buffy size option configurable at runtime. Mutt binary compiled with --enable-buffy-size will have an extra boolean variable that controls if mbox size should be used when checking for new mail.
Any chance this could be included? Thanks, -- Miroslav Lichvar
Index: buffy.c =================================================================== RCS file: /home/roessler/cvs/mutt/buffy.c,v retrieving revision 3.20 diff -u -r3.20 buffy.c --- buffy.c 19 Nov 2006 05:19:09 -0000 3.20 +++ buffy.c 28 Feb 2007 12:38:11 -0000 @@ -142,7 +142,7 @@ struct stat sb; struct stat tmp_sb; - if (stat (path,&sb) != 0) + if (!option(OPTBUFFYSIZE) || stat (path,&sb) != 0) return NULL; for (tmp = Incoming; tmp; tmp = tmp->next) @@ -237,7 +237,7 @@ * reading it), the size is set to 0 so that later when we check we see * that it increased . without buffy_size we probably don't care. */ - if (stat ((*tmp)->path, &sb) == 0 && !test_new_folder ((*tmp)->path)) + if (option(OPTBUFFYSIZE) && stat ((*tmp)->path, &sb) == 0 && !test_new_folder ((*tmp)->path)) { /* some systems out there don't have an off_t type */ (*tmp)->size = (long) sb.st_size; @@ -249,13 +249,16 @@ return 0; } +#define STAT_CHECK_SIZE (sb.st_size > tmp->size) +#define STAT_CHECK_ATIME (sb.st_mtime > sb.st_atime || (tmp->newly_created && sb.st_ctime == sb.st_mtime && sb.st_ctime == sb.st_atime)) + #ifdef BUFFY_SIZE /* people use buffy_size on systems where modified time attributes are BADLY * broken. Ignore them. */ -#define STAT_CHECK (sb.st_size > tmp->size) +#define STAT_CHECK (option(OPTBUFFYSIZE) ? STAT_CHECK_SIZE : STAT_CHECK_ATIME) #else -#define STAT_CHECK (sb.st_mtime > sb.st_atime || (tmp->newly_created && sb.st_ctime == sb.st_mtime && sb.st_ctime == sb.st_atime)) +#define STAT_CHECK STAT_CHECK_ATIME #endif /* BUFFY_SIZE */ int mutt_buffy_check (int force) Index: commands.c =================================================================== RCS file: /home/roessler/cvs/mutt/commands.c,v retrieving revision 3.37 diff -u -r3.37 commands.c --- commands.c 7 Dec 2006 11:34:34 -0000 3.37 +++ commands.c 28 Feb 2007 12:38:11 -0000 @@ -705,9 +705,8 @@ struct stat st; #ifdef BUFFY_SIZE BUFFY *tmp = NULL; -#else - struct utimbuf ut; #endif + struct utimbuf ut; *redraw = 0; @@ -846,7 +845,7 @@ tmp = mutt_find_mailbox (buf); if (tmp && !tmp->new) mutt_update_mailbox (tmp); -#else +#endif /* fix up the times so buffy won't get confused */ if (st.st_mtime > st.st_atime) { @@ -856,7 +855,6 @@ } else utime (buf, NULL); -#endif } mutt_clear_error (); Index: init.h =================================================================== RCS file: /home/roessler/cvs/mutt/init.h,v retrieving revision 3.110 diff -u -r3.110 init.h --- init.h 27 Feb 2007 20:39:37 -0000 3.110 +++ init.h 28 Feb 2007 12:38:11 -0000 @@ -351,6 +351,14 @@ ** follow these menus. The option is disabled by default because many ** visual terminals don't permit making the cursor invisible. */ +#ifdef BUFFY_SIZE + { "buffy_size", DT_BOOL, R_NONE, OPTBUFFYSIZE, 1 }, + /* + ** .pp + ** When this variable is set, mutt will use file size attribute instead of + ** access time when checking for new mail. + */ +#endif { "charset", DT_STR, R_NONE, UL &Charset, UL 0 }, /* ** .pp Index: mutt.h =================================================================== RCS file: /home/roessler/cvs/mutt/mutt.h,v retrieving revision 3.72 diff -u -r3.72 mutt.h --- mutt.h 27 Feb 2007 17:44:09 -0000 3.72 +++ mutt.h 28 Feb 2007 12:38:11 -0000 @@ -338,6 +338,9 @@ OPTBEEPNEW, OPTBOUNCEDELIVERED, OPTBRAILLEFRIENDLY, +#ifdef BUFFY_SIZE + OPTBUFFYSIZE, +#endif OPTCHECKNEW, OPTCOLLAPSEUNREAD, OPTCONFIRMAPPEND, Index: mx.c =================================================================== RCS file: /home/roessler/cvs/mutt/mx.c,v retrieving revision 3.27 diff -u -r3.27 mx.c --- mx.c 15 Aug 2006 17:08:32 -0000 3.27 +++ mx.c 28 Feb 2007 12:38:11 -0000 @@ -57,9 +57,7 @@ #include <stdlib.h> #include <string.h> #include <ctype.h> -#ifndef BUFFY_SIZE #include <utime.h> -#endif #define mutt_is_spool(s) (mutt_strcmp (Spoolfile, s) == 0) @@ -426,9 +424,7 @@ } else if ((f = fopen (path, "r")) != NULL) { -#ifndef BUFFY_SIZE struct utimbuf times; -#endif fgets (tmp, sizeof (tmp), f); if (mutt_strncmp ("From ", tmp, 5) == 0) @@ -436,7 +432,7 @@ else if (mutt_strcmp (MMDF_SEP, tmp) == 0) magic = M_MMDF; safe_fclose (&f); -#ifndef BUFFY_SIZE + /* need to restore the times here, the file was not really accessed, * only the type was accessed. This is important, because detection * of "new mail" depends on those times set correctly. @@ -444,7 +440,6 @@ times.actime = st.st_atime; times.modtime = st.st_mtime; utime (path, ×); -#endif } else {