Merge pull request #525 from jyp/master

mu4e: Allow to do retagging using marks instead of message actions
This commit is contained in:
Dirk-Jan C. Binnema
2014-11-30 17:23:28 +02:00

View File

@ -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 docid 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"
@ -248,7 +248,7 @@ The following marks are available, and the corresponding props:
(puthash docid (cons mark target) mu4e~mark-map) (puthash docid (cons mark target) mu4e~mark-map)
;; when we have a target (ie., when moving), show the target folder in ;; when we have a target (ie., when moving), show the target folder in
;; an overlay ;; an overlay
(when (and target mu4e-headers-show-target) (when (and shown-target mu4e-headers-show-target)
(let* ((targetstr (propertize (concat "-> " shown-target " ") (let* ((targetstr (propertize (concat "-> " shown-target " ")
'face 'mu4e-system-face)) 'face 'mu4e-system-face))
;; mu4e~headers-goto-docid docid t \will take us just after the ;; mu4e~headers-goto-docid docid t \will take us just after the
@ -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)