<<< Date Index >>>     <<< Thread Index >>>

Re: Clarification on tag-prefix-cond vs. tag-prefix



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Friday, February 13 at 07:20 PM, quoth Jan-Herbert Damm:
> if you don't mind, can you explain the pattern "~r >3m" equally 
> well?

Well, that's pretty simple.

First, mutt uses what it calls "simple patterns" to match messages. 
(That's what you search for in the manual if you want to find more 
information.) That right there is a simple pattern. Simple patterns 
are a match-type-specifier (for lack of a better term) and, for most 
match types, a match specification. In this case, the 
match-type-specifier is "~r". These match-type-specifiers are 
*generally* a tilde and a letter. That's significant, but I'll get to 
that in a moment.

Some simple patterns only need the specifier. For example, ~N is a 
pattern that matches all new messages. There's nothing more to it.

The ~r match-type means "messages with 'date-received' in a Date 
range". In other words, the ~r pattern matches against the date that a 
message was received (how that date is calculated is somewhat 
complicated, but let's ignore that). But this pattern takes an 
argument, so you can specify a range of dates it should match. In the 
manual, this is described as "MIN-MAX", but really, it takes a "date 
range", which is described in more detail a little later in the 
manual.

A date range is fairly complex and flexible. It can be specified 
either by listing the bracketing dates (literally MIN-MAX), or by 
specifying one-end of the range, OR by specifying an age relative to 
the current time. And dates can be given error ranges.

The match I used is fairly basic. ">3m" means "greater than 3 months 
ago", and is specifying an age relative to the current time. >4m would 
mean "greater than 4 months ago". You could also do <3m, which would 
mean "less than 3 months ago", or =3m (exactly 3 months ago). The 
unit, m in this case, can also be y, w, or d (for years, weeks, or 
days).

But you can see why you'd want an error range. For example: =3m*1w, 
which would match that two-week range exactly 3 months ago (the * 
means you're expanding the match in both directions; if you use a - 
that means only further-into-the-past, and + means the opposite.).

Exact dates must be specified in DD[/MM[/[cc]YY]] form. Each bracketed 
section there means an optional field; any ommitted field is assumed 
to be the current one. So, for example, "~r 10" would match any email 
received on the 10th of this month. "~r 10/01" would match any email 
received on January 10th of this year. "~r 10/01/08" would match any 
email received on January 10th of 2008, and "~r 10/01/1908" would 
match any email that appears to have been received back before email 
existed. So, if I wanted to match all messages received in the entire 
year of 2008, I could do it a couple different ways. One way would be 
to specify a date range: ~r 01/01/2008-31/12/2008, or I could use an 
error-range to accomplish the same thing: ~r 01/01/2008+1y

For what it's worth, there's another match-type that also uses this 
same way of specifying dates: ~d, which matches the Date header 
(which, unless it's incorrect, usually means the time the message was 
*sent*, rather than received).

With me so far?

Now, I said that in the match-type-specifier, the tilde was important, 
and it is, but now we're getting into *general* "simple patterns".

*SOME* match-type-specifiers have alternate forms. For example, ~b 
specifies a match against the message body. It takes a regular 
expression as an argument (instead of a date range), which mutt then 
uses to analyze every message. However, if messages aren't available 
*locally* (e.g. if you're reading your mail via IMAP), that can cause  
you to download every message so that mutt can search through it 
trying to match the regular expression. There's an alternate form of 
that match, that only works on IMAP servers, =b. That version also 
searches the body of the message, but asks the *server* to do the 
search (thus saving bandwidth). Since the IMAP protocol doesn't allow  
you to specify a regular expression, the =b simple pattern only 
matches an exact string.

As another example, ~C is a match-type-specifier that specifies a 
match against the To: and CC: headers. Like ~b, it takes a regular 
expression. However, mutt also allows you to define named "groups" 
(which is a whole other ball of wax). Thus, there's a variant of ~C 
that will take a group name instead of a regular expression: %C. For 
example, I defined a group that contains the addresses of all of my 
family members. Thus, I can match any message that is addressed To or 
CC'd to my family members with the following simple pattern: %C family

There's a full list of simple pattern types in the manual (I usually 
use the muttrc man page as a reference for that; search for "simple 
pat" to take you to the right spot quickly).

So-called "simple patterns" like this can also be combined. For 
example, the pattern "~r <2w ~b mutt" will match any message received 
in the last two weeks that contains the word "mutt". Make sense? 
Alternately, the pattern "~r <2w | ~b mutt" will match any message 
that is EITHER received in the last two weeks OR contains the word 
mutt (note the pipe symbol (|) separating the patterns). You can 
negate patterns as well, using an exclamation mark: "!~b mutt" matches 
all messages that don't contain the word "mutt". Another way that 
patterns can be combined is with the thread-pattern-matcher, ~(). That 
will match any message in a thread containing messages that matches 
whatever's inside those parenthesis. For example, ~P means messages 
you wrote. ~(~P) matches any message in a thread that contains 
messages that you wrote.

Finally, I mentioned that some simple patterns match against lists of 
email addresses, such as ~C. Normally, those patterns match any 
message that have *any* of those email addresses match. For example, 
"%C family" will match any message whose listed recipients include one 
of my family members. However, I can put a carrot (^) on front of it,  
like so: "^%C family" That will restrict it to matching only messages 
where ALL of the recipients are my family members.

I know that's a lot of information all at once, but is that about what 
you were looking for?

~Kyle
- -- 
I beseech you, in the bowels of Christ, think it possible you may be 
mistaken.
                                                     -- Oliver Cromwell
-----BEGIN PGP SIGNATURE-----
Comment: Thank you for using encryption!

iEYEARECAAYFAkmV3RUACgkQBkIOoMqOI1786gCfSs9AFoCXGThGm0JaTALcIvCm
FXUAoNzoKaQLpUyndoIzY3y2d2blqP6q
=YJ/R
-----END PGP SIGNATURE-----