On 2015-07-21 10:15 +0200, Michael Tatge wrote:

> folder-hooks use substring matches.

Unanchored regexp matches, to be more precise.

> ^ is a shortcut for the current mailbox. It's not BOL here.

Do you see how these 2 facts together make it hard to construct a
meaningful pattern, if you're worried about matches at different places
in the filesystem?  It's not your fault of course, unless you're a mutt
dev :-)

What I ended up doing (after spending several days patching the source
with debug prints just to understand WTH was happening) was:

folder-hook .*^/home/itz/foo/.* "my_hdr X-itz-real-home-foo: yes"

taking advantage of the fact that mutt's special handling of ^ (and
other folder "shortcuts") only applies in the 0th position, after that
it retains its regexp BOL meaning.

Oh and BTW, in this case:

folder-hook ^foo "my_hdr X-itz-real-home-foo: yes"

^ is _not_ replaced with /home/itz/foo, /home/itz/inbox, or anything
like that, but with the empty string.  That is because the statement is
parsed at startup time, before any current folder is established.

I feel this thicket of gotchas really deserves a few paragraphs in the
manual.

Thanks for replying!

-- 
Please *no* private copies of mailing list or newsgroup messages.
Rule 420: All persons more than eight miles high to leave the court.

Reply via email to