[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Af has search commands, which allow you to search through the messages in a buffer and find those which match a regular expression. You can also search for messages which match a tag expression.
15.1 Searching for Regular Expressions Searching for regular expressions. 15.2 Searching for Tagged Messages Searching for tagged messages. 15.3 Tagging Matching Messages Tag all messages which match a regex. 15.4 Syntax of Regular Expressions The syntax of regular expressions. 15.5 Searching and Case Should case be ignored while searching?
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
search-forward
).
search-backward
).
To do a search on a buffer (whether typeout or a mail buffer), use C-s or C-r. Af will prompt you for the regular expression to search for, and then the search takes place. If no messages match the regular expression then the search will fail with an error.
A second search immediately after the first, will not match the current message, so repeated searches will move through all the messages which match the regular expression. To make this more convenient, the search expression is defaulted to the last one you entered.
The search commands with a numeric argument will only search the headers of the messages. This is often convenient when (for example) looking for messages which are from a particular person.
With a negative numeric argument the search commands will only search the bodies of the messages. This can be useful when (for example) looking for messages which mention your machine's host name (which is included in the headers of all messages).
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
tag-search-forward
).
tag-search-backward
). To search for a message matching a tag expression use C-t C-s or C-t C-r. Af will prompt you for the tag expression (see section 13.1.4 Tag Expressions) to search for; and then the search takes place. If no messages match the tag expression then the search will fail with an error.
Just as with regular expression searches, a second search immediately after the first, will not match the current message, so repeated searches will move through all the messages which match the tag expression. To make this more convenient, the search expression is defaulted to the last one you entered.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
As well as just searching for a regular expression and moving point to
the first matching message, af can tag all the messages which match a
regular expression. To do this use C-t s (search-and-tag
).
You will be prompted for the regular expression to search for, and the
tags to set on the matching messages (see section 13.2 Setting and Removing Tags). Once the
search has finished, af will report how many messages were tagged.
With a numeric argument this command will only search the headers of the messages. This is often convenient when (for example) looking for messages which are from a particular person or mailing list.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Regular expressions have a syntax in which a few characters are special constructs and the rest are ordinary. An ordinary character is a simple regular expression which matches that same character and nothing else. The special characters are `$', `^', `.', `*', `+', `?', `[', `]' and `\'. Any other character appearing in a regular expression is ordinary, unless a `\' precedes it.
For example, `f' is not a special character, so it is ordinary, and therefore `f' is a regular expression that matches the string `f' and no other string. (It does not match the string `ff'.) Likewise, `o' is a regular expression that matches only `o'. (When case distinctions are being ignored, these regular expressions also match `F' and `O', but we consider this a generalization of "the same string", rather than an exception.)
Any two regular expressions a and b can be concatenated. The result is a regular expression which matches a string if a matches some amount of the beginning of that string and b matches the rest of the string.
As a simple example, we can concatenate the regular expressions `f' and `o' to get the regular expression `fo', which matches only the string `fo'. Still trivial. To do something nontrivial, you need to use one of the special characters. Here is a list of them.
`*' always applies to the smallest possible preceding expression. Thus, `fo*' has a repeating `o', not a repeating `fo'. It matches `f', `fo', `foo', and so on.
Thus, `[ad]' matches either one `a' or one `d', and `[ad]*' matches any string composed of just `a's and `d's (including the empty string), from which it follows that `c[ad]*r' matches `cr', `car', `cdr', `caddaar', etc.
You can also include character ranges in a character set, by writing two characters with a `-' between them. Thus, `[a-z]' matches any lower-case letter. Ranges may be intermixed freely with individual characters, as in `[a-z$%.]', which matches any lower case letter or `$', `%' or `.'.
Note that the usual regex special characters are not special inside a character set. A completely different set of special characters exists inside character sets: `]', `-' and `^'.
To include a `]' in a character set, you must make it the first character. For example, `[]a]' matches `]' or `a'. To include a `-', write `-' as the first or last character of the set. Thus, `[]-]' matches both `]' and `-'.
To include `^', make it other than the first character in the set.
`^' is not special in a character set unless it is the first character. The character following the `^' is treated as if it were first (`-' and `]' are not special there).
Because `\' quotes special characters, `\$' is a regular expression which matches only `$', and `\[' is a regular expression which matches only `[', etc.
For the most part, `\' followed by any character matches only that character. However, there are several exceptions: two-character sequences starting with `\' which have special meanings. The second character in the sequence is always an ordinary character on its own. Here is a table of ``\'' constructs.
If you add a comma after the number of times the expression must be matched, then the expression must be matched at least as many times as you specified. So `ca\{2,\}r' will match the strings `caar', `caaar', `caaaar', and so on.
You can also add a maximum value after the comma, to specify a range of values. So `ca\{1,3\}r' will match only the strings `car', `caar' and `caaar'.
Thus, `foo\|bar' matches either `foo' or `bar' but no other string.
`\|' applies to the largest possible surrounding expressions. Only a surrounding `\( ... \)' grouping can limit the scope of `\|'.
For example, `\([a-z]\)\1' matches any two consecutive lower case characters. The `\([a-z]\)' matches any lower case character, while the `\1' must match the same character.
If a use of `\( ... \)' matches more than once, which often happens if it is followed by `*' or `+', only the last match is stored for use with `\N'.
Here is a moderately complicated regex, which you might use to find messages from the af-bug or af-user mailing lists.
^From:.*af-\(bug\|user\)@csv.warwick.ac.uk |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Searches in af normally ignore the case of the text they are searching through. Thus, if you specify searching for `foo', then `Foo' and `foo' are also considered a match. Regular expressions, and in particular character sets, are included: `[ab]' would match `a' or `A' or `b' or `B'.
If you set the variable case-fold-search
to false
, then
all letters must match exactly, including case.
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |