/**
* mutt_folder_hook - Perform a folder hook
- * @param path Path to match
+ * @param path Path to potentially match
+ * @param desc Description to potentially match
*/
-void mutt_folder_hook(const char *path)
+void mutt_folder_hook(const char *path, const char *desc)
{
+ if (!path && !desc)
+ return;
+
struct Hook *tmp = NULL;
struct Buffer err, token;
if (tmp->type & MUTT_FOLDER_HOOK)
{
- if ((regexec(tmp->regex.regex, path, 0, NULL, 0) == 0) ^ tmp->regex.not)
+ if ((path && (regexec(tmp->regex.regex, path, 0, NULL, 0) == 0) ^ tmp->regex.not) ||
+ (desc && (regexec(tmp->regex.regex, desc, 0, NULL, 0) == 0) ^ tmp->regex.not))
{
if (mutt_parse_rc_line(tmp->command, &token, &err) == MUTT_CMD_ERROR)
{
void mutt_default_save(char *path, size_t pathlen, struct Email *e);
void mutt_delete_hooks(int type);
char *mutt_find_hook(int type, const char *pat);
-void mutt_folder_hook(const char *path);
+void mutt_folder_hook(const char *path, const char *desc);
void mutt_message_hook(struct Mailbox *m, struct Email *e, int type);
enum CommandResult mutt_parse_hook(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
enum CommandResult mutt_parse_unhook(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
* mutt_push/pop_current_menu() functions. If that changes, the menu
* would need to be reset here, and the pager cleanup code after the
* switch statement would need to be run. */
- mutt_folder_hook(buf);
+ mutt_folder_hook(buf, m->desc);
const int flags =
(ReadOnly || (op == OP_MAIN_CHANGE_FOLDER_READONLY)) ? MUTT_READONLY : 0;
}
}
- mutt_folder_hook(folder);
+ mutt_folder_hook(folder, NULL);
mutt_startup_shutdown_hook(MUTT_STARTUP_HOOK);
repeat_error = true;
set_noconv_flags(e->content, true);
#ifdef RECORD_FOLDER_HOOK
- mutt_folder_hook(path);
+ mutt_folder_hook(path, NULL);
#endif
struct Context *f = mx_mbox_open(NULL, path, MUTT_APPEND | MUTT_QUIET);
if (!f)
/* We ran a folder hook for the destination mailbox,
* now we run it for the user's current mailbox */
if (Context && Context->mailbox->path)
- mutt_folder_hook(Context->mailbox->path);
+ mutt_folder_hook(Context->mailbox->path, Context->mailbox->desc);
#endif
return rc;