📄 advancedusage.html
字号:
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Chapter聽4.聽Advanced Usage</title><meta name="generator" content="DocBook XSL Stylesheets V1.68.1" /><link rel="start" href="index.html" title="The Mutt E-Mail Client" /><link rel="up" href="index.html" title="The Mutt E-Mail Client" /><link rel="prev" href="configuration.html" title="Chapter聽3.聽Configuration" /><link rel="next" href="mimesupport.html" title="Chapter聽5.聽Mutt's MIME Support" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter聽4.聽Advanced Usage</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="configuration.html">Prev</a>聽</td><th width="60%" align="center">聽</th><td width="20%" align="right">聽<a accesskey="n" href="mimesupport.html">Next</a></td></tr></table><hr /></div><div class="chapter" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title"><a id="advancedusage"></a>Chapter聽4.聽Advanced Usage</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="advancedusage.html#regexp">1. Regular Expressions</a></span></dt><dt><span class="sect1"><a href="advancedusage.html#patterns">2. Patterns</a></span></dt><dd><dl><dt><span class="sect2"><a href="advancedusage.html#id2685716">2.1. Pattern Modifier</a></span></dt><dt><span class="sect2"><a href="advancedusage.html#id2685740">2.2. Complex Patterns</a></span></dt><dt><span class="sect2"><a href="advancedusage.html#id2685873">2.3. Searching by Date</a></span></dt></dl></dd><dt><span class="sect1"><a href="advancedusage.html#tags">3. Using Tags</a></span></dt><dt><span class="sect1"><a href="advancedusage.html#hooks">4. Using Hooks</a></span></dt><dd><dl><dt><span class="sect2"><a href="advancedusage.html#pattern-hook">4.1. Message Matching in Hooks</a></span></dt></dl></dd><dt><span class="sect1"><a href="advancedusage.html#query">5. External Address Queries</a></span></dt><dt><span class="sect1"><a href="advancedusage.html#mailbox-formats">6. Mailbox Formats</a></span></dt><dt><span class="sect1"><a href="advancedusage.html#shortcuts">7. Mailbox Shortcuts</a></span></dt><dt><span class="sect1"><a href="advancedusage.html#using-lists">8. Handling Mailing Lists</a></span></dt><dt><span class="sect1"><a href="advancedusage.html#editing-threads">9. Editing threads</a></span></dt><dd><dl><dt><span class="sect2"><a href="advancedusage.html#id2687015">9.1. Linking threads</a></span></dt><dt><span class="sect2"><a href="advancedusage.html#id2687044">9.2. Breaking threads</a></span></dt></dl></dd><dt><span class="sect1"><a href="advancedusage.html#dsn">10. Delivery Status Notification (DSN) Support</a></span></dt><dt><span class="sect1"><a href="advancedusage.html#pop">11. POP3 Support (OPTIONAL)</a></span></dt><dt><span class="sect1"><a href="advancedusage.html#imap">12. IMAP Support (OPTIONAL)</a></span></dt><dd><dl><dt><span class="sect2"><a href="advancedusage.html#id2687412">12.1. The Folder Browser</a></span></dt><dt><span class="sect2"><a href="advancedusage.html#id2687534">12.2. Authentication</a></span></dt></dl></dd><dt><span class="sect1"><a href="advancedusage.html#account-hook">13. Managing multiple IMAP/POP accounts (OPTIONAL)</a></span></dt><dt><span class="sect1"><a href="advancedusage.html#urlview">14. Start a WWW Browser on URLs (EXTERNAL)</a></span></dt><dt><span class="sect1"><a href="advancedusage.html#caching">15. Local caching (OPTIONAL)</a></span></dt><dd><dl><dt><span class="sect2"><a href="advancedusage.html#id2687751">15.1. Header caching</a></span></dt><dt><span class="sect2"><a href="advancedusage.html#id2687829">15.2. Body caching</a></span></dt></dl></dd></dl></div><div class="sect1" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="regexp"></a>1.聽Regular Expressions</h2></div></div></div><p>All string patterns in Mutt including those in more complex<a href="advancedusage.html#patterns" title="2.聽Patterns">patterns</a> must be specifiedusing regular expressions (regexp) in the ``POSIX extended'' syntax (whichis more or less the syntax used by egrep and GNU awk). For yourconvenience, we have included below a brief description of this syntax.</p><p>The search is case sensitive if the pattern contains at least one uppercase letter, and case insensitive otherwise. Note that ``\''must be quoted if used for a regular expression in an initializationcommand: ``\\''.</p><p>A regular expression is a pattern that describes a set of strings.Regular expressions are constructed analogously to arithmeticexpressions, by using various operators to combine smaller expressions.</p><p>Note that the regular expression can be enclosed/delimited by either "or ' which is useful if the regular expression includes a white-spacecharacter. See <a href="configuration.html#muttrc-syntax">Syntax of Initialization Files</a>for more information on " and ' delimiter processing. To match aliteral " or ' you must preface it with \ (backslash).</p><p>The fundamental building blocks are the regular expressions that matcha single character. Most characters, including all letters and digits,are regular expressions that match themselves. Any metacharacter withspecial meaning may be quoted by preceding it with a backslash.</p><p>The period ``.'' matches any single character. The caret ``^'' andthe dollar sign ``$'' are metacharacters that respectively matchthe empty string at the beginning and end of a line.</p><p>A list of characters enclosed by ``['' and ``]'' matches anysingle character in that list; if the first character of the listis a caret ``^'' then it matches any character <span class="bold"><strong>not</strong></span> in thelist. For example, the regular expression <span class="bold"><strong>[0123456789]</strong></span>matches any single digit. A range of ASCII characters may be specifiedby giving the first and last characters, separated by a hyphen``-''. Most metacharacters lose their special meaning insidelists. To include a literal ``]'' place it first in the list.Similarly, to include a literal ``^'' place it anywhere but first.Finally, to include a literal hyphen ``-'' place it last.</p><p>Certain named classes of characters are predefined. Character classesconsist of ``[:'', a keyword denoting the class, and ``:]''.The following classes are defined by the POSIX standard:</p><p></p><div class="variablelist"><dl><dt><span class="term">[:alnum:]</span></dt><dd><p>Alphanumeric characters.</p></dd><dt><span class="term">[:alpha:]</span></dt><dd><p>Alphabetic characters.</p></dd><dt><span class="term">[:blank:]</span></dt><dd><p>Space or tab characters.</p></dd><dt><span class="term">[:cntrl:]</span></dt><dd><p>Control characters.</p></dd><dt><span class="term">[:digit:]</span></dt><dd><p>Numeric characters.</p></dd><dt><span class="term">[:graph:]</span></dt><dd><p>Characters that are both printable and visible. (A space is printable,but not visible, while an ``a'' is both.)</p></dd><dt><span class="term">[:lower:]</span></dt><dd><p>Lower-case alphabetic characters.</p></dd><dt><span class="term">[:print:]</span></dt><dd><p>Printable characters (characters that are not control characters.)</p></dd><dt><span class="term">[:punct:]</span></dt><dd><p>Punctuation characters (characters that are not letter, digits, controlcharacters, or space characters).</p></dd><dt><span class="term">[:space:]</span></dt><dd><p>Space characters (such as space, tab and formfeed, to name a few).</p></dd><dt><span class="term">[:upper:]</span></dt><dd><p>Upper-case alphabetic characters.</p></dd><dt><span class="term">[:xdigit:]</span></dt><dd><p>Characters that are hexadecimal digits.</p></dd></dl></div><p></p><p>A character class is only valid in a regular expression inside thebrackets of a character list. Note that the brackets in theseclass names are part of the symbolic names, and must be includedin addition to the brackets delimiting the bracket list. Forexample, <span class="bold"><strong>[[:digit:]]</strong></span> is equivalent to<span class="bold"><strong>[0-9]</strong></span>.</p><p>Two additional special sequences can appear in character lists. Theseapply to non-ASCII character sets, which can have single symbols (calledcollating elements) that are represented with more than one character,as well as several characters that are equivalent for collating orsorting purposes:</p><p></p><div class="variablelist"><dl><dt><span class="term">Collating Symbols</span></dt><dd><p>A collating symbol is a multi-character collating element enclosed in``[.'' and ``.]''. For example, if ``ch'' is a collatingelement, then <span class="bold"><strong>[[.ch.]]</strong></span> is a regexp that matchesthis collating element, while <span class="bold"><strong>[ch]</strong></span> is a regexp thatmatches either ``c'' or ``h''.</p></dd><dt><span class="term">Equivalence Classes</span></dt><dd><p>An equivalence class is a locale-specific name for a list ofcharacters that are equivalent. The name is enclosed in ``[=''and ``=]''. For example, the name ``e'' might be used torepresent all of ``猫'' ``茅'' and ``e''. In this case,<span class="bold"><strong>[[=e=]]</strong></span> is a regexp that matches any of``猫'', ``茅'' and ``e''.</p></dd></dl></div><p></p><p>A regular expression matching a single character may be followed by oneof several repetition operators:</p><p></p><div class="variablelist"><dl><dt><span class="term">?</span></dt><dd><p>The preceding item is optional and matched at most once.</p></dd><dt><span class="term">*</span></dt><dd><p>The preceding item will be matched zero or more times.</p></dd><dt><span class="term">+</span></dt><dd><p>The preceding item will be matched one or more times.</p></dd><dt><span class="term">{n}</span></dt><dd><p>The preceding item is matched exactly <span class="emphasis"><em>n</em></span> times.</p></dd><dt><span class="term">{n,}</span></dt><dd><p>The preceding item is matched <span class="emphasis"><em>n</em></span> or more times.</p></dd><dt><span class="term">{,m}</span></dt><dd><p>The preceding item is matched at most <span class="emphasis"><em>m</em></span> times.</p></dd><dt><span class="term">{n,m}</span></dt><dd><p>The preceding item is matched at least <span class="emphasis"><em>n</em></span> times, but no more than<span class="emphasis"><em>m</em></span> times.</p></dd></dl></div><p></p><p>Two regular expressions may be concatenated; the resulting regularexpression matches any string formed by concatenating two substringsthat respectively match the concatenated subexpressions.</p><p>Two regular expressions may be joined by the infix operator ``|'';the resulting regular expression matches any string matching eithersubexpression.</p><p>Repetition takes precedence over concatenation, which in turn takesprecedence over alternation. A whole subexpression may be enclosed inparentheses to override these precedence rules.</p><p><span class="bold"><strong>Note:</strong></span> If you compile Mutt with the GNU <span class="emphasis"><em>rx</em></span> package, thefollowing operators may also be used in regular expressions:</p><p></p><div class="variablelist"><dl><dt><span class="term">\\y</span></dt><dd><p>Matches the empty string at either the beginning or the end of a word.</p></dd><dt><span class="term">\\B</span></dt><dd><p>Matches the empty string within a word.</p></dd><dt><span class="term">\\<</span></dt><dd><p>Matches the empty string at the beginning of a word.</p></dd><dt><span class="term">\\></span></dt><dd><p>Matches the empty string at the end of a word.</p></dd><dt><span class="term">\\w</span></dt><dd><p>Matches any word-constituent character (letter, digit, or underscore).</p></dd><dt><span class="term">\\W</span></dt><dd><p>Matches any character that is not word-constituent.</p></dd><dt><span class="term">\\`</span></dt><dd><p>Matches the empty string at the beginning of a buffer (string).</p></dd><dt><span class="term">\\'</span></dt><dd><p>Matches the empty string at the end of a buffer.</p></dd></dl></div><p></p><p>Please note however that these operators are not defined by POSIX, sothey may or may not be available in stock libraries on various systems.</p></div><div class="sect1" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="patterns"></a>2.聽Patterns</h2></div></div></div><p>Many of Mutt's commands allow you to specify a pattern to match(limit, tag-pattern, delete-pattern, etc.). There are several ways to selectmessages:</p><p></p><div class="table"><a id="id2685320"></a><p class="title"><b>Table聽4.1.聽Pattern modifiers</b></p><table summary="Pattern modifiers" border="1"><colgroup><col /><col /></colgroup><thead><tr><th>Pattern modifier</th><th>Description</th></tr></thead><tbody><tr><td>~A</td><td>all messages</td></tr><tr><td>~b EXPR</td><td>messages which contain EXPR in the message body</td></tr><tr><td>~B EXPR</td><td>messages which contain EXPR in the whole message</td></tr><tr><td>~c EXPR</td><td>messages carbon-copied to EXPR</td></tr><tr><td>~C EXPR</td><td>message is either to: or cc: EXPR</td></tr><tr><td>~d [MIN]-[MAX]</td><td>messages with ``date-sent'' in a Date range</td></tr><tr><td>~D</td><td>deleted messages</td></tr><tr><td>~e EXPR</td><td>message which contains EXPR in the ``Sender'' field</td></tr><tr><td>~E</td><td>expired messages</td></tr><tr><td>~F</td><td>flagged messages</td></tr><tr><td>~f EXPR</td><td>messages originating from EXPR</td></tr><tr><td>~g</td><td>cryptographically signed messages</td></tr><tr><td>~G</td><td>cryptographically encrypted messages</td></tr><tr><td>~h EXPR</td><td>messages which contain EXPR in the message header</td></tr><tr><td>~H EXPR</td><td>messages with a spam attribute matching EXPR</td></tr><tr><td>~i EXPR</td><td>message which match EXPR in the ``Message-ID'' field</td></tr><tr><td>~k</td><td>message contains PGP key material</td></tr><tr><td>~L EXPR</td><td>message is either originated or received by EXPR</td></tr><tr><td>~l</td><td>message is addressed to a known mailing list</td></tr><tr><td>~m [MIN]-[MAX]</td><td>message in the range MIN to MAX *)</td></tr><tr><td>~n [MIN]-[MAX]</td><td>messages with a score in the range MIN to MAX *)</td></tr><tr><td>~N</td><td>new messages</td></tr><tr><td>~O</td><td>old messages</td></tr><tr><td>~p</td><td>message is addressed to you (consults alternates)</td></tr><tr><td>~P</td><td>message is from you (consults alternates)</td></tr><tr><td>~Q</td><td>messages which have been replied to</td></tr><tr><td>~r [MIN]-[MAX]</td><td>messages with ``date-received'' in a Date range</td></tr><tr><td>~R</td><td>read messages</td></tr><tr><td>~s EXPR</td><td>messages having EXPR in the ``Subject'' field.</td></tr><tr><td>~S</td><td>superseded messages</td></tr><tr><td>~t EXPR</td><td>messages addressed to EXPR</td></tr><tr><td>~T</td><td>tagged messages</td></tr><tr><td>~u</td><td>message is addressed to a subscribed mailing list</td></tr><tr><td>~U</td><td>unread messages</td></tr><tr><td>~v</td><td>message is part of a collapsed thread.</td></tr><tr><td>~V</td><td>cryptographically verified messages</td></tr><tr><td>~x EXPR</td><td>messages which contain EXPR in the `References' field</td></tr><tr><td>~X [MIN]-[MAX]</td><td>messages with MIN to MAX attachments *)</td></tr><tr><td>~y EXPR</td><td>messages which contain EXPR in the `X-Label' field</td></tr><tr><td>~z [MIN]-[MAX]</td><td>messages with a size in the range MIN to MAX *)</td></tr><tr><td>~=</td><td>duplicated messages (see $duplicate_threads)</td></tr><tr><td>~$</td><td>unreferenced messages (requires threaded view)</td></tr></tbody></table></div><p></p><p>Where EXPR is a<a href="advancedusage.html#regexp" title="1.聽Regular Expressions">regular expression</a>. Special attention has to bemade when using regular expressions inside of patterns. Specifically,Mutt's parser for these patterns will strip one level of backslash (\),which is normally used for quoting. If it is your intention to use abackslash in the regular expression, you will need to use two backslashesinstead (\\). You can force mutt to treat EXPR as a simple stringinstead of a regular expression by using = instead of 藴 in thepattern name. For example, =b *.* will find all messages that containthe literal string '*.*'. Simple string matches are less powerful thanregular expressions but can be considerably faster. This is especiallytrue for IMAP folders, because string matches can be performed on theserver instead of by fetching every message. IMAP treats =h specially:it must be of the form "header: substring" and will not partiallymatch header names. The substring part may be omitted if you simplywish to find messages containing a particular header without regard toits value.</p><p>*) The forms <code class="literal"><[MAX]</code>, <code class="literal">>[MIN]</code>,<code class="literal">[MIN]-</code> and <code class="literal">-[MAX]</code>are allowed, too.</p><div class="sect2" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title"><a id="id2685716"></a>2.1.聽Pattern Modifier</h3></div></div></div><p>Note that patterns matching 'lists' of addresses (notably c,C,p,P and t)match if there is at least one match in the whole list. If you want tomake sure that all elements of that list match, you need to prefix yourpattern with ^.This example matches all mails which only has recipients from Germany.</p><p></p><pre class="screen">^~C \.de$</pre><p></p></div><div class="sect2" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title"><a id="id2685740"></a>2.2.聽Complex Patterns</h3></div></div></div><p>Logical AND is performed by specifying more than one criterion. Forexample:</p><p></p><pre class="screen">~t mutt ~f elkins</pre><p></p><p>would select messages which contain the word ``mutt'' in the list ofrecipients <span class="bold"><strong>and</strong></span> that have the word ``elkins'' in the ``From'' headerfield.</p><p>Mutt also recognizes the following operators to create more complex searchpatterns:</p><p></p><div class="itemizedlist"><ul type="disc"><li><p>! -- logical NOT operator</p></li><li><p>| -- logical OR operator</p></li><li><p>() -- logical grouping operator
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -