]> granicus.if.org Git - neomutt/commitdiff
add nm_exclude_tags
authorKarel Zak <kzak@redhat.com>
Tue, 22 Oct 2013 18:34:57 +0000 (11:34 -0700)
committerRichard Russon <rich@flatcap.org>
Mon, 14 Mar 2016 23:11:42 +0000 (23:11 +0000)
Based on patch from: Raghavendra D Prabhu <rprabhu@wnohang.net>

 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 <rprabhu@wnohang.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
README.notmuch
globals.h
init.h
mutt_notmuch.c

index 12e3183ad12ce702c86da35b0313cf58639e1107..37d5e786f923e50a047fee3e9e5d973a3ee4afe2 100644 (file)
@@ -216,6 +216,13 @@ notmuch support for mutt
 
       Default is "unread,draft,flagged,passed,replied,attachment".
 
+   nm_exclude_tags = <comma delimited list>
+
+      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 = <name>
 
       This variable specifies notmuch tag which is used for unread messages. The
index ec5c8b66f1b7b190505d9a8f78f1af195bda7272..a1ed00358fd7f6a9099477843cf453b5b0ffa470 100644 (file)
--- 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 d528db8770c68a9f86b4d5b3d2b4e9e7bbacc803..b7a8c94165419f712b534e9ab218f66c9f0de924 100644 (file)
--- 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
index 58fc8896dab16eec4423a58f41fa730db1c0db54..a10591a8643d04e56398a0f4379d1c3be7f9423d 100644 (file)
@@ -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;