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

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)
_______________________________________________
notmuch mailing list
[email protected]
http://notmuchmail.org/mailman/listinfo/notmuch

Reply via email to