[PATCH] is-alias pattern
This is a tiny patch to add an "~a" pattern, which matches
if h->env->from is a defined alias. I hope this will find
a home alongside the recent pattern group stuff, on account
of its simplicity.
I also considered allowing ~a to take an argument, which
identifies a group of aliases (such as "theguys" in the
manual) against which to match. I have not actually
implemented this, as it may be superfluous with pattern
groups, albeit simpler. It is unfortunate that ~f does not
work for this purpose.
Another option yet might be to implement a magical pattern
group which matches all aliases.
I don't often do this sort of thing, and I am not well
versed in mutt's inner workings, so please let me know if
I've done something wrong.
--
Sean Hamilton <sh@xxxxxxxxx>
Index: mutt.h
===================================================================
RCS file: /home/roessler/cvs/mutt/mutt.h,v
retrieving revision 3.65
diff -u -r3.65 mutt.h
--- mutt.h 28 Apr 2006 19:52:45 -0000 3.65
+++ mutt.h 5 Aug 2006 10:35:25 -0000
@@ -204,6 +204,7 @@
M_LIMIT,
M_EXPIRED,
M_SUPERSEDED,
+ M_ISALIAS,
/* actions for mutt_pattern_comp/mutt_pattern_exec */
M_AND,
Index: pattern.c
===================================================================
RCS file: /home/roessler/cvs/mutt/pattern.c,v
retrieving revision 3.30
diff -u -r3.30 pattern.c
--- pattern.c 28 Apr 2006 19:52:45 -0000 3.30
+++ pattern.c 5 Aug 2006 10:35:25 -0000
@@ -55,6 +55,7 @@
Flags[] =
{
{ 'A', M_ALL, 0, NULL },
+ { 'a', M_ISALIAS, 0, NULL },
{ 'b', M_BODY, M_FULL_MSG, eat_regexp },
{ 'B', M_WHOLE_MSG, M_FULL_MSG, eat_regexp },
{ 'c', M_CC, 0, eat_regexp },
@@ -1138,6 +1139,8 @@
}
case M_UNREFERENCED:
return (pat->not ^ (h->thread && !h->thread->child));
+ case M_ISALIAS:
+ return (pat->not ^ (NULL != alias_reverse_lookup (h->env->from)));
}
mutt_error (_("error: unknown op %d (report this error)."), pat->op);
return (-1);
Index: doc/manual.xml.head
===================================================================
RCS file: /home/roessler/cvs/mutt/doc/manual.xml.head,v
retrieving revision 3.24
diff -u -r3.24 manual.xml.head
--- doc/manual.xml.head 3 Aug 2006 23:46:31 -0000 3.24
+++ doc/manual.xml.head 5 Aug 2006 10:35:30 -0000
@@ -3515,6 +3515,7 @@
</thead>
<tbody>
<row><entry>~A</entry><entry>all messages</entry></row>
+<row><entry>~a</entry><entry>messages from an address for which an alias is
defined</entry></row>
<row><entry>~b EXPR</entry><entry>messages which contain EXPR in the message
body</entry></row>
<row><entry>~B EXPR</entry><entry>messages which contain EXPR in the whole
message</entry></row>
<row><entry>~c EXPR</entry><entry>messages carbon-copied to EXPR</entry></row>
Index: doc/muttrc.man.head
===================================================================
RCS file: /home/roessler/cvs/mutt/doc/muttrc.man.head,v
retrieving revision 3.22
diff -u -r3.22 muttrc.man.head
--- doc/muttrc.man.head 20 Jul 2006 00:12:52 -0000 3.22
+++ doc/muttrc.man.head 5 Aug 2006 10:35:30 -0000
@@ -401,6 +401,7 @@
.TS
l l.
~A all messages
+~a messages from an address for which an alias is defined
~b \fIEXPR\fP messages which contain \fIEXPR\fP in the message body
~B \fIEXPR\fP messages which contain \fIEXPR\fP in the whole message
~c \fIEXPR\fP messages carbon-copied to \fIEXPR\fP