doc/manual.xml.head | 23 +++++++++++++++++++++++ mutt.h | 1 + pattern.c | 18 ++++++++++++++++-- 3 files changed, 40 insertions(+), 2 deletions(-)
# HG changeset patch # User David Champion <d...@bikeshed.us> # Date 1472600102 25200 # Tue Aug 30 16:35:02 2016 -0700 # Node ID d2a36497a89c8af5de751bea6dd1e20932b5604a # Parent a347a5b31a5a032d4b3753045c9fc1a73f6023f8 Adds the '@' pattern modifier to limit matches to known aliases. Example: ~f joe matches messages from joe. @~f joe matches messages from any joe who is defined as an alias. diff --git a/doc/manual.xml.head b/doc/manual.xml.head --- a/doc/manual.xml.head +++ b/doc/manual.xml.head @@ -4359,6 +4359,29 @@ <command>macro</command>'s commands into its history. </para> +<para> +You can restrict address pattern matching to aliases that you have +defined with the "@" modifier. This example matches messages whose +recipients are all from Germany, and who are known to your alias list. +</para> + +<para> +<screen> +^@~C \.de$ +</screen> +</para> + +<para> +To match any defined alias, use a regular expression that matches any +string. This example matches messages whose senders are known aliases. +</para> + +<para> +<screen> +@~f . +</screen> +</para> + </sect3> </sect2> diff --git a/mutt.h b/mutt.h --- a/mutt.h +++ b/mutt.h @@ -850,6 +850,7 @@ unsigned int stringmatch : 1; unsigned int groupmatch : 1; unsigned int ign_case : 1; /* ignore case for local stringmatch searches */ + unsigned int isalias : 1; int min; int max; struct pattern_t *next; diff --git a/pattern.c b/pattern.c --- a/pattern.c +++ b/pattern.c @@ -783,6 +783,7 @@ int alladdr = 0; int or = 0; int implicit = 1; /* used to detect logical AND operator */ + int isalias = 0; const struct pattern_flags *entry; char *p; char *buf; @@ -805,6 +806,10 @@ ps.dptr++; not = !not; break; + case '@': + ps.dptr++; + isalias = !isalias; + break; case '|': if (!or) { @@ -830,6 +835,7 @@ implicit = 0; not = 0; alladdr = 0; + isalias = 0; break; case '%': case '=': @@ -859,8 +865,10 @@ last = tmp; tmp->not ^= not; tmp->alladdr |= alladdr; + tmp->isalias |= isalias; not = 0; alladdr = 0; + isalias = 0; /* compile the sub-expression */ buf = mutt_substrdup (ps.dptr + 1, p); if ((tmp2 = mutt_pattern_comp (buf, flags, err)) == NULL) @@ -888,10 +896,12 @@ tmp = new_pattern (); tmp->not = not; tmp->alladdr = alladdr; + tmp->isalias = isalias; tmp->stringmatch = (*ps.dptr == '=') ? 1 : 0; tmp->groupmatch = (*ps.dptr == '%') ? 1 : 0; not = 0; alladdr = 0; + isalias = 0; if (last) last->next = tmp; @@ -957,8 +967,10 @@ last = tmp; tmp->not ^= not; tmp->alladdr |= alladdr; + tmp->isalias |= isalias; not = 0; alladdr = 0; + isalias = 0; ps.dptr = p + 1; /* restore location */ break; default: @@ -1010,8 +1022,10 @@ { for (a = va_arg (ap, ADDRESS *) ; a ; a = a->next) { - if (pat->alladdr ^ ((a->mailbox && patmatch (pat, a->mailbox) == 0) || - (match_personal && a->personal && patmatch (pat, a->personal) == 0))) + if (pat->alladdr ^ + ((!pat->isalias || alias_reverse_lookup(a)) && + ((a->mailbox && patmatch (pat, a->mailbox) == 0) || + (match_personal && a->personal && !patmatch (pat, a->personal) )))) { va_end (ap); return (! pat->alladdr); /* Found match, or non-match if alladdr */