New function that does a full mailbox check regardless of imap_passive
A longtime annoyance I've had with mutt is that I never found the
check-new function very useful. What I wanted was a mail checking
function that does the same as opening a folder when imap_passive
is disabled, but it should not require noimap_passive. The reason
why I don't want to set noimap_passive is that it slows everything
down; sometimes, I just want to start mutt to read mail in local
folders, or just to compose a new email, and then I do _not_
want the multi-second delay that is introduced when mutt needs
to log into the IMAP server(s) on every startup.
For a long time, my solution to this problem was to make a macro
that did the following:
(1) set noimap_passive
(2) enter dummy folder, thereby opening imap connections and
checking for new mail in all imap folders
(3) return to folder browser
(4) set imap_passive
This works, but it feels a bit clumsy because of the unnecessary
dummy folder and the screen noise caused by the changing
of folders. I had finally had enough with this, so I took at
look at what happens when mutt enters a folder and created a new
function I call buffy-check that tries do just the folder checking
with imap_passive disabled. The patch is shown below. Comments?
By the way: While doing this I noticed that there is an
undocumented fallthrough from OP_TOGGLE_MAILBOXES to OP_CHECK_NEW.
Is this intentional? If so, better put a /* fallthrough */
comment where the break statement should be.
--- mutt-1.5.9/browser.c.orig 2005-02-19 14:49:37.000000000 +0100
+++ mutt-1.5.9/browser.c 2005-05-04 19:29:25.000000000 +0200
@@ -1106,7 +1106,7 @@
case OP_TOGGLE_MAILBOXES:
buffy = 1 - buffy;
- case OP_CHECK_NEW:
+ case OP_CHECK_NEW: op_check_new:
destroy_state (&state);
prefix[0] = 0;
killPrefix = 0;
@@ -1130,6 +1130,18 @@
init_menu (&state, menu, title, sizeof (title), buffy);
break;
+ case OP_BUFFY_CHECK:
+ {
+ int imap_passive = option (OPTIMAPPASSIVE);
+ unset_option (OPTIMAPPASSIVE);
+ mutt_buffy_check (1);
+ imap_keepalive ();
+ mutt_buffy_notify ();
+ if (imap_passive)
+ set_option (OPTIMAPPASSIVE);
+ }
+ goto op_check_new;
+
case OP_BUFFY_LIST:
mutt_buffy_list ();
break;
--- mutt-1.5.9/OPS.orig 2005-02-19 14:49:37.000000000 +0100
+++ mutt-1.5.9/OPS 2005-05-04 19:14:43.000000000 +0200
@@ -14,6 +14,7 @@
OP_BUFFY_LIST "list mailboxes with new mail"
OP_CHANGE_DIRECTORY "change directories"
OP_CHECK_NEW "check mailboxes for new mail"
+OP_BUFFY_CHECK "check all mailboxes (even imap) for new mail"
OP_COMPOSE_ATTACH_FILE "attach a file(s) to this message"
OP_COMPOSE_ATTACH_MESSAGE "attach message(s) to this message"
OP_COMPOSE_EDIT_BCC "edit the BCC list"
--- mutt-1.5.9/functions.h.orig 2005-02-19 14:49:39.000000000 +0100
+++ mutt-1.5.9/functions.h 2005-05-04 19:14:43.000000000 +0200
@@ -344,6 +344,7 @@
{ "sort-reverse", OP_SORT_REVERSE, "O" },
{ "select-new", OP_BROWSER_NEW_FILE, "N" },
{ "check-new", OP_CHECK_NEW, NULL },
+ { "buffy-check", OP_BUFFY_CHECK, NULL },
{ "toggle-mailboxes", OP_TOGGLE_MAILBOXES, "\t" },
{ "view-file", OP_BROWSER_VIEW_FILE, " " },
{ "buffy-list", OP_BUFFY_LIST, "." },
--
Haakon