Re: mbox-hook: broken or useless?
> The patch is included below. If you, or anyone else, can spot
> any obvious problems with this, please let me know -- I really
> don't want to loose any mail over this. :-)
Here's one obvious problem I just noticed myself: If a save-hook
matches an email, the default mbox will always be the mbox from the
last matching save-hook, not the one specified with the 'mbox'
option. A new patch that fixes this is shown here:
--- mutt-1.5.10/mx.c.orig 2005-08-02 09:08:01.000000000 +0200
+++ mutt-1.5.10/mx.c 2005-08-28 09:35:05.000000000 +0200
@@ -819,6 +819,8 @@
return rc;
}
+int mutt_addr_hook (char *path, size_t pathlen, int type, CONTEXT *ctx, HEADER
*hdr);
+
/* save changes and close mailbox */
int mx_close_mailbox (CONTEXT *ctx, int *index_hint)
{
@@ -944,14 +946,20 @@
else /* use regular append-copy mode */
#endif
{
- if (mx_open_mailbox (mbox, M_APPEND, &f) == NULL)
- {
- ctx->closing = 0;
- return -1;
- }
+ char save_hook_mbox[_POSIX_PATH_MAX];
+ char *mbox_ptr = mbox;
for (i = 0; i < ctx->msgcount; i++)
{
+ if (mutt_addr_hook (save_hook_mbox, sizeof (save_hook_mbox),
M_SAVEHOOK, ctx, ctx->hdrs[i]) == 0)
+ mbox_ptr = save_hook_mbox;
+ else
+ mbox_ptr = mbox;
+ if (mx_open_mailbox (mbox_ptr, M_APPEND, &f) == NULL)
+ {
+ ctx->closing = 0;
+ return -1;
+ }
if (ctx->hdrs[i]->read && !ctx->hdrs[i]->deleted
&& !(ctx->hdrs[i]->flagged && option (OPTKEEPFLAGGED)))
{
@@ -966,9 +974,8 @@
return -1;
}
}
+ mx_close_mailbox (&f, NULL);
}
-
- mx_close_mailbox (&f, NULL);
}
}
--- mutt-1.5.10/hook.c.orig 2005-02-03 19:47:52.000000000 +0100
+++ mutt-1.5.10/hook.c 2005-08-28 09:31:56.000000000 +0200
@@ -351,7 +351,7 @@
current_hook_type = 0;
}
-static int
+int
mutt_addr_hook (char *path, size_t pathlen, int type, CONTEXT *ctx, HEADER
*hdr)
{
HOOK *hook;
--
Haakon