Customize MU4E action marks with unicode emojis

posted on 2022-01-23

MU4E exposes set of variables to customize how messaeg flags are displayed and as Emacs got color emoji support1 it is quite easy to utilize them for some „eye-candy”:

(setq mu4e-headers-unread-mark    '("u" . "📩 ")
      mu4e-headers-draft-mark     '("D" . "🚧 ")
      mu4e-headers-flagged-mark   '("F" . "🚩 ")
      mu4e-headers-new-mark       '("N" . "✨ ")
      mu4e-headers-passed-mark    '("P" . "⤵ ")
      mu4e-headers-replied-mark   '("R" . "⤴ ")
      mu4e-headers-seen-mark      '("S" . " ")
      mu4e-headers-trashed-mark   '("T" . "🗑️ ")
      mu4e-headers-attach-mark    '("a" . "📎 ")
      mu4e-headers-encrypted-mark '("x" . "🔐 ")
      mu4e-headers-signed-mark    '("s" . "🔏 "))

But marks used to indicate actions like deleting the message or refiling (archiving) doesn’t got such easily accessible customization. They are kept in an assosiative list so we can create a wrapper function to redefine them:

(defun set-mu4e-mark-pretty-char (mark new-char)
  (let ((new-char-tuple  (cons
                          (car (plist-get (alist-get mark mu4e-marks)
                                          :char))
                          new-char)))
    (setf (alist-get mark mu4e-marks)
          (plist-put (alist-get mark mu4e-marks)
                     :char new-char-tuple))))

And with that we can define our emoji-powered action marks for all available actions:

(set-mu4e-mark-pretty-char 'trash    "🗑")
(set-mu4e-mark-pretty-char 'untrash  "📥")
(set-mu4e-mark-pretty-char 'refile   "🗃")
(set-mu4e-mark-pretty-char 'delete   "♻")
(set-mu4e-mark-pretty-char 'undelete "📥")
(set-mu4e-mark-pretty-char 'flag     "🚩")
(set-mu4e-mark-pretty-char 'unflag   "🏴")
(set-mu4e-mark-pretty-char 'read     "✉")
(set-mu4e-mark-pretty-char 'unread   "📩")
(set-mu4e-mark-pretty-char 'move     "🔃")
(set-mu4e-mark-pretty-char 'action   "🏃")

Happy hacking!

Footnotes:

1

version 28 or one built from git’s master branch.