Next: , Previous: , Up: Actions   [Contents]

11.4 Attachment actions

Finally, let’s define an attachment action. As mentioned, attachment-action functions receive 2 arguments, the message and the attachment number to use.

The following example action counts the number of lines in an attachment, and defines n as its shortcut key (the n is prefixed to the description).

(defun count-lines-in-attachment (msg attachnum)
  "Count the number of lines in an attachment."
  (mu4e-view-pipe-attachment msg attachnum "wc -l"))

;; defining 'n' as the shortcut
(add-to-list 'mu4e-view-attachment-actions
  '("ncount lines" . count-lines-in-attachment) t)