Stack Exchange Network
Stack Exchange network consists of 181 Q&A communities including
Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Visit Stack Exchange
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.
Sign up to join this community
Anybody can ask a question
The best answers are voted up and rise to the top
3 years, 1 month ago
The Mail application in macOS allows creation of rules, such as
Sender X and keyword Y in subject -> mark as read and move to archive. I am looking for something similar in mu4e.
Smart refiling has a similar feature:
you can select some messages in the headers view, then press
r, and have them all marked for refiling to their particular folders.
What I'm looking for is that result without having to see the message or press
r to refile it.
Does it exist?
Feb 18, 2020 at 20:06
1,661 10 10 silver badges 32 32 bronze badges
I don't think so. In any case, the function that does the refiling is called
mu4e~proc-move, so all you need is the message's
docid and target folder. But how do you know which messages are new during the indexing process? One way around this is to find messages flagged unread using the
mu find command (see below).
"mu find maildir:/YOUR_INBOX_FOLDER flag:unread --format=sexp 2>/dev/null")
(defun mu4e-refile-messages ()
(let* ((cmd mu4e-find-new-messages-command)
(res (concat "(list" (shell-command-to-string cmd) ")"))
(msgs (car (read-from-string res))))
(unless (equal '(list) msgs)
(dolist (msg msgs)
(when-let ((docid (mu4e-message-field msg :docid))
(maildir (funcall mu4e-refile-folder msg)))
(mu4e~proc-move docid maildir))))))
(add-to-list 'mu4e-index-updated-hook 'mu4e-refile-messages)
Feb 20, 2020 at 11:03
3,724 4 4 silver badges 17 17 bronze badges
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our
Accept all cookies
Necessary cookies only