changeset: 6474:6d733cab6b45
user:      Kevin McCarthy <[email protected]>
date:      Mon Jul 27 14:09:55 2015 -0700
link:      http://dev.mutt.org/hg/mutt/rev/6d733cab6b45

Add "Mailbox Matching in Hooks" section to manual.

Folder-hook and mbox-hook perform mailbox shortcut expansion on the
regexp parameter.  Add a section to the manual to give examples and make
the behavior clearer.

diffs (73 lines):

diff -r 21a08f9abc80 -r 6d733cab6b45 doc/manual.xml.head
--- a/doc/manual.xml.head       Sun Jul 26 14:48:53 2015 -0700
+++ b/doc/manual.xml.head       Mon Jul 27 14:09:55 2015 -0700
@@ -2423,6 +2423,12 @@
 executed in the order given in the <literal>.muttrc</literal>.
 </para>
 
+<para>
+The regexp parameter has <link linkend="shortcuts">mailbox
+shortcut</link> expansion performed on the first character.
+See  <xref linkend="mailbox-hook"/> for more details.
+</para>
+
 <note>
 <para>
 If you use the <quote>!</quote> shortcut for <link
@@ -3203,6 +3209,12 @@
 </para>
 
 <para>
+The regexp parameter has <link linkend="shortcuts">mailbox
+shortcut</link> expansion performed on the first character.
+See  <xref linkend="mailbox-hook"/> for more details.
+</para>
+
+<para>
 Unlike some of the other <emphasis>hook</emphasis> commands, only the
 <emphasis>first</emphasis> matching regexp is used (it is not possible
 to save read mail in more than a single mailbox).
@@ -5575,6 +5587,43 @@
 
 </sect2>
 
+<sect2 id="mailbox-hook" xreflabel="Mailbox Matching in Hooks">
+<title>Mailbox Matching in Hooks</title>
+
+<para>
+Hooks that match against mailboxes (<command>folder-hook</command>,
+<command>mbox-hook</command>) apply both <link linkend="regexp">regular
+expression</link> syntax as well as <link linkend="shortcuts">mailbox
+shortcut</link> expansion on the regexp parameter.  There is some
+overlap between these, so special attention should be paid to the first
+character of the regexp.
+</para>
+
+<screen>
+# Here, ^ will expand to "the current mailbox" not "beginning of string":
+folder-hook ^/home/user/Mail/bar "set sort=threads"
+
+# If you want ^ to be interpreted as "beginning of string", one workaround
+# is to enclose the regexp in parenthesis:
+folder-hook (^/home/user/Mail/bar) "set sort=threads"
+
+# This will expand to the default save folder for the alias 
"imap.example.com", which
+# is probably not what you want:
+folder-hook @imap.example.com "set sort=threads"
+
+# A workaround is to use parenthesis or a backslash:
+folder-hook (@imap.example.com) "set sort=threads"
+folder-hook \@imap.example.com "set sort=threads"
+</screen>
+
+<para>
+Keep in mind that mailbox shortcut expansion on the regexp parameter
+takes place when the hook is initially parsed, not when the hook is
+matching against a mailbox.
+</para>
+
+</sect2>
+
 </sect1>
 
 <sect1 id="query">

Reply via email to