Continuing my series of posts on using mu4e for emails in emacs, I wanted to duplicate the functionality of other email clients that warn you if you appear to have forgotten an attachment when you send an email.
My solution is decidedly lo-fi, but it does the trick. It is based on this post (coincidentally by the author of mu4e), which shows how to create highlighting for arbitrary keywords in emacs. This is a versatile trick and with the simple code below, any strings in a mu4e composition buffer that match “attach”, “pdf” or “file” get a nice red on yellow highlight.
;; attachment reminder based on ;; http://emacs-fu.blogspot.co.uk/2008/12/highlighting-todo-fixme-and-friends.html (set-face-attribute 'font-lock-warning-face nil :foreground "red" :weight 'bold :background "yellow") (add-hook 'mu4e-compose-mode-hook (defun bjm/mu4e-highlight-attachment () "Flag attachment keywords" (font-lock-add-keywords nil '(("\\(attach\\|pdf\\|file\\)" 1 font-lock-warning-face t)))))
It’s not pretty but it works for me! I’d prefer something that checked my email to see if it actually had an attachment and then warned me when I tried to send if there was no attachement there. I’ve not had time to work on that though, but if you know of anything similar, let me know!
There were some helpful suggestions in the comments for improved methods that prompt the user if they try to send a mail without an attachment. mbork has a nice clear example on their website.