mirror of https://github.com/djcb/mu.git
pass the message structure to the mark actions
This allows to re-tag a message in a mark action. Two examples of what one can do with this stuff: 1. G-mail archiving: (archive :char "a" :prompt "archive" :show-target (lambda (target) "archive") :action (lambda (docid msg target) (mu4e~proc-move docid nil "-N") (mu4e-action-retag-message msg "-\\Inbox"))) 2. Tagging: (tag :char "g" :prompt "gtag" :ask-target (lambda () (read-string "What tag do you want to add?")) :show-target (lambda (target) target) :action (lambda (docid msg target) (mu4e~proc-move docid nil "-N") (mu4e-action-retag-message msg (concat "+" target))))
This commit is contained in:
parent
a6c4785577
commit
f6e5f3df7f
|
@ -124,21 +124,21 @@ is either a headers or view buffer."
|
||||||
"The list of all the possible marks.
|
"The list of all the possible marks.
|
||||||
This is an alist mapping mark symbols to their properties. The
|
This is an alist mapping mark symbols to their properties. The
|
||||||
properties are:
|
properties are:
|
||||||
:char The character to display in the headers view
|
:char (string) The character to display in the headers view
|
||||||
:prompt The prompt to use when asking for marks (used for
|
:prompt (string) The prompt to use when asking for marks (used for
|
||||||
example when marking a whole thread)
|
example when marking a whole thread)
|
||||||
:ask-target Get the target. This function run once per
|
:ask-target (function returning a string) Get the target. This
|
||||||
bulk-operation, and thus is suitable for user-interaction.
|
function run once per bulk-operation, and thus is suitable
|
||||||
If nil, the target is nil.
|
for user-interaction. If nil, the target is nil.
|
||||||
:dyn-target Compute the dynamic target. This is run once per
|
:dyn-target (function from (TARGET MSG) to string). Compute
|
||||||
message, which is passed as an argument. If nil, the target
|
the dynamic target. This is run once per message, which is
|
||||||
is not touched.
|
passed as MSG. The default is to just return the target.
|
||||||
:show-target How to display the target.
|
:show-target (function from TARGET to string) How to display
|
||||||
:action The action to apply on the message.
|
the target.
|
||||||
|
:action (function taking (DOCID MSG TARGET)). The action to
|
||||||
|
apply on the message.
|
||||||
")
|
")
|
||||||
|
|
||||||
;; TODO: The actions should probably get the
|
|
||||||
;; message: it contains more info than the docid.
|
|
||||||
(unless mu4e-marks
|
(unless mu4e-marks
|
||||||
(setq mu4e-marks
|
(setq mu4e-marks
|
||||||
'((refile
|
'((refile
|
||||||
|
@ -146,49 +146,49 @@ properties are:
|
||||||
:prompt "refile"
|
:prompt "refile"
|
||||||
:dyn-target (lambda (target msg) (mu4e-get-refile-folder msg))
|
:dyn-target (lambda (target msg) (mu4e-get-refile-folder msg))
|
||||||
:show-target (lambda (target) target)
|
:show-target (lambda (target) target)
|
||||||
:action (lambda (docid target) (mu4e~proc-move docid (mu4e~mark-check-target target) "-N")))
|
:action (lambda (docid msg target) (mu4e~proc-move docid (mu4e~mark-check-target target) "-N")))
|
||||||
(delete
|
(delete
|
||||||
:char "D"
|
:char "D"
|
||||||
:prompt "Delete"
|
:prompt "Delete"
|
||||||
:show-target (lambda (target) "delete")
|
:show-target (lambda (target) "delete")
|
||||||
:action (lambda (docid target) (mu4e~proc-remove docid)))
|
:action (lambda (docid msg target) (mu4e~proc-remove docid)))
|
||||||
(flag
|
(flag
|
||||||
:char "+"
|
:char "+"
|
||||||
:prompt "+flag"
|
:prompt "+flag"
|
||||||
:show-target (lambda (target) "flag")
|
:show-target (lambda (target) "flag")
|
||||||
:action (lambda (docid target) (mu4e~proc-move docid nil "+F-u-N")))
|
:action (lambda (docid msg target) (mu4e~proc-move dociddocid nil "+F-u-N")))
|
||||||
(move
|
(move
|
||||||
:char "m"
|
:char "m"
|
||||||
:prompt "move"
|
:prompt "move"
|
||||||
:ask-target mu4e~mark-get-move-target
|
:ask-target mu4e~mark-get-move-target
|
||||||
:show-target (lambda (target) target)
|
:show-target (lambda (target) target)
|
||||||
:action (lambda (docid target) (mu4e~proc-move docid (mu4e~mark-check-target target) "-N")))
|
:action (lambda (docid msg target) (mu4e~proc-move docid (mu4e~mark-check-target target) "-N")))
|
||||||
(read
|
(read
|
||||||
:char "!"
|
:char "!"
|
||||||
:prompt "!read"
|
:prompt "!read"
|
||||||
:show-target (lambda (target) "read")
|
:show-target (lambda (target) "read")
|
||||||
:action (lambda (docid target) (mu4e~proc-move docid nil "+S-u-N")))
|
:action (lambda (docid msg target) (mu4e~proc-move docid nil "+S-u-N")))
|
||||||
(trash
|
(trash
|
||||||
:char "d"
|
:char "d"
|
||||||
:prompt "dtrash"
|
:prompt "dtrash"
|
||||||
:dyn-target (lambda (target msg) (mu4e-get-trash-folder msg))
|
:dyn-target (lambda (target msg) (mu4e-get-trash-folder msg))
|
||||||
:show-target (lambda (target) target)
|
:show-target (lambda (target) target)
|
||||||
:action (lambda (docid target) (mu4e~proc-move docid (mu4e~mark-check-target target) "+T-N")))
|
:action (lambda (docid msg target) (mu4e~proc-move docid (mu4e~mark-check-target target) "+T-N")))
|
||||||
(unflag
|
(unflag
|
||||||
:char "-"
|
:char "-"
|
||||||
:prompt "-unflag"
|
:prompt "-unflag"
|
||||||
:show-target (lambda (target) "unflag")
|
:show-target (lambda (target) "unflag")
|
||||||
:action (lambda (docid target) (mu4e~proc-move docid nil "-F-N")))
|
:action (lambda (docid msg target) (mu4e~proc-move docid nil "-F-N")))
|
||||||
(untrash
|
(untrash
|
||||||
:char "="
|
:char "="
|
||||||
:prompt "=untrash"
|
:prompt "=untrash"
|
||||||
:show-target (lambda (target) "untrash")
|
:show-target (lambda (target) "untrash")
|
||||||
:action (lambda (docid target) (mu4e~proc-move docid nil "-T")))
|
:action (lambda (docid msg target) (mu4e~proc-move docid nil "-T")))
|
||||||
(unread
|
(unread
|
||||||
:char "?"
|
:char "?"
|
||||||
:prompt "?unread"
|
:prompt "?unread"
|
||||||
:show-target (lambda (target) "unread")
|
:show-target (lambda (target) "unread")
|
||||||
:action (lambda (docid target) (mu4e~proc-move docid nil "-S+u-N")))
|
:action (lambda (docid msg target) (mu4e~proc-move docid nil "-S+u-N")))
|
||||||
(unmark
|
(unmark
|
||||||
:char " "
|
:char " "
|
||||||
:prompt "unmark"
|
:prompt "unmark"
|
||||||
|
@ -379,11 +379,14 @@ If NO-CONFIRMATION is non-nil, don't ask user for confirmation."
|
||||||
(maphash
|
(maphash
|
||||||
(lambda (docid val)
|
(lambda (docid val)
|
||||||
(let* ((mark (car val)) (target (cdr val))
|
(let* ((mark (car val)) (target (cdr val))
|
||||||
(markdescr (assq mark mu4e-marks)))
|
(markdescr (assq mark mu4e-marks))
|
||||||
|
(msg (save-excursion
|
||||||
|
(mu4e~headers-goto-docid docid)
|
||||||
|
(mu4e-message-at-point))))
|
||||||
;; note: whenever you do something with the message,
|
;; note: whenever you do something with the message,
|
||||||
;; it looses its N (new) flag
|
;; it looses its N (new) flag
|
||||||
(if markdescr
|
(if markdescr
|
||||||
(funcall (plist-get (cdr markdescr) :action) docid target)
|
(funcall (plist-get (cdr markdescr) :action) docid msg target)
|
||||||
(mu4e-error "Unrecognized mark %S" mark))))
|
(mu4e-error "Unrecognized mark %S" mark))))
|
||||||
mu4e~mark-map))
|
mu4e~mark-map))
|
||||||
(mu4e-mark-unmark-all)
|
(mu4e-mark-unmark-all)
|
||||||
|
|
Loading…
Reference in New Issue