It is possible to configure new marks, by adding elements to 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 the symbols 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). We can use 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 elements to mu4e-marks
(as in the example) allows you to use the
mark in bulk operations (for example when tagging a whole thread); if you also
want to add a key-binding for the headers view, you can use something like:
(defun my-mu4e-mark-add-tag() "Add a tag to the message at point." (interactive) (mu4e-headers-mark-and-next 'tag)) (define-key mu4e-headers-mode-map (kbd "g") #'my-mu4e-mark-add-tag)