unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] Make notmuch-show 'X' (and 'x') commands remove inbox (and unread) tags
@ 2009-11-17 21:32 Keith Packard
  2009-11-18 10:19 ` Carl Worth
  2009-11-22 23:19 ` Carl Worth
  0 siblings, 2 replies; 13+ messages in thread
From: Keith Packard @ 2009-11-17 21:32 UTC (permalink / raw)
  To: notmuch

When closing a thread view, mark the thread as archived by removing
the "inbox" tag, and for the 'x' variant, the "unread" tag as well,
then kill the buffer and update the search window view as well.

This makes 'x' much the same as 'a', but instead of taking you to the
next message, it takes you back to the search window instead.

Signed-off-by: Keith Packard <keithp@keithp.com>
---
 notmuch.el |   86 ++++++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 67 insertions(+), 19 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index 638d49d..7b0d72c 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -31,8 +31,8 @@
     ; Will be much preferable to switch to direct manipulation for
     ; toggling visibility of these components. Probably using
     ; overlays-at to query and manipulate the current overlay.
-    (define-key map "a" 'notmuch-show-archive-thread)
-    (define-key map "A" 'notmuch-show-mark-read-then-archive-thread)
+    (define-key map "a" 'notmuch-show-mark-read-archive-thread-next-thread)
+    (define-key map "A" 'notmuch-show-archive-thread-next-thread)
     (define-key map "b" 'notmuch-show-toggle-body-read-visible)
     (define-key map "c" 'notmuch-show-toggle-citations-visible)
     (define-key map "h" 'notmuch-show-toggle-headers-visible)
@@ -47,7 +47,8 @@
     (define-key map "s" 'notmuch-show-toggle-signatures-visible)
     (define-key map "v" 'notmuch-show-view-all-mime-parts)
     (define-key map "w" 'notmuch-show-view-raw-message)
-    (define-key map "x" 'kill-this-buffer)
+    (define-key map "x" 'notmuch-show-mark-read-archive-thread-kill-buffer)
+    (define-key map "X" 'notmuch-show-archive-thread-kill-buffer)
     (define-key map "+" 'notmuch-show-add-tag)
     (define-key map "-" 'notmuch-show-remove-tag)
     (define-key map (kbd "DEL") 'notmuch-show-rewind)
@@ -183,7 +184,33 @@ Unlike builtin `next-line' this version accepts no arguments."
 			 (cons (notmuch-show-get-message-id) nil)))
 	  (notmuch-show-set-tags (sort (set-difference tags toremove :test 'string=) 'string<))))))
 
-(defun notmuch-show-archive-thread-maybe-mark-read (markread)
+(defun notmuch-show-next-thread (markread)
+  (let ((parent-buffer notmuch-show-parent-buffer))
+    (kill-this-buffer)
+    (if parent-buffer
+	(progn
+	  (switch-to-buffer parent-buffer)
+	  (forward-line)
+	  (notmuch-search-show-thread)))))
+  
+(defun notmuch-delete-tags (to-remove from)
+  (if to-remove
+      (delete (car to-remove) (notmuch-delete-tags (cdr to-remove) from))
+    from))
+
+(defun notmuch-kill-message-buffer (markread)
+  (let ((parent-buffer notmuch-show-parent-buffer))
+    (kill-this-buffer)
+    (if parent-buffer
+	(progn
+	  (switch-to-buffer parent-buffer)
+	  (let ((tags (notmuch-search-get-tags)))
+	    (setq tags (delete "inbox" tags))
+	    (if markread (setq tags (delete "unread" tags)))
+	    (notmuch-search-set-tags tags))
+	  (forward-line)))))
+
+(defun notmuch-show-archive-thread-maybe-mark-read (markread shownext)
   (save-excursion
     (goto-char (point-min))
     (while (not (eobp))
@@ -194,15 +221,9 @@ Unlike builtin `next-line' this version accepts no arguments."
 	  (forward-char))
       (if (not (re-search-forward notmuch-show-message-begin-regexp nil t))
 	  (goto-char (point-max)))))
-  (let ((parent-buffer notmuch-show-parent-buffer))
-    (kill-this-buffer)
-    (if parent-buffer
-	(progn
-	  (switch-to-buffer parent-buffer)
-	  (forward-line)
-	  (notmuch-search-show-thread)))))
+  (if shownext (notmuch-show-next-thread markread) (notmuch-kill-message-buffer markread)))
 
-(defun notmuch-show-mark-read-then-archive-thread ()
+(defun notmuch-show-mark-read-archive-thread-next-thread ()
   "Remove \"unread\" tag from each message, then archive and show next thread.
 
 Archive each message currrently shown by removing the \"unread\"
@@ -215,9 +236,22 @@ being delivered to the same thread. It does not archive the
 entire thread, but only the messages shown in the current
 buffer."
   (interactive)
-  (notmuch-show-archive-thread-maybe-mark-read t))
+  (notmuch-show-archive-thread-maybe-mark-read t t))
+
+(defun notmuch-show-mark-read-archive-thread-kill-buffer ()
+  "Remove \"unread\" tag from each message, then archive and kill the buffer.
+
+Archive each message currrently shown by removing the \"unread\"
+and \"inbox\" tag from each. Then kill this buffer.
+
+Note: This command is safe from any race condition of new messages
+being delivered to the same thread. It does not archive the
+entire thread, but only the messages shown in the current
+buffer."
+  (interactive)
+  (notmuch-show-archive-thread-maybe-mark-read t nil))
 
-(defun notmuch-show-archive-thread ()
+(defun notmuch-show-archive-thread-next-thread ()
   "Archive each message in thread, and show next thread from search.
 
 Archive each message currrently shown by removing the \"inbox\"
@@ -229,7 +263,20 @@ being delivered to the same thread. It does not archive the
 entire thread, but only the messages shown in the current
 buffer."
   (interactive)
-  (notmuch-show-archive-thread-maybe-mark-read nil))
+  (notmuch-show-archive-thread-maybe-mark-read nil t))
+
+(defun notmuch-show-archive-thread-kill-buffer ()
+  "Archive each message in thread, and kill the thread buffer.
+
+Archive each message currrently shown by removing the \"inbox\"
+tag from each. Then kill this buffer.
+
+Note: This command is safe from any race condition of new messages
+being delivered to the same thread. It does not archive the
+entire thread, but only the messages shown in the current
+buffer."
+  (interactive)
+  (notmuch-show-archive-thread-maybe-mark-read nil t))
 
 (defun notmuch-show-view-raw-message ()
   "View the raw email of the current message."
@@ -297,7 +344,7 @@ by searching backward)."
       (not (re-search-forward notmuch-show-message-begin-regexp nil t)))))
 
 (defun notmuch-show-message-unread-p ()
-  "Preficate testing whether current message is unread."
+  "Predicate testing whether current message is unread."
   (member "unread" (notmuch-show-get-tags)))
 
 (defun notmuch-show-next-message ()
@@ -434,7 +481,7 @@ which this thread was originally shown."
       (let ((last (notmuch-show-last-message-p)))
 	(notmuch-show-mark-read-then-next-open-message)
 	(if last
-	    (notmuch-show-archive-thread))))))
+	    (notmuch-show-archive-thread-next-thread))))))
 
 (defun notmuch-show-markup-citations-region (beg end depth)
   (goto-char beg)
@@ -618,8 +665,9 @@ messages. Each time you navigate away from a message with
 
 You can add or remove tags from the current message with '+' and
 '-'.  You can also archive all messages in the current
-view, (remove the \"inbox\" tag from each), with
-`notmuch-show-archive-thread' (bound to 'a' by default).
+view, (remove the \"inbox\" tag from each), with either
+`notmuch-show-archive-thread-next-thread' (bound to 'a' by default) or
+`notmuch-show-archive-thread-kill-buffer' (bound to 'x' by default).
 
 \\{notmuch-show-mode-map}"
   (interactive)
-- 
1.6.5.2

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

* Re: [PATCH] Make notmuch-show 'X' (and 'x') commands remove inbox (and unread) tags
  2009-11-17 21:32 Keith Packard
@ 2009-11-18 10:19 ` Carl Worth
  2009-11-18 17:45   ` Keith Packard
  2009-11-22 23:19 ` Carl Worth
  1 sibling, 1 reply; 13+ messages in thread
From: Carl Worth @ 2009-11-18 10:19 UTC (permalink / raw)
  To: Keith Packard, notmuch

On Tue, 17 Nov 2009 13:32:45 -0800, Keith Packard <keithp@keithp.com> wrote:
> When closing a thread view, mark the thread as archived by removing
> the "inbox" tag, and for the 'x' variant, the "unread" tag as well,
> then kill the buffer and update the search window view as well.
> 
> This makes 'x' much the same as 'a', but instead of taking you to the
> next message, it takes you back to the search window instead.

I don't like this---but that's because I use 'x' precisely *because* it
preserves these tags.

Otherwise, you might as well just remove inbox and unread as soon as the
message is presented to the user. And that's a bug in a lot of other
email programs that I'm unwilling to replicate.

We may run into a need to define different ways that people like to work
with their email here. (I know that so far I've just been coding up the
way I want my mail to work.)

-Carl

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

* Re: [PATCH] Make notmuch-show 'X' (and 'x') commands remove inbox (and unread) tags
  2009-11-18 10:19 ` Carl Worth
@ 2009-11-18 17:45   ` Keith Packard
  2009-11-19  0:25     ` Carl Worth
  0 siblings, 1 reply; 13+ messages in thread
From: Keith Packard @ 2009-11-18 17:45 UTC (permalink / raw)
  To: Carl Worth, notmuch

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

On Wed, 18 Nov 2009 02:19:26 -0800, Carl Worth <cworth@cworth.org> wrote:

> I don't like this---but that's because I use 'x' precisely *because* it
> preserves these tags.

You can use kill-buffer directly (C-X k); adding a new special binding
for that command seems unnecessary to me.

> Otherwise, you might as well just remove inbox and unread as soon as the
> message is presented to the user. And that's a bug in a lot of other
> email programs that I'm unwilling to replicate.

My mail flow doesn't involve moving directly from one message to the
next; I go back to the index after reviewing each one; there isn't a way
to mark a buffer as read/archived and *not* view another message

--
keith.packard@intel.com


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

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

* Re: [PATCH] Make notmuch-show 'X' (and 'x') commands remove inbox (and unread) tags
  2009-11-18 17:45   ` Keith Packard
@ 2009-11-19  0:25     ` Carl Worth
  2009-11-19  0:43       ` Keith Packard
  0 siblings, 1 reply; 13+ messages in thread
From: Carl Worth @ 2009-11-19  0:25 UTC (permalink / raw)
  To: Keith Packard, notmuch

On Wed, 18 Nov 2009 09:45:01 -0800, Keith Packard <keithp@keithp.com> wrote:
> On Wed, 18 Nov 2009 02:19:26 -0800, Carl Worth <cworth@cworth.org> wrote:
> You can use kill-buffer directly (C-X k); adding a new special binding
> for that command seems unnecessary to me.

Well, that's "Control, X, K, Enter", so quite a bit harder than just
'x'. :-)

But fine, I could move my convenience for "kill buffer" to just 'k'.

I think I'd like to see a better mapping for "archive and kill buffer"
to a key other than 'x'. Any ideas?

> My mail flow doesn't involve moving directly from one message to the
> next; I go back to the index after reviewing each one; there isn't a way
> to mark a buffer as read/archived and *not* view another message

OK, that's definitely different than me.

Let me at least explain a couple of parts of my flow, (not intended to
try to convince you to use it---just to explain):

1. Before I go into "read a bunch of messages with spacebar" mode I
   first arrange for filtered search results that I know I want to read
   all together. Most frequently this involves bringing up the inbox,
   and then hitting 't' for filter-to-tag and choosing a tag of mail
   that's all interesting, (like the "to-me" tag that gets applied
   automatically[*] to all mail addressed to me individually).

2. When I archive a thread with 'a', I'm not necessarily always planning
   to read the next message (just because notmuch is presenting it to
   me). And if not, I'll just press 'x' right away.

   a. An important point here is that that "undesired" presentation of a
      message results in no state changes. In far too many other email
      programs I've used, deleting one message causes another one to be
      displayed and *that* message gets immediately marked "unread"
      forcing me to read it immediately or risk losing it. Not nice.

   b. Sometimes, even if I wasn't really planning in advance to read the
      mail, just having it appear does encourage me to read it, (but
      with no risk if I choose not to---unlike the broken mailer I
      described above). So here's one way that notmuch encourages me to
      mow through my pending mail quickly.

3. There's one entirely different mode I use. The above is for a
   collection of "mostly interesting" messages where I want to at least
   see them all. The other mode is "mostly uninteresting" messages where
   I can take care of most everything from the search view, (and maybe
   just pop into one or two messages). Here your, 'archive and exit' key
   might be useful, but my 'exit without archiving' works fine too. The
   reason is that after I look at the one or two interesting messages,
   the next thing I'll do is to archive away all the messages from the
   search view. Of course, for this I need an "archive all" binding that
   doesn't exist yet. And I also really need to fix the Xapian bug so
   that archiving 100 threads doesn't take *forever* like it does
   currently.

Anyway, thanks for letting me ramble a bit about how I deal with mail.

-Carl

[*] I'm currently getting "automatic" tags via a script (which I've
named notmuch-poll) that calls "notmuch new" and then calls a bunch of
"notmuch tag" commands not unlike the following:

	notmuch tag +notmuch to:notmuchmail.org and not tag:notmuch

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

* Re: [PATCH] Make notmuch-show 'X' (and 'x') commands remove inbox (and unread) tags
  2009-11-19  0:25     ` Carl Worth
@ 2009-11-19  0:43       ` Keith Packard
  0 siblings, 0 replies; 13+ messages in thread
From: Keith Packard @ 2009-11-19  0:43 UTC (permalink / raw)
  To: Carl Worth, notmuch

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

On Thu, 19 Nov 2009 01:25:34 +0100, Carl Worth <cworth@cworth.org> wrote:
> On Wed, 18 Nov 2009 09:45:01 -0800, Keith Packard <keithp@keithp.com> wrote:
> > On Wed, 18 Nov 2009 02:19:26 -0800, Carl Worth <cworth@cworth.org> wrote:
> > You can use kill-buffer directly (C-X k); adding a new special binding
> > for that command seems unnecessary to me.
> 
> Well, that's "Control, X, K, Enter", so quite a bit harder than just
> 'x'. :-)

I'd forgotten about the 'q' binding, which used to be the same as 'x'
and is now different. Similar to how fdisk differentiates between
'q'uit without saving changes and 'w'rite table to disk and exit.

> But fine, I could move my convenience for "kill buffer" to just 'k'.

You've got 'q' already :-)

> I think I'd like to see a better mapping for "archive and kill buffer"
> to a key other than 'x'. Any ideas?

I'm up for almost anything; but I'd have to retrain my fingers to use it
instead of 'x' :-)

> 1. Before I go into "read a bunch of messages with spacebar" mode I
>    first arrange for filtered search results that I know I want to read
>    all together.

I generally do the same, but don't read mail in time sequence. One of
the reasons I like the threaded reading mode is that I don't *have* to
read mail in time sequence as I can review a thread and see the time
ordering of the messages within that.

> 2. When I archive a thread with 'a', I'm not necessarily always planning
>    to read the next message (just because notmuch is presenting it to
>    me). And if not, I'll just press 'x' right away.

Right, if you use the 'a' key to flip to a new message, you probably
don't want to use 'x' on the final (and still essentially ignored)
message.

>    Of course, for this I need an "archive all" binding that
>    doesn't exist yet. And I also really need to fix the Xapian bug so
>    that archiving 100 threads doesn't take *forever* like it does
>    currently.

yes, please! I'd even be willing to wait at this point...

--
keith.packard@intel.com

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

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

* [PATCH] Make notmuch-show 'X' (and 'x') commands remove inbox (and unread) tags
@ 2009-11-21  4:46 Keith Packard
  0 siblings, 0 replies; 13+ messages in thread
From: Keith Packard @ 2009-11-21  4:46 UTC (permalink / raw)
  To: notmuch

When closing a thread view, mark the thread as archived by removing
the "inbox" tag, and for the 'x' variant, the "unread" tag as well,
then kill the buffer and update the search window view as well.

This makes 'x' much the same as 'a', but instead of taking you to the
next message, it takes you back to the search window instead.

Signed-off-by: Keith Packard <keithp@keithp.com>
---
 notmuch.el |   86 ++++++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 67 insertions(+), 19 deletions(-)

This adds new functionality without removing any; without this patch,
the 'x' and 'q' commands do the same thing,  killing the buffer
without clearing any tags. With this patch, the 'x' command clears the
inbox and unread tags from the current message and returns to the
search index view, while the existing 'q' command continues to provide
old behaviour.

diff --git a/notmuch.el b/notmuch.el
index cd3780f..544f281 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -31,8 +31,8 @@
     ; Will be much preferable to switch to direct manipulation for
     ; toggling visibility of these components. Probably using
     ; overlays-at to query and manipulate the current overlay.
-    (define-key map "a" 'notmuch-show-archive-thread)
-    (define-key map "A" 'notmuch-show-mark-read-then-archive-thread)
+    (define-key map "a" 'notmuch-show-mark-read-archive-thread-next-thread)
+    (define-key map "A" 'notmuch-show-archive-thread-next-thread)
     (define-key map "b" 'notmuch-show-toggle-body-read-visible)
     (define-key map "c" 'notmuch-show-toggle-citations-visible)
     (define-key map "h" 'notmuch-show-toggle-headers-visible)
@@ -47,7 +47,8 @@
     (define-key map "s" 'notmuch-show-toggle-signatures-visible)
     (define-key map "v" 'notmuch-show-view-all-mime-parts)
     (define-key map "w" 'notmuch-show-view-raw-message)
-    (define-key map "x" 'kill-this-buffer)
+    (define-key map "x" 'notmuch-show-mark-read-archive-thread-kill-buffer)
+    (define-key map "X" 'notmuch-show-archive-thread-kill-buffer)
     (define-key map "+" 'notmuch-show-add-tag)
     (define-key map "-" 'notmuch-show-remove-tag)
     (define-key map (kbd "DEL") 'notmuch-show-rewind)
@@ -193,7 +194,33 @@ Unlike builtin `next-line' this version accepts no arguments."
 			 (cons (notmuch-show-get-message-id) nil)))
 	  (notmuch-show-set-tags (sort (set-difference tags toremove :test 'string=) 'string<))))))
 
-(defun notmuch-show-archive-thread-maybe-mark-read (markread)
+(defun notmuch-show-next-thread (markread)
+  (let ((parent-buffer notmuch-show-parent-buffer))
+    (kill-this-buffer)
+    (if parent-buffer
+	(progn
+	  (switch-to-buffer parent-buffer)
+	  (forward-line)
+	  (notmuch-search-show-thread)))))
+  
+(defun notmuch-delete-tags (to-remove from)
+  (if to-remove
+      (delete (car to-remove) (notmuch-delete-tags (cdr to-remove) from))
+    from))
+
+(defun notmuch-kill-message-buffer (markread)
+  (let ((parent-buffer notmuch-show-parent-buffer))
+    (kill-this-buffer)
+    (if parent-buffer
+	(progn
+	  (switch-to-buffer parent-buffer)
+	  (let ((tags (notmuch-search-get-tags)))
+	    (setq tags (delete "inbox" tags))
+	    (if markread (setq tags (delete "unread" tags)))
+	    (notmuch-search-set-tags tags))
+	  (forward-line)))))
+
+(defun notmuch-show-archive-thread-maybe-mark-read (markread shownext)
   (save-excursion
     (goto-char (point-min))
     (while (not (eobp))
@@ -204,15 +231,9 @@ Unlike builtin `next-line' this version accepts no arguments."
 	  (forward-char))
       (if (not (re-search-forward notmuch-show-message-begin-regexp nil t))
 	  (goto-char (point-max)))))
-  (let ((parent-buffer notmuch-show-parent-buffer))
-    (kill-this-buffer)
-    (if parent-buffer
-	(progn
-	  (switch-to-buffer parent-buffer)
-	  (forward-line)
-	  (notmuch-search-show-thread)))))
+  (if shownext (notmuch-show-next-thread markread) (notmuch-kill-message-buffer markread)))
 
-(defun notmuch-show-mark-read-then-archive-thread ()
+(defun notmuch-show-mark-read-archive-thread-next-thread ()
   "Remove \"unread\" tag from each message, then archive and show next thread.
 
 Archive each message currently shown by removing the \"unread\"
@@ -225,9 +246,22 @@ being delivered to the same thread. It does not archive the
 entire thread, but only the messages shown in the current
 buffer."
   (interactive)
-  (notmuch-show-archive-thread-maybe-mark-read t))
+  (notmuch-show-archive-thread-maybe-mark-read t t))
+
+(defun notmuch-show-mark-read-archive-thread-kill-buffer ()
+  "Remove \"unread\" tag from each message, then archive and kill the buffer.
+
+Archive each message currrently shown by removing the \"unread\"
+and \"inbox\" tag from each. Then kill this buffer.
 
-(defun notmuch-show-archive-thread ()
+Note: This command is safe from any race condition of new messages
+being delivered to the same thread. It does not archive the
+entire thread, but only the messages shown in the current
+buffer."
+  (interactive)
+  (notmuch-show-archive-thread-maybe-mark-read t nil))
+
+(defun notmuch-show-archive-thread-next-thread ()
   "Archive each message in thread, and show next thread from search.
 
 Archive each message currently shown by removing the \"inbox\"
@@ -239,7 +273,20 @@ being delivered to the same thread. It does not archive the
 entire thread, but only the messages shown in the current
 buffer."
   (interactive)
-  (notmuch-show-archive-thread-maybe-mark-read nil))
+  (notmuch-show-archive-thread-maybe-mark-read nil t))
+
+(defun notmuch-show-archive-thread-kill-buffer ()
+  "Archive each message in thread, and kill the thread buffer.
+
+Archive each message currrently shown by removing the \"inbox\"
+tag from each. Then kill this buffer.
+
+Note: This command is safe from any race condition of new messages
+being delivered to the same thread. It does not archive the
+entire thread, but only the messages shown in the current
+buffer."
+  (interactive)
+  (notmuch-show-archive-thread-maybe-mark-read nil t))
 
 (defun notmuch-show-view-raw-message ()
   "View the raw email of the current message."
@@ -310,7 +357,7 @@ by searching backward)."
       (not (re-search-forward notmuch-show-message-begin-regexp nil t)))))
 
 (defun notmuch-show-message-unread-p ()
-  "Preficate testing whether current message is unread."
+  "Predicate testing whether current message is unread."
   (member "unread" (notmuch-show-get-tags)))
 
 (defun notmuch-show-next-message ()
@@ -447,7 +494,7 @@ which this thread was originally shown."
       (let ((last (notmuch-show-last-message-p)))
 	(notmuch-show-mark-read-then-next-open-message)
 	(if last
-	    (notmuch-show-archive-thread))))))
+	    (notmuch-show-archive-thread-next-thread))))))
 
 (defun notmuch-show-markup-citations-region (beg end depth)
   (goto-char beg)
@@ -631,8 +678,9 @@ messages. Each time you navigate away from a message with
 
 You can add or remove tags from the current message with '+' and
 '-'.  You can also archive all messages in the current
-view, (remove the \"inbox\" tag from each), with
-`notmuch-show-archive-thread' (bound to 'a' by default).
+view, (remove the \"inbox\" tag from each), with either
+`notmuch-show-archive-thread-next-thread' (bound to 'a' by default) or
+`notmuch-show-archive-thread-kill-buffer' (bound to 'x' by default).
 
 \\{notmuch-show-mode-map}"
   (interactive)
-- 
1.6.5.2

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

* Re: [PATCH] Make notmuch-show 'X' (and 'x') commands remove inbox (and unread) tags
  2009-11-17 21:32 Keith Packard
  2009-11-18 10:19 ` Carl Worth
@ 2009-11-22 23:19 ` Carl Worth
  2009-11-22 23:32   ` Keith Packard
  1 sibling, 1 reply; 13+ messages in thread
From: Carl Worth @ 2009-11-22 23:19 UTC (permalink / raw)
  To: Keith Packard, notmuch

On Tue, 17 Nov 2009 13:32:45 -0800, Keith Packard <keithp@keithp.com> wrote:
> When closing a thread view, mark the thread as archived by removing
> the "inbox" tag, and for the 'x' variant, the "unread" tag as well,
> then kill the buffer and update the search window view as well.

I'm starting to come around to this patch, Keith. :-)

I think one thing we're going to really need is a better help message
for presenting the keybindings. The function names are all really
confusing, (the "notmuch-show" prefix doesn't help). So what I'd really
like is something that displays the keybinding and the first line of the
documentation of a function, rather than the function name itself.

> This makes 'x' much the same as 'a', but instead of taking you to the
> next message, it takes you back to the search window instead.

Except that the patch also reverses the current behavior of "a" and
"A". That should be a separate patch anyway, but I'm also not sure that
I like it. I like that the command that takes the extra effort of
pressing shift is the command that does *more*, (removing both "unread"
and "inbox"), rather than the command that does *less*.

-Carl

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

* Re: [PATCH] Make notmuch-show 'X' (and 'x') commands remove inbox (and unread) tags
  2009-11-22 23:19 ` Carl Worth
@ 2009-11-22 23:32   ` Keith Packard
  2009-11-23  3:03     ` Carl Worth
  0 siblings, 1 reply; 13+ messages in thread
From: Keith Packard @ 2009-11-22 23:32 UTC (permalink / raw)
  To: Carl Worth, notmuch

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

On Mon, 23 Nov 2009 00:19:29 +0100, Carl Worth <cworth@cworth.org> wrote:

> I'm starting to come around to this patch, Keith. :-)

I'll keep posting it then :-)

> I think one thing we're going to really need is a better help message
> for presenting the keybindings. The function names are all really
> confusing, (the "notmuch-show" prefix doesn't help). So what I'd really
> like is something that displays the keybinding and the first line of the
> documentation of a function, rather than the function name itself.

That's a fine plan. It 'shouldn't' be too hard to implement either.

Btw, I'm thinking that it might be useful to create some 'global'
notmuch keybindings and then create per-view bindings that also expose
the global bindings. That way, things like 'm' to create a new mail
would work consistently in each view. Note that this idea is
inconsistent with the following though...

> Except that the patch also reverses the current behavior of "a" and
> "A". That should be a separate patch anyway, but I'm also not sure that
> I like it. I like that the command that takes the extra effort of
> pressing shift is the command that does *more*, (removing both "unread"
> and "inbox"), rather than the command that does *less*.

I was trying to make the 'normal' action easier; for me, if I'm looking
at a message, then the normal action is to mark it read and archived,
but when I'm looking only at the subject line in the search window, the
normal action is just to mark it archived (having not actually read the
message).

-- 
keith.packard@intel.com

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

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

* Re: [PATCH] Make notmuch-show 'X' (and 'x') commands remove inbox (and unread) tags
  2009-11-22 23:32   ` Keith Packard
@ 2009-11-23  3:03     ` Carl Worth
  2009-11-23  3:52       ` Keith Packard
  0 siblings, 1 reply; 13+ messages in thread
From: Carl Worth @ 2009-11-23  3:03 UTC (permalink / raw)
  To: Keith Packard, notmuch

On Sun, 22 Nov 2009 15:32:13 -0800, Keith Packard <keithp@keithp.com> wrote:
> That's a fine plan. It 'shouldn't' be too hard to implement either.

Noted in TODO for future reference.

> Btw, I'm thinking that it might be useful to create some 'global'
> notmuch keybindings and then create per-view bindings that also expose
> the global bindings. That way, things like 'm' to create a new mail
> would work consistently in each view. Note that this idea is
> inconsistent with the following though...

That's an excellent idea. And it's consistent with what I want 'a' to
do, (and I do think it's important to have these commands consistent
across the views). I think it's natural too. See below...

> I was trying to make the 'normal' action easier; for me, if I'm looking
> at a message, then the normal action is to mark it read and archived,
> but when I'm looking only at the subject line in the search window, the
> normal action is just to mark it archived (having not actually read the
> message).

I agree that "normal" should be easier too. So I just need to win you
over to my notion of "normal", (and teach you of the ways of the magic
space bar).

The most normal thing (for me) to do *when at the end of a thread* is
to mark it read, archive it, and then advance to the next message. And
that's exactly what space bar does.

If you're not at the end of a thread, then you can archive it, (that's
what 'a' is for), but it shouldn't be marked read, (because otherwise
that would be "cheating").[*]

And if you want to cheat willingly, (notmuch, please consider these
messages read even though you've never presented them to me), then
that should require an extra-explicit action. So that's the shift key.

[*] We should perhaps fix 'a' to remove the "unread" tag from any
messages that _are_ wholly visible in the current window. It's really
only when an entire thread fits this one, and I *did* read it, that I
end up reaching for the 'A' binding.

So does that make sense?

The question of whether you next want to see the next message, or you
would rather return to the search view, is a trickier one. I'd suggest
that there's no harm in seeing the next message after archiving the
current message, from which you can immediately return to the search
view with 'q' (or 'x' currently, but not with your patch). That does
mean that "archive and return to search" does require two keys instead
of one.

Hmm... if we fix 'a' to correctly remove "unread" from wholly
presented messages, then I wouldn't need the current 'A' keybinding at
all. That is, notmuch would be automatically managing "unread" tags in
a fairly consistent way, and we wouldn't be giving UI for the
"cheating", (which should be fine---I can't see a good reason for
cheating here).

If we did that, then we could make 'a' do archive-go-to-next-message
and 'A' do archive-return-to-search-view. What would you think about
that?

-Carl
Date: Mon, 23 Nov 2009 04:02:59 +0100
Message-ID: <871vjqgcyk.fsf@yoom.home.cworth.org>

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

* Re: [PATCH] Make notmuch-show 'X' (and 'x') commands remove inbox (and unread) tags
  2009-11-23  3:03     ` Carl Worth
@ 2009-11-23  3:52       ` Keith Packard
  2009-11-23  6:31         ` Carl Worth
  0 siblings, 1 reply; 13+ messages in thread
From: Keith Packard @ 2009-11-23  3:52 UTC (permalink / raw)
  To: Carl Worth, notmuch

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

On Mon, 23 Nov 2009 04:03:12 +0100, Carl Worth <cworth@cworth.org> wrote:

> I agree that "normal" should be easier too. So I just need to win you
> over to my notion of "normal", (and teach you of the ways of the magic
> space bar).

As I mentioned, I rarely read mail in a linear fashion; I don't want it
to show me another message, I want to see the index again. I'm torn over
whether I just want the index to always be visible; having the full
screen available to view a single thread is awfully nice. It seems like
a 'I'm done, go back to the index' is just what is needed here.

> [*] We should perhaps fix 'a' to remove the "unread" tag from any
> messages that _are_ wholly visible in the current window. It's really
> only when an entire thread fits this one, and I *did* read it, that I
> end up reaching for the 'A' binding.

yes, that does make a lot of sense, and do precisely the same for the
'x' key, leaving 'q' the way to get out of a message without changing
it at all.

> If we did that, then we could make 'a' do archive-go-to-next-message
> and 'A' do archive-return-to-search-view. What would you think about
> that?

I'd take 'x' for 'return to search view; otherwise you're going to wear
out my pinky reaching for the shift key. That leaves us with three
commands:

'a': advance to next message, archiving current thread, marking read
messages. ('A' forces all messages in thread to be marked as read)

'x': exit to search view, archiving current thread, marking read
messages. ('X' forces all messages in thread to be marked as read)

'q': quit back to search view, leaving thread tags unmodified.

There's a slightly weird asymmetry here -- there's no way to advance to
the next thread and not mark messages.

-- 
keith.packard@intel.com

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

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

* Re: [PATCH] Make notmuch-show 'X' (and 'x') commands remove inbox (and unread) tags
  2009-11-23  3:52       ` Keith Packard
@ 2009-11-23  6:31         ` Carl Worth
  2009-11-23  7:20           ` Keith Packard
  0 siblings, 1 reply; 13+ messages in thread
From: Carl Worth @ 2009-11-23  6:31 UTC (permalink / raw)
  To: Keith Packard, notmuch

On Sun, 22 Nov 2009 19:52:00 -0800, Keith Packard <keithp@keithp.com> wrote:
> I'd take 'x' for 'return to search view; otherwise you're going to wear
> out my pinky reaching for the shift key. That leaves us with three
> commands:
> 
> 'a': advance to next message, archiving current thread, marking read
> messages. ('A' forces all messages in thread to be marked as read)
> 
> 'x': exit to search view, archiving current thread, marking read
> messages. ('X' forces all messages in thread to be marked as read)
> 
> 'q': quit back to search view, leaving thread tags unmodified.

OK. You win. That looks pretty good to me.

> There's a slightly weird asymmetry here -- there's no way to advance to
> the next thread and not mark messages.

Well, there's "q, n, RET" at least. ;-)

-Carl

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

* Re: [PATCH] Make notmuch-show 'X' (and 'x') commands remove inbox (and unread) tags
  2009-11-23  6:31         ` Carl Worth
@ 2009-11-23  7:20           ` Keith Packard
  2009-12-01  7:27             ` Carl Worth
  0 siblings, 1 reply; 13+ messages in thread
From: Keith Packard @ 2009-11-23  7:20 UTC (permalink / raw)
  To: Carl Worth, notmuch

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

On Mon, 23 Nov 2009 07:31:04 +0100, Carl Worth <cworth@cworth.org> wrote:

> OK. You win. That looks pretty good to me.

So we need to do the 'mark all that have been seen read' change, then we
can do the rest of this switch. Not sure how to make that work, as we
need to know what has been displayed, and you can display bits of the
window in lots of different ways (even using the mouse!)

-- 
keith.packard@intel.com

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

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

* Re: [PATCH] Make notmuch-show 'X' (and 'x') commands remove inbox (and unread) tags
  2009-11-23  7:20           ` Keith Packard
@ 2009-12-01  7:27             ` Carl Worth
  0 siblings, 0 replies; 13+ messages in thread
From: Carl Worth @ 2009-12-01  7:27 UTC (permalink / raw)
  To: Keith Packard, notmuch

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

On Sun, 22 Nov 2009 23:20:58 -0800, Keith Packard <keithp@keithp.com> wrote:
> So we need to do the 'mark all that have been seen read' change, then we
> can do the rest of this switch. Not sure how to make that work, as we
> need to know what has been displayed, and you can display bits of the
> window in lots of different ways (even using the mouse!)

Yeah, we're not yet very friendly to reading with the mouse scroll
wheel, (in that doing so won't clear the "unread" tag from messages as
they go by).

Meanwhile, I actually like being able to peek ahead in a thread with 'n'
and 'p' and know that those commands don't touch my "unread" tag.

So I think what I'd like is for 'a' and 'x' to simply remove the unread
tag from any message whose final line is currently visible.

But that's also really orthogonal to making 'x' and 'X' remove the
"inbox" tag from the messages in the current thread. So I've just
committed that change (see below).

-Carl

commit 55559ea409ad8df367f13752430244b7087dcd23
Author: Carl Worth <cworth@cworth.org>
Date:   Mon Nov 30 23:21:04 2009 -0800

    notmuch.el: Make 'x' and 'X' in show-mode archive the current thread.
    
    This makes these keys different than 'q' in this mode, (where 'x'
    and 'q' are identical in all of the other modes currently).
    
    The idea here is to make it easier to do non-linear reading of messages,
    (such as when poking in to read just one or two threads from a search
    result that returned many threads).

diff --git a/notmuch.el b/notmuch.el
index e605d9d..2509651 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -55,7 +55,6 @@
   (let ((map (make-sparse-keymap)))
     (define-key map "?" 'notmuch-help)
     (define-key map "q" 'kill-this-buffer)
-    (define-key map "x" 'kill-this-buffer)
     (define-key map (kbd "C-p") 'notmuch-show-previous-line)
     (define-key map (kbd "C-n") 'notmuch-show-next-line)
     (define-key map (kbd "M-TAB") 'notmuch-show-previous-button)
@@ -70,6 +69,8 @@
     (define-key map "v" 'notmuch-show-view-all-mime-parts)
     (define-key map "-" 'notmuch-show-remove-tag)
     (define-key map "+" 'notmuch-show-add-tag)
+    (define-key map "X" 'notmuch-show-mark-read-then-archive-then-exit)
+    (define-key map "x" 'notmuch-show-archive-thread-then-exit)
     (define-key map "A" 'notmuch-show-mark-read-then-archive-thread)
     (define-key map "a" 'notmuch-show-archive-thread)
     (define-key map "p" 'notmuch-show-previous-message)
@@ -273,6 +274,18 @@ buffer."
   (interactive)
   (notmuch-show-archive-thread-maybe-mark-read nil))
 
+(defun notmuch-show-archive-thread-then-exit ()
+  "Archive each message in thread, then exit back to search results."
+  (interactive)
+  (notmuch-show-archive-thread)
+  (kill-this-buffer))
+
+(defun notmuch-show-mark-read-then-archive-then-exit ()
+  "Remove unread tags from thread, then archive and exit to search results."
+  (interactive)
+  (notmuch-show-mark-read-then-archive-thread)
+  (kill-this-buffer))
+
 (defun notmuch-show-view-raw-message ()
   "View the raw email of the current message."
   (interactive)


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

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

end of thread, other threads:[~2009-12-01  7:28 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-21  4:46 [PATCH] Make notmuch-show 'X' (and 'x') commands remove inbox (and unread) tags Keith Packard
  -- strict thread matches above, loose matches on Subject: below --
2009-11-17 21:32 Keith Packard
2009-11-18 10:19 ` Carl Worth
2009-11-18 17:45   ` Keith Packard
2009-11-19  0:25     ` Carl Worth
2009-11-19  0:43       ` Keith Packard
2009-11-22 23:19 ` Carl Worth
2009-11-22 23:32   ` Keith Packard
2009-11-23  3:03     ` Carl Worth
2009-11-23  3:52       ` Keith Packard
2009-11-23  6:31         ` Carl Worth
2009-11-23  7:20           ` Keith Packard
2009-12-01  7:27             ` 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).