📄 advancedusage.html
字号:
</p></li></ul></div><p></p><p>Here is an example illustrating a complex search pattern. This pattern willselect all messages which do not contain ``mutt'' in the ``To'' or ``Cc''field and which are from ``elkins''.</p><p></p><pre class="screen">!(~t mutt|~c mutt) ~f elkins</pre><p></p><p>Here is an example using white space in the regular expression (notethe ' and " delimiters). For this to match, the mail's subject mustmatch the ``^Junk +From +Me$'' and it must be from either ``Jim +Somebody''or ``Ed +SomeoneElse'':</p><p></p><pre class="screen"> '~s "^Junk +From +Me$" ~f ("Jim +Somebody"|"Ed +SomeoneElse")'</pre><p></p><p>Note that if a regular expression contains parenthesis, or a vertical bar("|"), you <span class="bold"><strong>must</strong></span> enclose the expression in double or single quotes sincethose characters are also used to separate different parts of Mutt'spattern language. For example,</p><p></p><pre class="screen">~f "me@(mutt\.org|cs\.hmc\.edu)"</pre><p></p><p>Without the quotes, the parenthesis wouldn't end.This would be seperated to two OR'd patterns: <span class="emphasis"><em>藴f me@(mutt\.org</em></span>and <span class="emphasis"><em>cs\.hmc\.edu)</em></span>. They are never what you want.</p></div><div class="sect2" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title"><a id="id2685873"></a>2.3.聽Searching by Date</h3></div></div></div><p>Mutt supports two types of dates, <span class="emphasis"><em>absolute</em></span> and <span class="emphasis"><em>relative</em></span>.</p><p><span class="bold"><strong>Absolute</strong></span>. Dates <span class="bold"><strong>must</strong></span> be in DD/MM/YY format (month and year areoptional, defaulting to the current month and year). An example of a validrange of dates is:</p><p></p><pre class="screen">Limit to messages matching: ~d 20/1/95-31/10</pre><p></p><p>If you omit the minimum (first) date, and just specify ``-DD/MM/YY'', allmessages <span class="emphasis"><em>before</em></span> the given date will be selected. If you omit the maximum(second) date, and specify ``DD/MM/YY-'', all messages <span class="emphasis"><em>after</em></span> the givendate will be selected. If you specify a single date with no dash (``-''),only messages sent on the given date will be selected. </p><p><span class="bold"><strong>Error Margins</strong></span>. You can add error margins to absolute dates.An error margin is a sign (+ or -), followed by a digit, followed byone of the following units:</p><pre class="screen">y yearsm monthsw weeksd days</pre><p>As a special case, you can replace the sign by a ``*'' character,which is equivalent to giving identical plus and minus error margins.</p><p>Example: To select any messages two weeks around January 15, 2001,you'd use the following pattern: </p><pre class="screen"> Limit to messages matching: ~d 15/1/2001*2w</pre><p></p><p><span class="bold"><strong>Relative</strong></span>. This type of date is relative to the current date, and maybe specified as:</p><div class="itemizedlist"><ul type="disc"><li><p>><span class="emphasis"><em>offset</em></span> (messages older than <span class="emphasis"><em>offset</em></span> units)</p></li><li><p><<span class="emphasis"><em>offset</em></span> (messages newer than <span class="emphasis"><em>offset</em></span> units)</p></li><li><p>=<span class="emphasis"><em>offset</em></span> (messages exactly <span class="emphasis"><em>offset</em></span> units old)</p></li></ul></div><p></p><p><span class="emphasis"><em>offset</em></span> is specified as a positive number with one of the followingunits:</p><pre class="screen">y yearsm monthsw weeksd days</pre><p></p><p>Example: to select messages less than 1 month old, you would use</p><pre class="screen">Limit to messages matching: ~d <1m</pre><p></p><p><span class="bold"><strong>Note:</strong></span> all dates used when searching are relative to the<span class="bold"><strong>local</strong></span> time zone, so unless you change the setting of your <a href="reference.html#index-format" title="3.95.聽index_format">$index_format</a> to include a<code class="literal">%[...]</code> format, these are <span class="bold"><strong>not</strong></span> the dates shownin the main index.</p></div></div><div class="sect1" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="tags"></a>3.聽Using Tags</h2></div></div></div><p>Sometimes it is desirable to perform an operation on a group ofmessages all at once rather than one at a time. An example might beto save messages to a mailing list to a separate folder, or todelete all messages with a given subject. To tag all messagesmatching a pattern, use the tag-pattern function, which is bound to``shift-T'' by default. Or you can select individual messages byhand using the ``tag-message'' function, which is bound to ``t'' bydefault. See <a href="advancedusage.html#patterns" title="2.聽Patterns">patterns</a> for Mutt's patternmatching syntax.</p><p>Once you have tagged the desired messages, you can use the``tag-prefix'' operator, which is the ``;'' (semicolon) key by default.When the ``tag-prefix'' operator is used, the <span class="bold"><strong>next</strong></span> operation willbe applied to all tagged messages if that operation can be used in thatmanner. If the <a href="reference.html#auto-tag" title="3.16.聽auto_tag">$auto_tag</a>variable is set, the next operation applies to the tagged messagesautomatically, without requiring the ``tag-prefix''.</p><p>In <a href="configuration.html#macro" title="6.聽Keyboard macros">macros</a> or <a href="configuration.html#push" title="21.聽Adding key sequences to the keyboard buffer">push</a> commands,you can use the ``tag-prefix-cond'' operator. If there are no taggedmessages, mutt will "eat" the rest of the macro to abort it's execution.Mutt will stop "eating" the macro when it encounters the ``end-cond''operator; after this operator the rest of the macro will be executed asnormal.</p></div><div class="sect1" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="hooks"></a>4.聽Using Hooks</h2></div></div></div><p>A <span class="emphasis"><em>hook</em></span> is a concept borrowed from the EMACS editor which allows you toexecute arbitrary commands before performing some operation. For example,you may wish to tailor your configuration based upon which mailbox you arereading, or to whom you are sending mail. In the Mutt world, a <span class="emphasis"><em>hook</em></span>consists of a <a href="advancedusage.html#regexp" title="1.聽Regular Expressions">regular expression</a> or<a href="advancedusage.html#patterns" title="2.聽Patterns">pattern</a> along with aconfiguration option/command. See</p><div class="itemizedlist"><ul type="disc"><li><p><a href="configuration.html#folder-hook" title="5.聽Setting variables based upon mailbox">folder-hook</a></p></li><li><p><a href="configuration.html#send-hook" title="18.聽Change settings based upon message recipients">send-hook</a></p></li><li><p><a href="configuration.html#message-hook" title="19.聽Change settings before formatting a message">message-hook</a></p></li><li><p><a href="configuration.html#save-hook" title="15.聽Specify default save filename">save-hook</a></p></li><li><p><a href="configuration.html#mbox-hook" title="11.聽Using Multiple spool mailboxes">mbox-hook</a></p></li><li><p><a href="configuration.html#fcc-hook" title="16.聽Specify default Fcc: mailbox when composing">fcc-hook</a></p></li><li><p><a href="configuration.html#fcc-save-hook" title="17.聽Specify default save filename and default Fcc: mailbox at once">fcc-save-hook</a></p></li></ul></div><p>for specific details on each type of <span class="emphasis"><em>hook</em></span> available.</p><p><span class="bold"><strong>Note:</strong></span> if a hook changes configuration settings, these changes remaineffective until the end of the current mutt session. As this is generallynot desired, a default hook needs to be added before all other hooks torestore configuration defaults. Here is an example with send-hook and themy_hdr directive:</p><p></p><pre class="screen">send-hook . 'unmy_hdr From:'send-hook ~C'^b@b\.b$' my_hdr from: c@c.c</pre><p></p><div class="sect2" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title"><a id="pattern-hook"></a>4.1.聽Message Matching in Hooks</h3></div></div></div><p>Hooks that act upon messages (<code class="literal">send-hook, save-hook, fcc-hook,message-hook</code>) are evaluated in a slightly different manner. For the othertypes of hooks, a <a href="advancedusage.html#regexp" title="1.聽Regular Expressions">regular expression</a> issufficient. But in dealing with messages a finer grain of control isneeded for matching since for different purposes you want to matchdifferent criteria.</p><p>Mutt allows the use of the <a href="advancedusage.html#patterns" title="2.聽Patterns">search pattern</a>language for matching messages in hook commands. This works inexactly the same way as it would when <span class="emphasis"><em>limiting</em></span> or<span class="emphasis"><em>searching</em></span> the mailbox, except that you are restricted to thoseoperators which match information mutt extracts from the header ofthe message (i.e. from, to, cc, date, subject, etc.).</p><p>For example, if you wanted to set your return address based upon sendingmail to a specific address, you could do something like:</p><pre class="screen">send-hook '~t ^me@cs\.hmc\.edu$' 'my_hdr From: Mutt User <user@host>'</pre><p>which would execute the given command when sending mail to<span class="emphasis"><em>me@cs.hmc.edu</em></span>.</p><p>However, it is not required that you write the pattern to match using thefull searching language. You can still specify a simple <span class="emphasis"><em>regularexpression</em></span> like the other hooks, in which case Mutt will translate yourpattern into the full language, using the translation specified by the <a href="reference.html#default-hook" title="3.37.聽default_hook">$default_hook</a> variable. Thepattern is translated at the time the hook is declared, so the value of <a href="reference.html#default-hook" title="3.37.聽default_hook">$default_hook</a> that is in effectat that time will be used.</p></div></div><div class="sect1" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="query"></a>5.聽External Address Queries</h2></div></div></div><p>Mutt supports connecting to external directory databases such as LDAP,ph/qi, bbdb, or NIS through a wrapper script which connects to muttusing a simple interface. Using the <a href="reference.html#query-command" title="3.224.聽query_command">$query_command</a> variable, you specify the wrappercommand to use. For example:</p><p></p><pre class="screen">set query_command = "mutt_ldap_query.pl '%s'"</pre><p></p><p>The wrapper script should accept the query on the command-line. Itshould return a one line message, then each matching response on a
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -