Skip to content

Commit

Permalink
add "virtual-unmailboxes" command
Browse files Browse the repository at this point in the history
This new command removes virtual mailboxes (notmuch queries).
It works OK, but there are still some display issues.

References:
    karelzak/mutt-kz#76
    karelzak/mutt-kz#144
  • Loading branch information
flatcap committed Dec 24, 2016
1 parent e38035a commit 92a188d
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
43 changes: 42 additions & 1 deletion buffy.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ int mutt_parse_virtual_mailboxes (BUFFER *path, BUFFER *s, unsigned long data, B

mutt_extract_token (path, s, 0);
if (path->data && *path->data)
desc = safe_strdup( path->data);
desc = safe_strdup (path->data);
else
continue;

Expand Down Expand Up @@ -514,6 +514,47 @@ int mutt_parse_virtual_mailboxes (BUFFER *path, BUFFER *s, unsigned long data, B
}
return 0;
}

int mutt_parse_virtual_unmailboxes (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;
}
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;
}
}
}

return 0;
}
#endif

static void buffy_check (BUFFY *tmp, struct stat *contex_sb, int check_stats)
Expand Down
1 change: 1 addition & 0 deletions init.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
{ "virtual-unmailboxes",mutt_parse_virtual_unmailboxes, 0 },
{ "tag-transforms", parse_tag_transforms, 0 },
{ "tag-formats", parse_tag_formats, 0 },
#endif
Expand Down
1 change: 1 addition & 0 deletions protos.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_virtual_unmailboxes (BUFFER *path, BUFFER *s, unsigned long data, BUFFER *err);
#endif

FILE *mutt_open_read (const char *, pid_t *);
Expand Down

0 comments on commit 92a188d

Please sign in to comment.