From: Karel Zak Date: Tue, 22 Oct 2013 18:34:57 +0000 (-0700) Subject: add nm_exclude_tags X-Git-Tag: neomutt-20160317~5^2~26 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9881f7905305b781df0d73088c869c736610b73e;p=neomutt add nm_exclude_tags Based on patch from: Raghavendra D Prabhu This makes use of notmuch_query_add_tag_exclude in notmuch API, to exclude messages tagged with tags from nm_exclude_tags from query results by default unless specified explicitly. Signed-off-by: Raghavendra D Prabhu Signed-off-by: Karel Zak --- diff --git a/README.notmuch b/README.notmuch index 12e3183ad..37d5e786f 100644 --- a/README.notmuch +++ b/README.notmuch @@ -216,6 +216,13 @@ notmuch support for mutt Default is "unread,draft,flagged,passed,replied,attachment". + nm_exclude_tags = + + The messages tagged with these tags are excluded and not loaded + from notmuch DB to mutt unless specified explicitly. + + Not set by default. + nm_unread_tag = This variable specifies notmuch tag which is used for unread messages. The diff --git a/globals.h b/globals.h index ec5c8b66f..a1ed00358 100644 --- a/globals.h +++ b/globals.h @@ -285,6 +285,7 @@ WHERE char *SmimeGetCertEmailCommand; #ifdef USE_NOTMUCH WHERE int NotmuchOpenTimeout; WHERE char *NotmuchDefaultUri; +WHERE char *NotmuchExcludeTags; WHERE char *NotmuchUnreadTag; WHERE char *NotmuchHiddenTags; WHERE char *VirtFolderFormat; diff --git a/init.h b/init.h index d528db877..b7a8c9416 100644 --- a/init.h +++ b/init.h @@ -1668,6 +1668,12 @@ struct option_t MuttVars[] = { ** This variable specifies private notmuch tags which should not be printed ** on screen. */ + { "nm_exclude_tags", DT_STR, R_NONE, UL &NotmuchExcludeTags, 0 }, + /* + ** .pp + ** The messages tagged with these tags are excluded and not loaded + ** from notmuch DB to mutt unless specified explicitly. + */ { "nm_unread_tag", DT_STR, R_NONE, UL &NotmuchUnreadTag, UL "unread" }, /* ** .pp diff --git a/mutt_notmuch.c b/mutt_notmuch.c index 58fc8896d..a10591a86 100644 --- a/mutt_notmuch.c +++ b/mutt_notmuch.c @@ -584,6 +584,32 @@ static notmuch_query_t *get_query(struct nm_ctxdata *data, int writable) if (!q) goto err; + if (NotmuchExcludeTags) { + char *buf = safe_strdup(NotmuchExcludeTags); + char *p, *tag = NULL, *end = NULL; + + for (p = buf; p && *p; p++) { + if (!tag && isspace(*p)) + continue; + if (!tag) + tag = p; /* begin of the tag */ + if (*p == ',' || *p == ' ') + end = p; /* terminate the tag */ + else if (*(p + 1) == '\0') + end = p + 1; /* end of optstr */ + if (!tag || !end) + continue; + if (tag >= end) + break; + *end = '\0'; + + dprint(2, (debugfile, "nm: query explude tag '%s'\n", tag)); + notmuch_query_add_tag_exclude(q, tag); + end = tag = NULL; + } + FREE(&buf); + + } notmuch_query_set_sort(q, NOTMUCH_SORT_NEWEST_FIRST); dprint(2, (debugfile, "nm: query successfully initialized\n")); return q;