unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Matthieu Lemerre <racin@free.fr>
To: notmuch@notmuchmail.org
Subject: [PATCH] How to improve the mail handling workflow?
Date: Fri, 12 Nov 2010 16:23:58 +0100	[thread overview]
Message-ID: <87fwv65zw1.fsf@free.fr> (raw)

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


Hi,

I think that there are several irritating nitpicks when using notmuch in
a typical mail workflow.

I don't know how other people process their email. I for myself use the
following method:

1. The script I use to fetch new mails tries to add tags if it can. For
   instance, all new mails from the notmuch mailing lists appears with
   tags "(inbox,unread,notmuch)".

2. When processing mails, I manually add some tag to the mails for which
   no tags were added automatically. Then I archive the mail (remove its
   inbox tag).

3. Sometimes I keep mails in my inbox, for instance if I am expecting a
   specific mail and do not want to take the time to process the others.

The emacs interface to notmuch gets in my way in at least several
manners:

 - I often find myself hitting the spacebar too much, which ends up with
   some of my new messages being removed from all of their tags, which
   make them very difficult to find. I don't think the spacebar should
   remove the inbox tag at all. It should only change the unread tag.

 - It does not provide a command for deleting mails. We were several
   people who provided patches to add a 'd' keybinding to support
   deletion. I provided a complex patch for that (that added "and not
   tag:deleted" to all requests", but I now think that just adding a
   "deleted" tag and removing the "inbox" tag would be sufficient).

 - Processing mails which do not have any automatically added tag is
   boring, because I need to press several keys to archive them: "+" to
   add a tag, and then "a". If I forget about +, then my mail is
   impossible to find.

Here is first a patch that copes with this last point. Whenever you want
to archive a thread, it finds whether you forgot to add a custom "user"
tag to a message, and if so asks you for a tag to add before
archiving. That way, I no longer have messages without any tags.

I probably will send patches to handle the other bullet points to, but
first I would be happy to hear your comments about this, or learn about
how you process your mail using the current interface.

Thanks,
Matthieu Lemerre


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: out.patch --]
[-- Type: text/x-diff, Size: 2244 bytes --]

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index d8773e6..57ff72e 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1054,11 +1054,35 @@ argument, hide all of the messages."
   (interactive)
   (backward-button 1))
 
+(defun notmuch-is-user-tag (tag)
+  ;; Returns true if tag is not one of 
+  ;; inbox, deleted, replied, draft, 
+  (not (member tag '("inbox" "replied" "draft" "deleted" 
+		    "attachment" "unread"))))
+
 (defun notmuch-show-archive-thread-internal (show-next)
   ;; Remove the tag from the current set of messages.
   (goto-char (point-min))
-  (loop do (notmuch-show-remove-tag "inbox")
-	until (not (notmuch-show-goto-message-next)))
+  (let ((has-empty-tags))
+    ;; 1st pass: try to see if adding a tag is necessary.
+    (loop do (let ((user-tags (remove-if-not #'notmuch-is-user-tag 
+					     (notmuch-show-get-tags))))
+	       (setq has-empty-tags 
+		     (or has-empty-tags (eq user-tags nil))))
+	  until (not (notmuch-show-goto-message-next)))
+    ;; Only ask for a tag to add if has-empty-tags is non-nil. Use
+    ;; tags-to-apply to propose a default value.
+    (let ((tags-to-add '()))
+      (if has-empty-tags
+	  (setq tags-to-add (list (notmuch-select-tag-with-completion 
+				   "Some messages in the thread have no user tags. Add: "))))
+      ;; 2nd pass: tag all the messages with the user-selected tag,
+      ;; and remove the "inbox" tag
+      (goto-char (point-min))
+      (loop do (progn 
+		 (apply #'notmuch-show-add-tag tags-to-add)
+		 (notmuch-show-remove-tag "inbox"))
+	  until (not (notmuch-show-goto-message-next)))))
   ;; Move to the next item in the search results, if any.
   (let ((parent-buffer notmuch-show-parent-buffer))
     (notmuch-kill-this-buffer)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 5933747..eeff18c 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -560,7 +560,9 @@ thread or threads in the current region."
 
 This function advances the next thread when finished."
   (interactive)
-  (notmuch-search-remove-tag-thread "inbox")
+  (save-excursion
+    (notmuch-search-show-thread)
+    (notmuch-show-archive-thread-internal nil))
   (forward-line))
 
 (defun notmuch-search-process-sentinel (proc msg)

             reply	other threads:[~2010-11-12 15:12 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-12 15:23 Matthieu Lemerre [this message]
2010-11-12 15:33 ` [PATCH] How to improve the mail handling workflow? Jameson Rollins
2010-11-12 16:39   ` Matthieu Lemerre
2010-11-14 21:07   ` Sebastian Spaeth
2010-11-14 21:19     ` Jameson Rollins
2010-11-14 21:31     ` Sebastian Spaeth
2010-11-15  8:28     ` David Edmondson
2010-11-12 15:39 ` Darren McGuicken
2010-11-12 16:35   ` Matthieu Lemerre
2010-11-12 16:58     ` Darren McGuicken
2010-11-14 21:34     ` Sebastian Spaeth
2010-11-14 23:25       ` Matthieu Lemerre
2010-11-13  6:05   ` Michal Sojka
2010-11-13 11:03     ` Darren McGuicken
2010-11-15  8:00       ` Michal Sojka
2010-11-12 17:05 ` David Edmondson
2010-11-12 17:48   ` Matthieu Lemerre
2010-11-12 17:42     ` David Edmondson
2010-11-13 16:43 ` Cédric Cabessa
2010-11-13 18:41   ` Jameson Rollins
2010-11-14 17:01     ` Matthieu Lemerre
2010-11-14 19:13       ` Jameson Rollins
2010-11-14 21:43         ` Matthieu Lemerre
2010-11-14 21:45 ` Michael Hudson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fwv65zw1.fsf@free.fr \
    --to=racin@free.fr \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).