Next: , Up: Actions   [Contents]

11.1 Defining actions

Defining a new custom action comes down to writing an elisp-function to do the work. Functions that operate on messages receive a msg parameter, which corresponds to the message at point. Something like:

  (defun my-action-func (msg)
  "Describe my message function."
  ;; do stuff

Messages that operate on attachments receive a msg parameter, which corresponds to the message at point, and an attachment-num, which is the number of the attachment as seen in the message view. An attachment function looks like:

  (defun my-attachment-action-func (msg attachment-num)
  "Describe my attachment function."
  ;; do stuff

After you have defined your function, you can add it to the list of actions35, either mu4e-headers-actions, mu4e-view-actions or mu4e-view-attachment-actions. The format36 of each action is a cons-cell, (DESCRIPTION . VALUE); see below for some examples. If your shortcut is not also the first character of the description, simply prefix the description with that character.

Let’s look at some examples.



Instead of defining the functions separately, you can obviously also add a lambda-function directly to the list; however, separate functions are easier to change


Note, the format of the actions has changed since version, and you must change your configuration to use the new format; mu4e warns you when you are using the old format.