Hi guys, I've got Mutt configured to use two Maildir accounts, synced using offlineimap.
This is done using folder hooks. Part of this setup is as follows: # --- Begin set mbox_type = Maildir set folder = ~/.maildb set spoolfile = +/SitePoint/INBOX folder-hook +SitePoint.* set from = "adam.bo...@sitepoint.com" folder-hook +SitePoint.* my_hdr From: Adam Bolte <adam.bo...@sitepoint.com> set smtp_url = "smtp://smtp.server/ folder-hook +GMail.* set from = "otherm...@gmail.com" folder-hook +GMail.* my_hdr From: Adam Bolte <otherm...@gmail.com> folder-hook +GMail.* set smtp_url = "smtp://othersmtp.server/" # --- End I use more folder-hooks and options than shown above, but you get the idea. Now my problem: I want my SitePoint signature to be automatically inserted into my editor whenever I send mail or reply to a message in my SitePoint folder, but not when sending from the other personal account. I also don't want to have the signature inserted if replying to an e-mail thread that already has my signature. It saves me manually deleting it. To accomplish this, I've tried the following: # --- Begin # Signatures are set by default for new messages folder-hook +SitePoint.* "set signature = "~/.mutt/signature-SitePoint"" folder-hook +SitePoint.* "reply-hook \"! ~b '^[[:space:]\>]*Adam Bolte$'\" set signature = \"~/.mutt/signature-SitePoint\"" # But we don't use them if it appears it's been posted before. folder-hook +SitePoint.* "reply-hook \"~b '^[[:space:]\>]*Adam Bolte$'\" unset signature" folder-hook +GMail.* "unset signature" # --- End I'm making the assumption that if my full name appears on any line by itself in part of the thread, my signature has been previously included. This search works as expected over 99% of the time. The real problem with the above comes from the following usage scenario: 1. Reply to a mail that has already had my e-mail signature used, thus having my signature unset. 2. Writing a new mail in the same folder. Since I did not change folders, the folder-hook doesn't run and the signature remains unset. Ideally, I would be able to set a hook when creating a new mail from scratch - something like "new-hook". I've tried investigating send-hook, but it only runs after folder-hook, not before (thus clobbering folder-hook). Further, I still need folder-hook for when replying to messages since ~b doesn't exist in send-hook (presumably because if sending a new message, no message body would already exist). I don't see a way to make this work. Does anyone have any idea how I can trigger a hook *only* when writing a new message? Maybe there's a patch floating around that I should know about? Thanks, Adam -- Adam Bolte SitePoint Pty. Ltd. www.sitepoint.com