--- /dev/null
+Return-Path: <markwalters1009@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 7A689431FD0\r
+ for <notmuch@notmuchmail.org>; Sun, 1 Dec 2013 02:08:32 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.201\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
+ RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id 3ScLmYa9ZR3w for <notmuch@notmuchmail.org>;\r
+ Sun, 1 Dec 2013 02:08:27 -0800 (PST)\r
+Received: from mail-wg0-f44.google.com (mail-wg0-f44.google.com\r
+ [74.125.82.44]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client\r
+ certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
+ D09C7431FD2 for <notmuch@notmuchmail.org>; Sun, 1 Dec 2013 02:08:26 -0800\r
+ (PST)\r
+Received: by mail-wg0-f44.google.com with SMTP id a1so8742474wgh.11\r
+ for <notmuch@notmuchmail.org>; Sun, 01 Dec 2013 02:08:25 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+ h=from:to:cc:subject:date:message-id:in-reply-to:references;\r
+ bh=K3wprTwWhykGUau4nn5vyDf2jfHbu0RJjdMUWSUxTko=;\r
+ b=QNqqmZKpe7kcak/JPOR7MKVW6lvdgBmXHz/ppLp31APlqDcEHq6r4R684aLa405XzS\r
+ 4W0sJUIjl8idLk6FtQeg6sdpvVtHJqbYzQB1mu8iq66Pg7dJ4WqFhaRywz1eqf0mf6po\r
+ ke6iV7RLdB4cCyVJV+TUdxnuVE/XdLlR7faz8zD5jFSPXL3aDZ6RNQeH7NQBfUx3IdkZ\r
+ fJOkOb1buIIRvuETTxAiSeLSIHH2hhqGuMr3IHsKC4HFR9SgcYhIQjZo8NuaxBRFJJky\r
+ IqMl0Ze1pmNrs0/ZuWAg85hzWCKYI4MuHYgQed3wn6QxDg7MYj/ETp+qPf/am/nrRWoX\r
+ PL8g==\r
+X-Received: by 10.194.78.141 with SMTP id b13mr31650481wjx.32.1385892154498;\r
+ Sun, 01 Dec 2013 02:02:34 -0800 (PST)\r
+Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
+ by mx.google.com with ESMTPSA id\r
+ x19sm110885362wia.5.2013.12.01.02.02.33 for <multiple recipients>\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Sun, 01 Dec 2013 02:02:33 -0800 (PST)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH WIP v2 2/6] emacs: show: add some seen helpers\r
+Date: Sun, 1 Dec 2013 10:02:23 +0000\r
+Message-Id: <1385892147-16994-3-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <1385892147-16994-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1385892147-16994-1-git-send-email-markwalters1009@gmail.com>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sun, 01 Dec 2013 10:08:32 -0000\r
+\r
+We separate out "seeing" a message from marking it read. The intention\r
+is only to mark read at certain times (eg quitting a show buffer). We\r
+use the term seen to mean we have seen the message (for some\r
+definition of seen) in the current buffer, but have not (typically)\r
+marked the message read yet.\r
+\r
+This adds helper functions to test/set the seen property and a\r
+function to tag all seen messages read. The last of these tells the\r
+user how many messages have been marked read. It also takes an\r
+argument that tells the function not to do any marking. This last use\r
+case displays a messages saying "Not marking messages read" and keeps\r
+the logic of what to do when the user does not want to sync seen to\r
+read in one place.\r
+---\r
+ emacs/notmuch-show.el | 34 ++++++++++++++++++++++++++++++++++\r
+ 1 files changed, 34 insertions(+), 0 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index a135e79..c63d295 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -1536,6 +1536,40 @@ marked as unread, i.e. the tag changes in\r
+ (apply 'notmuch-show-tag-message\r
+ (notmuch-tag-change-list notmuch-show-mark-read-tags unread))))\r
+ \r
++(defun notmuch-show-seen-p ()\r
++ "Return t if current message has been seen."\r
++ (notmuch-show-get-prop :seen))\r
++\r
++(defun notmuch-show-mark-seen ()\r
++ "Mark current message seen."\r
++ (notmuch-show-set-prop :seen t))\r
++\r
++(defun notmuch-show-mark-all-seen-read (&optional not-mark)\r
++ "Mark read all messages that have been seen in this buffer.\r
++\r
++If NOT-MARK then do not mark the messages read, and tell the user\r
++we are not marking them."\r
++ (if not-mark\r
++ (message "Not marking messages read")\r
++ (let ((messages-to-mark-read))\r
++ ;; We get a list of all message to tag read. A list means that\r
++ ;; we can tag all the messages in one tag operation rather than\r
++ ;; needing one per read message.\r
++ (notmuch-show-mapc\r
++ (lambda ()\r
++ (when (and (notmuch-show-seen-p) (notmuch-show-unread-p))\r
++ (push (notmuch-show-get-message-id) messages-to-mark-read))))\r
++ (when messages-to-mark-read\r
++ (notmuch-tag (mapconcat #'identity messages-to-mark-read " ")\r
++ (notmuch-tag-change-list notmuch-show-mark-read-tags)))\r
++ (let ((count (length messages-to-mark-read)))\r
++ (cond ((> count 1)\r
++ (message "Marked %s messages read" count))\r
++ ((= count 1)\r
++ (message "Marked one message read"))\r
++ ((= count 0)\r
++ (message "No messages marked read")))))))\r
++\r
+ ;; Functions for getting attributes of several messages in the current\r
+ ;; thread.\r
+ \r
+-- \r
+1.7.9.1\r
+\r