]> granicus.if.org Git - neomutt/commitdiff
X-Label header support from David Champion <dgc@uchicago.edu>.
authorThomas Roessler <roessler@does-not-exist.org>
Tue, 9 May 2000 15:32:49 +0000 (15:32 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Tue, 9 May 2000 15:32:49 +0000 (15:32 +0000)
doc/manual.sgml.head
hdrline.c
init.h
mutt.h
parse.c
pattern.c

index e98fa1baa43cb8c652e981e5aced0e400e9e4d47..99f21ac8aaf6568f435b39d79efa08bd6ad94328 100644 (file)
@@ -1610,6 +1610,7 @@ messages:
 ~U              unread messages
 ~v             message is part of a collapsed thread.
 ~x EXPR         messages which contain EXPR in the `References' field
+~y EXPR         messages which contain EXPR in the `X-Label' field
 ~z [MIN]-[MAX]  messages with a size in the range MIN to MAX *)
 </verb></tscreen>
 
@@ -1944,6 +1945,16 @@ the ``Reply-To'' field, or reply directly to the address given in the
 ``From'' field.  When unset, the ``Reply-To'' field will be used when
 present.
 
+The ``X-Label:'' header field can be used to further identify mailing
+lists or list subject matter (or just to annotate messages
+individually).  The <ref id="index_format"
+name="&dollar;index&lowbar;format"> variable's ``&percnt;y'' and
+``&percnt;Y'' escapes can be used to expand ``X-Label:'' fields in the
+index, and Mutt's pattern-matcher can match regular expressions to
+``X-Label:'' fields with the ``~y'' selector.  ``X-Label:'' is not a
+standard message header field, but it can easily be inserted by procmail
+and other mail filtering agents.
+
 Lastly, Mutt has the ability to <ref id="sort" name="sort"> the mailbox into
 <ref id="threads" name="threads">.  A thread is a group of messages which all relate to the same
 subject.  This is usually organized into a tree-like structure where a
index 9ee54bef77bc98ce91c089fc39853531b26606f0..9ace2ca655d3becb5995908eb6581b40c90139bf 100644 (file)
--- a/hdrline.c
+++ b/hdrline.c
@@ -217,6 +217,8 @@ int mutt_user_is_recipient (HEADER *h)
  * %T = $to_chars
  * %u = user (login) name of author
  * %v = first name of author, unless from self
+ * %y = `x-label:' field (if present)
+ * %Y = `x-label:' field (if present, tree unfolded, and != parent's x-label)
  * %Z = status flags   */
 
 struct hdr_format_info
@@ -267,7 +269,7 @@ hdr_format_str (char *dest,
                format_flag flags)
 {
   struct hdr_format_info *hfi = (struct hdr_format_info *) data;
-  HEADER *hdr;
+  HEADER *hdr, *htmp;
   CONTEXT *ctx;
   char fmt[SHORT_STRING], buf2[SHORT_STRING], ch, *p;
   int do_locales, i;
@@ -650,6 +652,41 @@ hdr_format_str (char *dest,
       hdr_format_s (dest, destlen, prefix, buf2);
       break;
 
+     case 'y':
+       if (optional)
+        optional = hdr->env->x_label ? 1 : 0;
+
+       hdr_format_s (dest, destlen, prefix, NONULL (hdr->env->x_label));
+       break;
+    case 'Y':
+      if (hdr->env->x_label)
+      {
+       i = 1;  /* reduce reuse recycle */
+       htmp = NULL;
+       if (flags & M_FORMAT_TREE
+           && (hdr->prev && hdr->prev->env->x_label))
+         htmp = hdr->prev;
+       else if (flags & M_FORMAT_TREE
+                && (hdr->parent && hdr->parent->env->x_label))
+         htmp = hdr->parent;
+       if (htmp && mutt_strcasecmp (hdr->env->x_label,
+                                    htmp->env->x_label) == 0)
+         i = 0;
+      }
+      else
+       i = 0;
+
+      if (optional)
+       optional = i;
+
+      if (i)
+        hdr_format_s (dest, destlen, prefix, NONULL (hdr->env->x_label));
+      else
+        hdr_format_s (dest, destlen, prefix, "");
+
+      break;
+      
     default:
       snprintf (dest, destlen, "%%%s%c", prefix, op);
       break;
diff --git a/init.h b/init.h
index 061650cf7b9b0217152d47b7c7094b75ee1d836f..0ce81a474da3d2067c6f848c0cb58c52d42741ff 100644 (file)
--- a/init.h
+++ b/init.h
@@ -806,6 +806,12 @@ struct option_t MuttVars[] = {
   ** %u      user (login) name of the author
   ** %v      first name of the author, or the 
   ** .       recipient if the message is from you
+  ** %y             `x-label:' field, if present
+  ** %Y             `x-label' field, if present, and 
+  ** .       (1) not at part of a thread tree,
+  ** .       (2) at the top of a thread, or
+  ** .              (3) `x-label' is different from preceding
+  ** .       message's `x-label'.
   ** %Z      message status flags
   ** %{fmt}  the date and time of the message is
   ** .       converted to sender's time zone, and 
diff --git a/mutt.h b/mutt.h
index db7ba4c6e6c90c159ca516cca42e8df3674decc4..4325dfd70c93dae4e3bab0becfd1955377af3040 100644 (file)
--- a/mutt.h
+++ b/mutt.h
@@ -199,6 +199,7 @@ enum
   M_PGP_ENCRYPT,
   M_PGP_KEY,
 #endif
+  M_XLABEL,
   
   /* Options for Mailcap lookup */
   M_EDIT,
@@ -462,6 +463,7 @@ typedef struct envelope
   char *message_id;
   char *supersedes;
   char *date;
+  char *x_label;
   LIST *references;            /* message references (in reverse order) */
   LIST *userhdrs;              /* user defined headers */
 } ENVELOPE;
diff --git a/parse.c b/parse.c
index 011d602870f7fab6c825b7a64a3219ba2f15263e..e93d5c23cec89920af69b7ad541095567c1becaf 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -1181,6 +1181,11 @@ ENVELOPE *mutt_read_rfc822_header (FILE *f, HEADER *hdr, short user_hdrs,
          }
          matched = 1;
        }
+       else if (mutt_strcasecmp (line+1, "-label") == 0)
+       {
+         e->x_label = safe_strdup(p);
+         matched = 1;
+       }
            
       default:
        break;
index 643bcc4dab2c57eb04b737b3b108fce3ebb75ccc..4b749ab2539637d29d6cd5c5b31bc6a9ebb644b5 100644 (file)
--- a/pattern.c
+++ b/pattern.c
@@ -88,6 +88,7 @@ Flags[] =
   { 'U', M_UNREAD,             0,              NULL },
   { 'v', M_COLLAPSED,          0,              NULL },
   { 'x', M_REFERENCE,          0,              eat_regexp },
+  { 'y', M_XLABEL,             0,              eat_regexp },
   { 'z', M_SIZE,               0,              eat_range },
   { 0 }
 };
@@ -890,6 +891,8 @@ mutt_pattern_exec (struct pattern_t *pat, pattern_exec_flag flags, CONTEXT *ctx,
    case M_PGP_KEY:
      return (pat->not ^ (h->pgp & PGPKEY));
 #endif
+    case M_XLABEL:
+      return (pat->not ^ (h->env->x_label && regexec (pat->rx, h->env->x_label, 0, NULL, 0) == 0));
   }
   mutt_error (_("error: unknown op %d (report this error)."), pat->op);
   return (-1);