From: Richard Russon Date: Sat, 23 Jul 2016 22:08:53 +0000 (+0100) Subject: notmuch: add "virtual-unmailboxes" command X-Git-Tag: neomutt-20170113~17 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4b3067ddf37919fcb287b4346972d57142470942;p=neomutt notmuch: add "virtual-unmailboxes" command This new command removes virtual mailboxes (notmuch queries). Closes: karelzak/mutt-kz#76 Closes: karelzak/mutt-kz#144 --- diff --git a/buffy.c b/buffy.c index 4c9760266..25c68d72a 100644 --- a/buffy.c +++ b/buffy.c @@ -506,12 +506,66 @@ int mutt_parse_virtual_mailboxes (BUFFER *path, BUFFER *s, unsigned long data, B if (!*tmp) *tmp = buffy_new (buf); + (*tmp)->magic = MUTT_NOTMUCH; (*tmp)->new = 0; (*tmp)->notified = 1; (*tmp)->newly_created = 0; (*tmp)->size = 0; (*tmp)->desc = desc; +#ifdef USE_SIDEBAR + mutt_sb_notify_mailbox (*tmp, 1); +#endif + } +#ifdef USE_SIDEBAR + mutt_sb_draw(); +#endif + return 0; +} + +int mutt_parse_unvirtual_mailboxes (BUFFER *path, BUFFER *s, unsigned long data, BUFFER *err) +{ + BUFFY **tmp, *tmp1; + + while (MoreArgs (s)) + { + mutt_extract_token (path, s, 0); + + if (mutt_strcmp (path->data, "*") == 0) + { + for (tmp = &VirtIncoming; *tmp;) + { + tmp1 = (*tmp)->next; +#ifdef USE_SIDEBAR + mutt_sb_notify_mailbox (*tmp, 0); +#endif + buffy_free (tmp); + *tmp = tmp1; + } +#ifdef USE_SIDEBAR + mutt_sb_draw(); +#endif + return 0; + } + + for (tmp = &VirtIncoming; *tmp; tmp = &((*tmp)->next)) + { + if ((mutt_strcasecmp (path->data, (*tmp)->path) == 0) || + (mutt_strcasecmp (path->data, (*tmp)->desc) == 0)) + { + tmp1 = (*tmp)->next; +#ifdef USE_SIDEBAR + mutt_sb_notify_mailbox (*tmp, 0); +#endif + buffy_free (tmp); + *tmp = tmp1; + break; + } + } } + +#ifdef USE_SIDEBAR + mutt_sb_draw(); +#endif return 0; } #endif diff --git a/doc/manual.xml.head b/doc/manual.xml.head index 58b16a87a..a62f4716b 100644 --- a/doc/manual.xml.head +++ b/doc/manual.xml.head @@ -12247,6 +12247,16 @@ virtual-mailboxes "My INBOX" "notmuch://?query=tag:inbox" + unvirtual-mailboxes + + + * + + + mailbox + + + tag-transforms tag @@ -12392,6 +12402,8 @@ bind index,pager \eX vfolder-from-query # virtual-mailboxes description notmuch-URI { description notmuch-URI ...} # virtual-mailboxes "Climbing" "notmuch://?query=climbing" +# unvirtual-mailboxes { * | mailbox ...} + # Replace some tags with icons # tag-transforms tag transformed-string { tag transformed-string ...} # tag-transforms "inbox" "i" \ diff --git a/init.h b/init.h index 4135dbf10..0229bf9b1 100644 --- a/init.h +++ b/init.h @@ -4401,6 +4401,7 @@ const struct command_t Commands[] = { { "unmailboxes", mutt_parse_mailboxes, MUTT_UNMAILBOXES }, #ifdef USE_NOTMUCH { "virtual-mailboxes",mutt_parse_virtual_mailboxes, 0 }, + { "unvirtual-mailboxes",mutt_parse_unvirtual_mailboxes, 0 }, { "tag-transforms", parse_tag_transforms, 0 }, { "tag-formats", parse_tag_formats, 0 }, #endif diff --git a/protos.h b/protos.h index f9cd30976..72eb5e6e7 100644 --- a/protos.h +++ b/protos.h @@ -87,6 +87,7 @@ void mutt_set_parameter (const char *, const char *, PARAMETER **); #ifdef USE_NOTMUCH int mutt_parse_virtual_mailboxes (BUFFER *path, BUFFER *s, unsigned long data, BUFFER *err); +int mutt_parse_unvirtual_mailboxes (BUFFER *path, BUFFER *s, unsigned long data, BUFFER *err); #endif FILE *mutt_open_read (const char *, pid_t *);