It is possible to configure new marks. To do so, one can add entries
in the list mu4e-marks
. Such an element must have the following form:
(SYMBOL :char STRING :prompt STRING :ask-target (lambda () TARGET) :dyn-target (lambda (TARGET MSG) DYN-TARGET) :show-target (lambda (DYN-TARGET) STRING) :action (lambda (DOCID MSG DYN-TARGET) nil))
The symbol can be any symbol, except for 'unmark
and
'something
, which are reserved. The rest is a plist with the
following elements:
:char
— the character to display in the headers view.
:prompt
— the prompt to use when asking for marks
(used for example when marking a whole thread).
:ask-target
— a function run once per bulk-operation, and thus suitable for
querying the user about a target for move-like marks. If nil
, the
TARGET
passed to :dyn-target
is nil
.
:dyn-target
— a function run once per message
(The message is passed as MSG
to the function). This function allows
to compute a per-message target, for refile-like marks. If nil
, the
DYN-TARGET
passed to the :action
is the TARGET
obtained as above.
:show-target
— how to display the target in the headers view.
If :show-target
is nil
the DYN-TARGET
is shown (and
DYN-TARGET
must be a string).
:action
— the action to apply on the message when the mark is executed.
As an example, suppose we would like to add a mark for tagging
messages (GMail-style), then we can run the following code (after
loading mu4e
):
(add-to-list 'mu4e-marks '(tag :char "g" :prompt "gtag" :ask-target (lambda () (read-string "What tag do you want to add?")) :action (lambda (docid msg target) (mu4e-action-retag-message msg (concat "+" target)))))
Adding to mu4e-marks
list allows to use the mark in bulk operations
(for example when tagging a whole thread), but does not bind the mark
to a key to use at the top-level. This must be done separately. In our
example:
(defun my-mu4e-mark-add-tag() "Add a tag to the message." (interactive) (mu4e-headers-mark-and-next 'tag)) (define-key mu4e-headers-mode-map (kbd "g") 'mu4e-headers-mark-for-tag)