]> granicus.if.org Git - neomutt/commitdiff
hidden_tags -> slist
authorRichard Russon <rich@flatcap.org>
Mon, 10 Jun 2019 12:26:47 +0000 (13:26 +0100)
committerRichard Russon <rich@flatcap.org>
Wed, 12 Jun 2019 23:23:35 +0000 (00:23 +0100)
Convert `$hidden_tags` to use the new DT_SLIST type (string list).

email/tags.c
email/tags.h
init.h

index d1fc589a42087887f070d6d24c32935dab4ee713..b23aa19272e01997e32d4dccb96255492b51a799 100644 (file)
 #include <stdbool.h>
 #include <string.h>
 #include "mutt/mutt.h"
+#include "config/lib.h"
 #include "tags.h"
 
 /* These Config Variables are only used in email/tags.c */
-char *C_HiddenTags; ///< Config: Tags that shouldn't be displayed on screen
+struct Slist *C_HiddenTags; ///< Config: Tags that shouldn't be displayed on screen
 
 struct Hash *TagTransforms; /**< Lookup table of alternative tag names */
 
@@ -82,26 +83,17 @@ static void driver_tags_add(struct TagHead *head, char *new_tag)
 {
   char *new_tag_transformed = mutt_hash_find(TagTransforms, new_tag);
 
-  struct TagNode *np = mutt_mem_calloc(1, sizeof(struct TagNode));
-  np->name = mutt_str_strdup(new_tag);
-  np->hidden = false;
+  struct TagNode *tn = mutt_mem_calloc(1, sizeof(struct TagNode));
+  tn->name = mutt_str_strdup(new_tag);
+  tn->hidden = false;
   if (new_tag_transformed)
-    np->transformed = mutt_str_strdup(new_tag_transformed);
+    tn->transformed = mutt_str_strdup(new_tag_transformed);
 
   /* filter out hidden tags */
-  if (C_HiddenTags)
-  {
-    char *p = strstr(C_HiddenTags, new_tag);
-    size_t xsz = p ? mutt_str_strlen(new_tag) : 0;
-
-    if (p && ((p == C_HiddenTags) || (p[-1] == ',') || (p[-1] == ' ')) &&
-        ((p[xsz] == '\0') || (p[xsz] == ',') || (p[xsz] == ' ')))
-    {
-      np->hidden = true;
-    }
-  }
+  if (mutt_list_find(&C_HiddenTags->head, new_tag))
+    tn->hidden = true;
 
-  STAILQ_INSERT_TAIL(head, np, entries);
+  STAILQ_INSERT_TAIL(head, tn, entries);
 }
 
 /**
index d2bcb1eee923063751d1ac65cd458d1f10bcad7a..13ae44c805b863c927c0c621f5adbfa992327f23 100644 (file)
@@ -27,7 +27,7 @@
 #include "mutt/mutt.h"
 
 /* These Config Variables are only used in email/tags.c */
-extern char *C_HiddenTags;
+extern struct Slist *C_HiddenTags;
 
 extern struct Hash *TagTransforms;
 
diff --git a/init.h b/init.h
index 62100b240ff3f931db0b87e9a9844fb82c295b6c..6d3b5da084aa914ba31675b22b8354520226ebcb 100644 (file)
--- a/init.h
+++ b/init.h
@@ -1420,7 +1420,7 @@ struct ConfigDef MuttVars[] = {
   ** affect the generation of Message-IDs, and it will not lead to the
   ** cut-off of first-level domains.
   */
-  { "hidden_tags", DT_STRING, &C_HiddenTags, IP "unread,draft,flagged,passed,replied,attachment,signed,encrypted" },
+  { "hidden_tags", DT_SLIST|SLIST_SEP_COMMA, &C_HiddenTags, IP "unread,draft,flagged,passed,replied,attachment,signed,encrypted" },
   /*
   ** .pp
   ** This variable specifies private notmuch/imap tags which should not be printed