Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dcolascione opened this issue Jul 16, 2023 · 2 comments
Open

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

dcolascione opened this issue Jul 16, 2023 · 2 comments
Labels
mu4e specific for mu4e rfe

Comments

@dcolascione
Copy link
Contributor

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.

@sebeaumont
Copy link

Can this be done even with the mu-guile api? I have exactly the same use case.

@djcb
Copy link
Owner

djcb commented Nov 1, 2024

Not in current mu-guile, currently, the easiest way is to use the mu move command-line tool

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mu4e specific for mu4e rfe
Projects
None yet
Development

No branches or pull requests

3 participants