Skip to content

[mu4e rfe] Public-API functions for moving and copying messages #2520

Description

@dcolascione

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    mu4especific for mu4erfe

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions