unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* auto-tagging replied messages
@ 2010-03-05 14:39 Jesse Rosenthal
  2010-03-05 15:32 ` Sebastian Spaeth
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Jesse Rosenthal @ 2010-03-05 14:39 UTC (permalink / raw)
  To: notmuch

Dear All,

One element of traditional clients that I've missed in notmuch is the
ability to easily see which messages have been replied to. A look at the
thread structure will often make that clear, but for both searching and
syncing, an "answered" tag would be nice.

To solve this, I have added the following to my .emacs, and I wanted to
share it in case others might find it useful. You can add an arbitrary
number of tags to the list "notmuch-answered-tags" and it will apply
them (or remove them) when the reply is sent. So you could use it to
automatically mark and email "answered" and remove it from the inbox, or
remove a "todo" or "reply_later" tag.

This relies on the "In-Reply-To" header, so if that's not there, it
won't mark the original message. But then, if that's not there,
threading won't work either, so you'll have bigger problems in notmuch.

Thanks to David, who took a look and offered some suggestions on IRC.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; A set of tags to be added or, if prefaced with a `-', removed
;; e.g. (setq notmuch-answered-tags '("replied" "-todo" "-inbox"))
(setq notmuch-answered-tags '("answered"))

(defun jkr/notmuch-mark-answered ()
  ;; get the in-reply-to header and parse it for the message id. 
  (let ((rep (mail-header-parse-addresses (message-field-value "In-Reply-To"))))
    (when (and notmuch-answered-tags rep)
      ;; add a "+" to any tag that is doesn't already begin with a "+"
      ;; or "-"
      (let ((tags (mapcar '(lambda (str)
			     (if (not (string-match "^[+-]" str))
				 (concat "+" str)
			       str))
			  notmuch-answered-tags)))
	(apply 'notmuch-call-notmuch-process "tag"
	       (append tags (list (concat "id:" (car (car rep)))) nil))))))

(add-hook 'message-sent-hook 'jkr/notmuch-mark-answered)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

By the way, the reason that I didn't submit this as a patch to
notmuch.el is that I'm not sure how we want to deal with things that are
actually more about message-mode, and could possibly affect other
programs using message-mode (gnus). There are a couple of ways to deal
with this (e.g., notmuch minor-mode in message-mode, custom headers) but
my sense is that we should keep notmuch.el from being too imperious at
the moment.

Best,
Jesse

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-04-24 21:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-05 14:39 auto-tagging replied messages Jesse Rosenthal
2010-03-05 15:32 ` Sebastian Spaeth
2010-03-05 16:36 ` Jameson Rollins
2010-04-22 10:35 ` Sebastian Spaeth
2010-04-24 12:38   ` Carl Worth
2010-04-24 13:56     ` Jesse Rosenthal
2010-04-24 21:36       ` Carl Worth

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).