--- /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 9B553431E62\r
+ for <notmuch@notmuchmail.org>; Sun, 1 Dec 2013 02:02:44 -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 G00pTmjJPYES for <notmuch@notmuchmail.org>;\r
+ Sun, 1 Dec 2013 02:02:38 -0800 (PST)\r
+Received: from mail-wg0-f48.google.com (mail-wg0-f48.google.com\r
+ [74.125.82.48]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client\r
+ certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
+ E2F7A431FAF for <notmuch@notmuchmail.org>; Sun, 1 Dec 2013 02:02:37 -0800\r
+ (PST)\r
+Received: by mail-wg0-f48.google.com with SMTP id z12so10804144wgg.27\r
+ for <notmuch@notmuchmail.org>; Sun, 01 Dec 2013 02:02:36 -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=3Vf/imofLOIgUyrlDJFL9j2d6ZxpoFu8Uaygb2bfDf0=;\r
+ b=sqj4QuTd6sIKPC5gy7tZMFdh9ChDM1G+Ip4I0R9J1JtYOxGwHRbAr21CK5H0LHF3Xi\r
+ GUJ3GOqU35ciYp5yJedktFCfmWiUl2lj+BandGQUQ0V5RJ3l808t8le/P6oDi1OseC7s\r
+ k0cMZf8lAxWj0didX5sOc5BjFRVrcSr2qCKdQ90NbpGYmptAgjTAVJGLa9YEndVf1A40\r
+ jTPpzp49wu8q7KbRbXV96VVFl75QCPbnMkxtizlUvaFqXaPN3MSa+g1oeYwf5m+ux2kC\r
+ XnEbFtUT7G5ZnffJ20D/m0viv7YFRLpOU4/79X0KInTGaVsQBLiNcvf0vhqw9uzMq9ul\r
+ yiFQ==\r
+X-Received: by 10.180.210.232 with SMTP id mx8mr13811800wic.34.1385892156568; \r
+ Sun, 01 Dec 2013 02:02:36 -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 f11sm93688599wic.4.2013.12.01.02.02.35\r
+ for <multiple recipients>\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Sun, 01 Dec 2013 02:02:36 -0800 (PST)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH WIP v2 3/6] emacs: show: sync seen to read on quit and refresh\r
+Date: Sun, 1 Dec 2013 10:02:24 +0000\r
+Message-Id: <1385892147-16994-4-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:02:44 -0000\r
+\r
+This makes notmuch show buffers mark all seen messages as read when\r
+quitting or refreshing the show buffer, accept in the case these are\r
+called with a prefix argument.\r
+\r
+This slightly overloads the prefix-argument to refresh: as it tells\r
+refresh not to save state either. This is probably OK as it says "make\r
+the buffer look like the database".\r
+\r
+Note, at this point the seen functionality is not yet used: that is\r
+nothing yet marks a message seen.\r
+---\r
+ emacs/notmuch-show.el | 15 +++++++++++++++\r
+ 1 files changed, 15 insertions(+), 0 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index c63d295..05f649b 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -1213,6 +1213,11 @@ preferences. If invoked with a prefix argument (or RESET-STATE is\r
+ non-nil) then the state of the buffer (open/closed messages) is\r
+ reset based on the original query."\r
+ (interactive "P")\r
++ ;; Do not mark seen messages read if we are resetting state. The\r
++ ;; idea is that resetting state is asking for the view to be reset\r
++ ;; to the current state of the database.\r
++ (notmuch-show-mark-all-seen-read reset-state)\r
++\r
+ (let ((inhibit-read-only t)\r
+ (state (unless reset-state\r
+ (notmuch-show-capture-state))))\r
+@@ -1258,6 +1263,8 @@ reset based on the original query."\r
+ (defvar notmuch-show-mode-map\r
+ (let ((map (make-sparse-keymap)))\r
+ (set-keymap-parent map notmuch-common-keymap)\r
++ ;; the following overrides the common-keymap quit\r
++ (define-key map [remap notmuch-kill-this-buffer] 'notmuch-show-quit-and-mark-read)\r
+ (define-key map "Z" 'notmuch-tree-from-show-current-query)\r
+ (define-key map (kbd "<C-tab>") 'widget-backward)\r
+ (define-key map (kbd "M-TAB") 'notmuch-show-previous-button)\r
+@@ -1570,6 +1577,14 @@ we are not marking them."\r
+ ((= count 0)\r
+ (message "No messages marked read")))))))\r
+ \r
++(put 'notmuch-show-quit-and-mark-read 'notmuch-prefix-doc\r
++ "... without marking seen messages read.")\r
++(defun notmuch-show-quit-and-mark-read (&optional not-mark)\r
++ "Kill the current buffer marking seen messages read."\r
++ (interactive "P")\r
++ (notmuch-show-mark-all-seen-read not-mark)\r
++ (notmuch-kill-this-buffer))\r
++\r
+ ;; Functions for getting attributes of several messages in the current\r
+ ;; thread.\r
+ \r
+-- \r
+1.7.9.1\r
+\r