Hi All,

Is there a way, in a save-hook, to match an email header with an
exact string match (not a regex) when the mail being saved is from
an IMAP mailbox? I am saving the messages to local mbox files, and
am using both the Mutt header cache and the Mutt message cache. I
would like for the exact string search to be made against data from
the local caches rather than on the remote IMAP server (which is
what '=h' does).

Context:

I am consolidating different Mutt configs into a multi-account
config that accesses both local inboxes (main mail spool and other
local mailboxes into which messages have been sifted) and remote
IMAP inboxes.

In a related effort, I am also in the process of moving some mailing
list subscriptions from an account whose messages are pulled down
down into the local mail spool to one in which that list traffic
will be delivered to one of the IMAP accounts.

My existing save-hook commands for these lists use the '=h' pattern
modifier, and generally look like this:

    save-hook '~L "\\<debian-emacsen@lists[.]debian[.]org\\>" =h "List-Id: 
<debian-emacsen.lists.debian.org>"' +debian-emacsen-%[%Y].gz

Those worked well when the config was using only the local mail
spool, and I'm sure my intent was to have the 'List-Id:' headers
match exactly. With IMAP, though, '=h' has special meaning, and the
search will be performed on the IMAP server.

<quote src="Mutt manual">
    You can force Mutt to treat EXPR as a simple string instead of a
    regular expression by using = instead of ~ in the pattern
    name. For example, =b *.* will find all messages that contain
    the literal string “*.*”. Simple string matches are less
    powerful than regular expressions but can be considerably
    faster.

    For IMAP folders, string matches =b, =B, and =h will be
    performed on the server instead of by fetching every
    message. IMAP treats =h specially: it must be of the form
    “header: substring” and will not partially match header
    names. The substring part may be omitted if you simply wish to
    find messages containing a particular header without regard to
    its value.
</quote>

I could rewrite the '=h' bits my save-hooks to work with '~h'
regexen:

    save-hook '~L "\\<debian-emacsen@lists[.]debian[.]org\\>" ~h 
"\\<list-id:[[:space:]].*[<]debian-emacsen[.]lists[.]debian[.]org[>]"' +debian-emacsen-%[%Y].gz

but if there's a way to say "match this specific literal header
string, using only locally available data", I'd be interested in
learning about it. I feel like I might be missing something obvious,
but I haven't been able to find it in the manual or via web
searches.

Thanks,
-Al

--
a l a n   d.   s a l e w s k i
ads@salewski.email
salew...@att.net
https://github.com/salewski

Reply via email to