]> granicus.if.org Git - neomutt/commitdiff
tags: Add index_format %J
authorMehdi Abaakouk <sileht@sileht.net>
Mon, 20 Feb 2017 20:20:50 +0000 (21:20 +0100)
committerRichard Russon <rich@flatcap.org>
Tue, 3 Oct 2017 12:47:30 +0000 (13:47 +0100)
This change adds %J to index_format, to be able to show message tags
only when they are different from the previous one in a thread.

hdrline.c

index a9aa2327d0a810d4534093d17b3111631af18b7d..80fdfc7e184da1956a472e2250802a03431a88b7 100644 (file)
--- a/hdrline.c
+++ b/hdrline.c
@@ -472,6 +472,7 @@ static char *apply_subject_mods(struct Envelope *env)
  * | \%F     | like %n, unless from self
  * | \%g     | message tags (e.g. notmuch tags)
  * | \%Gx    | individual message tag (e.g. notmuch tags)
+ * | \%J     | message tags (if present, tree unfolded, and != parent's keywords)
  * | \%i     | message-id
  * | \%I     | initials of author
  * | \%K     | the list to which the letter was sent (if any; otherwise: empty)
@@ -902,6 +903,38 @@ static const char *hdr_format_str(char *dest, size_t destlen, size_t col, int co
                     hdr->env->message_id ? hdr->env->message_id : "<no.id>");
       break;
 
+    case 'J':;
+      const char *tags = hdr_tags_get_transformed(hdr);
+      if (tags)
+      {
+        i = 1; /* reduce reuse recycle */
+        htmp = NULL;
+
+        if (flags & MUTT_FORMAT_TREE &&
+            (hdr->thread->prev && hdr->thread->prev->message &&
+             hdr_tags_get_transformed(hdr->thread->prev->message)))
+          htmp = hdr->thread->prev->message;
+        else if (flags & MUTT_FORMAT_TREE &&
+                 (hdr->thread->parent && hdr->thread->parent->message &&
+                  hdr_tags_get_transformed(hdr->thread->parent->message)))
+          htmp = hdr->thread->parent->message;
+        if (htmp && mutt_strcasecmp(tags, hdr_tags_get_transformed(htmp)) == 0)
+          i = 0;
+      }
+      else
+        i = 0;
+
+      if (optional)
+        optional = i;
+
+      colorlen = add_index_color(dest, destlen, flags, MT_COLOR_INDEX_TAGS);
+      if (i)
+        mutt_format_s(dest + colorlen, destlen - colorlen, prefix, NONULL(tags));
+      else
+        mutt_format_s(dest + colorlen, destlen - colorlen, prefix, "");
+      add_index_color(dest + colorlen, destlen - colorlen, flags, MT_COLOR_INDEX);
+      break;
+
     case 'l':
       if (!optional)
       {