From: Karel Zak Date: Wed, 14 Dec 2011 12:16:44 +0000 (+0100) Subject: add 'virtual-mailboxes' parser X-Git-Tag: neomutt-20160404~13^2~108 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f9af845e337725051b5dbe5f3c00d7afb52f7099;p=neomutt add 'virtual-mailboxes' parser Signed-off-by: Karel Zak --- diff --git a/README.notmuch b/README.notmuch index 989029e51..1a5f3b759 100644 --- a/README.notmuch +++ b/README.notmuch @@ -5,6 +5,7 @@ notmuch support for mutt * notmuch is e-email library for e-mail fulltext indexing and tagging; see http://notmuchmail.org/ for more information. + * compile: $ git clone git://github.com/karelzak/mutt-kz.git @@ -13,3 +14,17 @@ notmuch support for mutt $ ./configure --enable-notmuch $ make + + * virtual mailboxes + + .muttrc: + + synopsis: + + virtual-mailboxes [ ...] + + example: + + virtual-mailboxes "Linux Kernel" "notmuch:///whereis/db?query=tag:lkml&limit=1000" \ + "Filesystems" "notmuch:///whereis/db?query=tag:fs" \ + "Music" "notmuch:///another/db?query=tag:hard and tag:heavy" diff --git a/buffy.c b/buffy.c index a95d5ed2f..5697c6d7c 100644 --- a/buffy.c +++ b/buffy.c @@ -219,6 +219,8 @@ static BUFFY *buffy_new (const char *path) static void buffy_free (BUFFY **mailbox) { + if (mailbox && *mailbox) + FREE (&(*mailbox)->desc); FREE (mailbox); /* __FREE_CHECKED__ */ } @@ -377,6 +379,46 @@ static int buffy_maildir_dir_hasnew(BUFFY* mailbox, const char *dir_name) return rc; } +#ifdef USE_NOTMUCH +int mutt_parse_virtual_mailboxes (BUFFER *path, BUFFER *s, unsigned long data, BUFFER *err) +{ + BUFFY **tmp; + char buf[_POSIX_PATH_MAX]; + + while (MoreArgs (s)) + { + mutt_extract_token (path, s, 0); + strfcpy (buf, path->data, sizeof (buf)); + + /* Skip empty tokens. */ + if(!*buf) continue; + + /* avoid duplicates */ + for (tmp = &VirtIncoming; *tmp; tmp = &((*tmp)->next)) + { + if (mutt_strcmp (buf, (*tmp)->path) == 0) + { + dprint(3,(debugfile,"vistual mailbox '%s' already registered as '%s'\n", buf, (*tmp)->path)); + break; + } + } + + if (!*tmp) + *tmp = buffy_new (buf); + + mutt_extract_token (path, s, 0); + if (path->data && *path->data) + (*tmp)->desc = safe_strdup( path->data); + + (*tmp)->new = 0; + (*tmp)->notified = 1; + (*tmp)->newly_created = 0; + (*tmp)->size = 0; + } + return 0; +} +#endif + /* returns 1 if maildir has new mail */ static int buffy_maildir_hasnew (BUFFY* mailbox) { diff --git a/buffy.h b/buffy.h index d69453c0e..f7f63797e 100644 --- a/buffy.h +++ b/buffy.h @@ -26,6 +26,7 @@ typedef struct buffy_t #ifdef USE_SIDEBAR char realpath[_POSIX_PATH_MAX]; #endif + char *desc; off_t size; struct buffy_t *next; #ifdef USE_SIDEBAR @@ -51,6 +52,10 @@ BUFFY; WHERE BUFFY *Incoming INITVAL (0); WHERE short BuffyTimeout INITVAL (3); +#ifdef USE_NOTMUCH +WHERE BUFFY *VirtIncoming INITVAL (0); +#endif + extern time_t BuffyDoneTime; /* last time we knew for sure how much mail there was */ BUFFY *mutt_find_mailbox (const char *path); diff --git a/init.h b/init.h index 35ba5113c..e1cb0799b 100644 --- a/init.h +++ b/init.h @@ -3887,6 +3887,9 @@ const struct command_t Commands[] = { { "macro", mutt_parse_macro, 0 }, { "mailboxes", mutt_parse_mailboxes, M_MAILBOXES }, { "unmailboxes", mutt_parse_mailboxes, M_UNMAILBOXES }, +#ifdef USE_NOTMUCH + { "virtual-mailboxes",mutt_parse_virtual_mailboxes, 0 }, +#endif { "mailto_allow", parse_list, UL &MailtoAllow }, { "unmailto_allow", parse_unlist, UL &MailtoAllow }, { "message-hook", mutt_parse_hook, M_MESSAGEHOOK }, diff --git a/protos.h b/protos.h index cbf0115b1..7c001c86f 100644 --- a/protos.h +++ b/protos.h @@ -80,6 +80,9 @@ void mutt_generate_boundary (PARAMETER **); void mutt_delete_parameter (const char *attribute, PARAMETER **p); 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); +#endif FILE *mutt_open_read (const char *, pid_t *);