You need to tag at least one message in the thread with the value "muted" (press aM
in the headers buffer), then add a predicate function to mu4e-headers-hide-predicate
to determine whether the thread should be muted/shown. Note: This will only hide muted threads from view.
(add-to-list 'mu4e-headers-actions
'("Mute thread" . (lambda (msg)
(mu4e-action-retag-message msg "+muted")
;; This part is for demonstration
(mu4e-update-index))))
(setq mu4e-headers-hide-predicate
(lambda (msg)
(let* ((msgid (mu4e-message-field msg :message-id))
(cmd (format "mu find 'msgid:%s' -r --format=sexp" msgid))
(result (concat "(list " (shell-command-to-string cmd) ")"))
(msgs (car (read-from-string result))))
(catch 'muted
(cl-loop for msg in msgs
when (member "muted" (plist-get msg :tags))
collect (throw 'muted t))))))
To mute by archiving messages you can try the following:
(add-to-list 'mu4e-headers-actions
'("Mute thread" .
(lambda (msg)
(let ((docid (mu4e-message-field msg :docid))
(refloc (if (stringp mu4e-refile-folder)
mu4e-refile-folder
(funcall mu4e-refile-folder msg))))
(mu4e-action-retag-message msg "+muted")
(mu4e~proc-move docid refloc "+S-N")))))
(defun mu4e-archive-if-muted ()
(let* ((cmd "mu find tag:muted --format=sexp -r")
(result (concat "(list " (shell-command-to-string cmd) ")"))
(msgs (car (read-from-string result))))
(dolist (msg (cdr msgs))
(let ((maildir (mu4e-message-field msg :maildir))
(docid (mu4e-message-field msg :docid))
(refloc (if (stringp mu4e-refile-folder)
mu4e-refile-folder
(funcall mu4e-refile-folder msg))))
(unless (or (string= refloc maildir)
(string= "/sent" maildir))
(when (and docid (> docid 0))
(mu4e~proc-move docid refloc "+S-N")))))))
(add-to-list 'mu4e-index-updated-hook 'mu4e-archive-if-muted t)
What this does is it finds all muted messages, including messages of the same thread, and moves them to the archive directory when the indexing process had one or more messages updated.