Sometimes, the built-in functions to mark messages may not be sufficient for
your needs. For this, mu4e
offers an easy way to define your own custom
mark functions. You can choose one of the custom marker functions by pressing
& in the The headers view and The message view.
Custom mark functions are to be appended to the list
mu4e-headers-custom-markers
. Each of the elements of this list
(’markers’) is a list with two or three elements:
msg
and param
.
msg
is the message plist (see Message functions) and param
is
a parameter provided by the third of the marker elements (see the next
item). The predicate function should return non-nil
if the message
matches.
Let’s look at an example: suppose we want to match all messages that have more than n recipients — we could do this with the following recipe:
(add-to-list 'mu4e-headers-custom-markers '("More than n recipients" (lambda (msg n) (> (+ (length (mu4e-message-field msg :to)) (length (mu4e-message-field msg :cc))) n)) (lambda () (read-number "Match messages with more recipients than: "))) t)
After evaluating this expression, you can use it by pressing & in
the headers buffer to select a custom marker function, and then M
to choose this particular one (M
because it is the first character
of the description).
As you can see, it’s not very hard to define simple functions to match
messages. There are more examples in the defaults for
mu4e-headers-custom-markers
; see mu4e-headers.el and see
Extending mu4e for general information about writing your own functions.