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

* Re: auto-tagging replied messages
  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
  2 siblings, 0 replies; 7+ messages in thread
From: Sebastian Spaeth @ 2010-03-05 15:32 UTC (permalink / raw)
  To: Jesse Rosenthal, notmuch

On 2010-03-05, Sebastian Spaeth wrote:
> 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).

This is really neat functionality, and I have no problems with hooking
this into message mode directly (or even including it into notmuch). I
think it is reasonable to tag notmuch messages as replied (even when
doing from gnus) when I have loaded (notmuch.el).

Testing 'replied' tag with this message...

> 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.

;-). I agree.

Sebastian

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

* Re: auto-tagging replied messages
  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
  2 siblings, 0 replies; 7+ messages in thread
From: Jameson Rollins @ 2010-03-05 16:36 UTC (permalink / raw)
  To: Jesse Rosenthal, notmuch

[-- Attachment #1: Type: text/plain, Size: 964 bytes --]

On Fri, 05 Mar 2010 09:39:14 -0500, Jesse Rosenthal <jrosenthal@jhu.edu> wrote:
> 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.

Hey, Jesse.  This does look neat.  Don't forget to add it to the "emacs
tips" section of the wiki as well.  I've also got some stuff that I'll
be adding there when I ever get a chance.

jamie.

[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]

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

* Re: auto-tagging replied messages
  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
  2 siblings, 1 reply; 7+ messages in thread
From: Sebastian Spaeth @ 2010-04-22 10:35 UTC (permalink / raw)
  To: Jesse Rosenthal, notmuch

On 2010-03-05, Jesse Rosenthal wrote:
> 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.

This patch has been working great so far and is very useful. Can I
persuade someone to take this into the notmuch code and have a defcustom
as to which tag a reply should get (or disable if nil)?

Sebastian

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

* Re: auto-tagging replied messages
  2010-04-22 10:35 ` Sebastian Spaeth
@ 2010-04-24 12:38   ` Carl Worth
  2010-04-24 13:56     ` Jesse Rosenthal
  0 siblings, 1 reply; 7+ messages in thread
From: Carl Worth @ 2010-04-24 12:38 UTC (permalink / raw)
  To: Sebastian Spaeth, Jesse Rosenthal, notmuch

[-- Attachment #1: Type: text/plain, Size: 1205 bytes --]

On Thu, 22 Apr 2010 12:35:16 +0200, "Sebastian Spaeth" <Sebastian@SSpaeth.de> wrote:
> On 2010-03-05, Jesse Rosenthal wrote:
> > 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.
> 
> This patch has been working great so far and is very useful. Can I
> persuade someone to take this into the notmuch code and have a defcustom
> as to which tag a reply should get (or disable if nil)?

I'd like to see the in as well.

Since we name the action of responding to a message "reply" in the
documentation already, my vote for a default tag to add would be
"replied".

Supporting the removal of a tag as well is clever, but I wouldn't
suggest doing that by default (the patch doesn't anyway). And instead,
people could do things like searches for "tag:reply-required and not
tag:replied".

So here's my vote for someone cleaning this up into a patch that could
be applied directly to notmuch rather than just being a snippet of code
to shove into .emacs.

-Carl



[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: auto-tagging replied messages
  2010-04-24 12:38   ` Carl Worth
@ 2010-04-24 13:56     ` Jesse Rosenthal
  2010-04-24 21:36       ` Carl Worth
  0 siblings, 1 reply; 7+ messages in thread
From: Jesse Rosenthal @ 2010-04-24 13:56 UTC (permalink / raw)
  To: Carl Worth, Sebastian Spaeth, notmuch

On Sat, 24 Apr 2010 05:38:36 -0700, Carl Worth <cworth@cworth.org> wrote:
> So here's my vote for someone cleaning this up into a patch that could
> be applied directly to notmuch rather than just being a snippet of code
> to shove into .emacs.

I'd love to put this into shape to become part of notmuch proper. 

My question, for this and other things I've worked on, is where code
that targets message-mode should go. In notmuch-mua.el? Or a new
notmuch-message-utils.el? Or just a catch-all notmuch-utils.el? Once I
know where it would make the most sense to group these, I'll submit a
patch.

> Supporting the removal of a tag as well is clever, but I wouldn't
> suggest doing that by default (the patch doesn't anyway). And instead,
> people could do things like searches for "tag:reply-required and not
> tag:replied".

But just to clarify: you don't mind if removal is a customizable user
option, right?

Best,
Jesse

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

* Re: auto-tagging replied messages
  2010-04-24 13:56     ` Jesse Rosenthal
@ 2010-04-24 21:36       ` Carl Worth
  0 siblings, 0 replies; 7+ messages in thread
From: Carl Worth @ 2010-04-24 21:36 UTC (permalink / raw)
  To: Jesse Rosenthal, Sebastian Spaeth, notmuch

[-- Attachment #1: Type: text/plain, Size: 886 bytes --]


-- 
carl.d.worth@intel.com
On Sat, 24 Apr 2010 09:56:04 -0400, Jesse Rosenthal <jrosenthal@jhu.edu> wrote:
> I'd love to put this into shape to become part of notmuch proper. 

Great!

> My question, for this and other things I've worked on, is where code
> that targets message-mode should go. In notmuch-mua.el? Or a new
> notmuch-message-utils.el? Or just a catch-all notmuch-utils.el? Once I
> know where it would make the most sense to group these, I'll submit a
> patch.

You can call it notmuch-message.el if you'd like.

I'm never a fan of something generic like -utils. Things like that seem
to grow without bounds.

> But just to clarify: you don't mind if removal is a customizable user
> option, right?

I don't mind at all. I was just happy to realize that we wouldn't have
to do any tag removal to make the feature useful out-of-the-box.

-Carl

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ 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).