-
Notifications
You must be signed in to change notification settings - Fork 400
Description
Is your feature request related to a problem? Please describe.
I want to make a custom mark for marking messages as spam. In my setup, I mark a message as spam by moving it to a special IMAP folder. Mu4e has no built-in way of moving a message to a specific filter: I can only move to a folder about which I'm asked every time, and I want a command to move to a specific folder, the spam training one.
I have something working, but it relies on the internal function mu4e--server-move:
(defun dancol-mu4e-get-junk-folder (msg &optional print)
(interactive (list (mu4e-message-at-point) t))
(let* ((maildir (mu4e-message-field msg :maildir))
(folder (cond
((string-match "^/XXX/" maildir)
"/XXX/spam")
((string-match "^/YYY/" maildir)
"/YYY/Junk Email")
(t (error "unknown spam folder for maildir %S"
maildir)))))
(when print
(message "maildir=%S spam=%S" maildir folder))
folder))
(add-to-list 'mu4e-marks
'(spam
:char "s"
:prompt "spam"
:dyn-target (lambda (target msg)
(dancol-mu4e-get-junk-folder msg))
:action (lambda (docid msg target)
(mu4e--server-move docid target "+S-u-N"))))
(mu4e~headers-defun-mark-for spam)
(define-key mu4e-headers-mode-map (kbd "`") 'mu4e-headers-mark-for-spam)
(mu4e--view-defun-mark-for spam)
(define-key mu4e-view-mode-map (kbd "`") 'mu4e-view-mark-for-spam)
I'd like to use a public API function instead.
Describe the solution you'd like
There should be a public API version of mu4e--server-move. Accepting flags symbolically might be nice too.
It'd also be nice, while we're at it, to make a public API function for copying a message.