summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/manual.sgml.head11
-rw-r--r--hdrline.c39
-rw-r--r--init.h6
-rw-r--r--mutt.h2
-rw-r--r--parse.c5
-rw-r--r--pattern.c3
6 files changed, 65 insertions, 1 deletions
diff --git a/doc/manual.sgml.head b/doc/manual.sgml.head
index e98fa1ba..99f21ac8 100644
--- a/doc/manual.sgml.head
+++ b/doc/manual.sgml.head
@@ -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
diff --git a/hdrline.c b/hdrline.c
index 9ee54bef..9ace2ca6 100644
--- 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 061650cf..0ce81a47 100644
--- 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 db7ba4c6..4325dfd7 100644
--- 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 011d6028..e93d5c23 100644
--- 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;
diff --git a/pattern.c b/pattern.c
index 643bcc4d..4b749ab2 100644
--- 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);