Previous: , Up: Marking   [Contents]


8.7 Adding a new kind of mark

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:

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)))))

As another example, suppose we would like to “archive and mark read” a message (gmail-style), then we can run the following code (after loading mu4e):

(add-to-list 'mu4e-marks
  '(archive
     :char       "A"
     :prompt     "Archive"
     :show-target (lambda (target) "archive")
     :action      (lambda (docid msg target)
                    ;; must come before proc-move since retag runs
                    ;; 'sed' on the file
                    (mu4e-action-retag-message msg "-\\Inbox")
                    (mu4e~proc-move docid nil "+S-u-N"))))

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:

(mu4e~headers-defun-mark-for tag)
(mu4e~headers-defun-mark-for archive)
(define-key mu4e-headers-mode-map (kbd "g") 'mu4e-headers-mark-for-tag)
(define-key mu4e-headers-mode-map (kbd "A") 'mu4e-headers-mark-for-archive)

Previous: , Up: Marking   [Contents]