notmuch and "mute" -- useful to anyone?

Matt Armstrong marmstrong at google.com
Tue Aug 2 10:39:41 PDT 2016


Is anyone else interested in Gmail-like "mute" support in notmuch.el?
If so, I can think about polishing the below off and adding it to
notmuch.

I've managed to implement Gmail's "mute" in notmuch as follows in my
notmuch-post-new:

----------------------------------------------------------------------
# Unmute all threads with new messages sent to me.
notmuch search --output=threads tag:new AND tag:me | \
  xargs --no-run-if-empty notmuch tag -muted --

# Remove all muted threads from the inbox and mark every message in them
# muted.  Ideally this would be atomic with the above.
notmuch search --output=threads tag:muted | \
  xargs --no-run-if-empty notmuch tag -inbox +muted --
----------------------------------------------------------------------

Then in .emacs:

----------------------------------------------------------------------
(defcustom my-notmuch-mute-tags '("+muted" "-inbox")
  "List of tag changes to apply to a message or a thread when it is muted.

Tags starting with \"+\" (or not starting with either \"+\" or
\"-\") in the list will be added, and tags starting with \"-\"
will be removed from the message or thread being archived.

For example, if you wanted to remove an \"inbox\" tag and add an
\"archived\" tag, you would set:
    (\"-inbox\" \"+archived\")"
  :type '(repeat string)
  :group 'notmuch-search
  :group 'notmuch-show)

;; TODO: consider defadvice?
(defun my-notmuch-search-mute-thread (&optional unarchive beg end)
  "Mute the currently selected thread or region.

Mute  each message in the currently selected thread by applying the
tag changes in `my-notmuch-mute-tags' to each (remove the \"inbox\"
tag by default). If a prefix argument is given, the messages will
be \"unarchived\" (i.e. the tag changes in `my-notmuch-mute-tags'
will be reversed).

This function advances the next thread when finished."
  (interactive (cons current-prefix-arg (notmuch-search-interactive-region)))
  (let ((notmuch-archive-tags my-notmuch-mute-tags))
    (notmuch-search-archive-thread unarchive beg end)))

(defun my-notmuch-show-mute-thread-then-next ()
  (interactive)
  "Mute all messages in the current buffer, then show next thread from search."
  (let ((notmuch-archive-tags my-notmuch-mute-tags))
    (notmuch-show-archive-thread-then-next)))

(define-key notmuch-search-mode-map "m" 'my-notmuch-search-mute-thread)
(define-key notmuch-show-mode-map "m" 'my-notmuch-show-mute-thread-then-next)
----------------------------------------------------------------------


More information about the notmuch mailing list