--- /dev/null
+Return-Path: <amthrax@drake.mit.edu>\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 490F6431FAE\r
+ for <notmuch@notmuchmail.org>; Tue, 21 Feb 2012 07:42:41 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[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 CKvzl7BkhEAk for <notmuch@notmuchmail.org>;\r
+ Tue, 21 Feb 2012 07:42:40 -0800 (PST)\r
+Received: from dmz-mailsec-scanner-3.mit.edu (DMZ-MAILSEC-SCANNER-3.MIT.EDU\r
+ [18.9.25.14])\r
+ by olra.theworths.org (Postfix) with ESMTP id 6CCE6431FAF\r
+ for <notmuch@notmuchmail.org>; Tue, 21 Feb 2012 07:42:40 -0800 (PST)\r
+X-AuditID: 1209190e-b7f7c6d0000008c3-fa-4f43bb6fdd9f\r
+Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
+ by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id DC.F1.02243.F6BB34F4; Tue, 21 Feb 2012 10:42:40 -0500 (EST)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+ by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id q1LFgdDG015612; \r
+ Tue, 21 Feb 2012 10:42:39 -0500\r
+Received: from drake.mit.edu\r
+ (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com\r
+ [209.6.116.242]) (authenticated bits=0)\r
+ (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+ by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q1LFgai4025723\r
+ (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+ Tue, 21 Feb 2012 10:42:38 -0500 (EST)\r
+Received: from amthrax by drake.mit.edu with local (Exim 4.77)\r
+ (envelope-from <amthrax@drake.mit.edu>)\r
+ id 1RzrrQ-0005Ou-Qz; Tue, 21 Feb 2012 10:42:36 -0500\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v3 1/3] emacs: When refreshing a show buffer,\r
+ only mark read when resetting state\r
+Date: Tue, 21 Feb 2012 10:42:31 -0500\r
+Message-Id: <1329838953-20666-2-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 1.7.7.3\r
+In-Reply-To: <1329838953-20666-1-git-send-email-amdragon@mit.edu>\r
+References: <1329632533-16152-1-git-send-email-amdragon@mit.edu>\r
+ <1329838953-20666-1-git-send-email-amdragon@mit.edu>\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFtrDIsWRmVeSWpSXmKPExsUixG6nrluw29nf4Fcno8X1mzOZLd6snMfq\r
+ wORx+OtCFo9nq24xBzBFcdmkpOZklqUW6dslcGXsP97AVHBdtGLmtZuMDYyXBLsYOTkkBEwk\r
+ Dky9yQhhi0lcuLeerYuRi0NIYB+jRM/zdnaQhJDABkaJs7tkIBL3mSRWP73KCuHMZ5To2/yC\r
+ DaSKTUBDYtv+5WCjRASkJXbenc0KYjMLWEkcvroJyObgEBZIlNjywQ0kzCKgKjFj33GwVl4B\r
+ B4mXBw+zQFyhIHFu9TmwxZwCjhLL1/1mhjiiXKJlxmTGCYz8CxgZVjHKpuRW6eYmZuYUpybr\r
+ Ficn5uWlFuka6+VmluilppRuYgQFEqck3w7GrweVDjEKcDAq8fCe2uzsL8SaWFZcmXuIUZKD\r
+ SUmUd8suoBBfUn5KZUZicUZ8UWlOavEhRgkOZiUR3sULgHK8KYmVValF+TApaQ4WJXFeNa13\r
+ fkIC6YklqdmpqQWpRTBZGQ4OJQneYyBDBYtS01Mr0jJzShDSTBycIMN5gIZ/A6nhLS5IzC3O\r
+ TIfIn2JUlBLnvQaSEABJZJTmwfXCIv0VozjQK8K8r0CqeIBJAq77FdBgJqDBLf8dQQaXJCKk\r
+ pBoYJ2+aZ2X9qjiqamWtRESexu3oWQKy2u1rp0UfWLXY61CYruPfaPXDizSi575eVrzJ9OYs\r
+ 3p5eS/+D30M95e/EpR9Ou7pdJqchZ6r7+WJ+q233XBbssK16W568KkBvnvAjrxnL1++a9J97\r
+ cc9V0yXqK1Zv+rYhxy1QT/XbpHl8E1YWeEofrJ8uqsRSnJFoqMVcVJwIABryzi7PAgAA\r
+Cc: tomi.ollila@iki.fi\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: Tue, 21 Feb 2012 15:42:41 -0000\r
+\r
+If we retain state while refreshing a show buffer, it should not mark\r
+any messages read since it's not a navigation operation (it especially\r
+shouldn't mark the first message matching the query read, which is\r
+what it did previously). If the user or caller requests that refresh\r
+reset the state of the buffer, then we consider that a navigation\r
+operation, so we do mark the message under point after the refresh\r
+read.\r
+\r
+This is implemented by moving responsibility for initial positioning\r
+and read-marking out of notmuch-show-worker and into its caller.\r
+Since notmuch-show-worker is now exclusively about building the show\r
+buffer, we rename it to notmuch-show-build-buffer.\r
+---\r
+ emacs/notmuch-show.el | 26 +++++++++++++++-----------\r
+ 1 files changed, 15 insertions(+), 11 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index aa9ccee..f759351 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -1047,9 +1047,14 @@ function is used."\r
+ (setq notmuch-show-thread-id thread-id\r
+ notmuch-show-parent-buffer parent-buffer\r
+ notmuch-show-query-context query-context)\r
+- (notmuch-show-worker)))\r
++ (notmuch-show-build-buffer)\r
+ \r
+-(defun notmuch-show-worker ()\r
++ ;; Move to the first open message and mark it read\r
++ (if (notmuch-show-message-visible-p)\r
++ (notmuch-show-mark-read)\r
++ (notmuch-show-next-open-message))))\r
++\r
++(defun notmuch-show-build-buffer ()\r
+ (let ((inhibit-read-only t))\r
+ \r
+ (notmuch-show-mode)\r
+@@ -1076,14 +1081,8 @@ function is used."\r
+ \r
+ (run-hooks 'notmuch-show-hook))\r
+ \r
+- ;; Move straight to the first open message\r
+- (unless (notmuch-show-message-visible-p)\r
+- (notmuch-show-next-open-message))\r
+-\r
+ ;; Set the header line to the subject of the first open message.\r
+- (setq header-line-format (notmuch-show-strip-re (notmuch-show-get-pretty-subject)))\r
+-\r
+- (notmuch-show-mark-read)))\r
++ (setq header-line-format (notmuch-show-strip-re (notmuch-show-get-pretty-subject)))))\r
+ \r
+ (defun notmuch-show-capture-state ()\r
+ "Capture the state of the current buffer.\r
+@@ -1130,9 +1129,14 @@ buffer is stored and re-applied after the refresh."\r
+ (if retain-state\r
+ (setq state (notmuch-show-capture-state)))\r
+ (erase-buffer)\r
+- (notmuch-show-worker)\r
++ (notmuch-show-build-buffer)\r
+ (if state\r
+- (notmuch-show-apply-state state))))\r
++ (notmuch-show-apply-state state)\r
++ ;; We're resetting state, so navigate to the first open message\r
++ ;; and mark it read, just like opening a new show buffer.\r
++ (if (notmuch-show-message-visible-p)\r
++ (notmuch-show-mark-read)\r
++ (notmuch-show-next-open-message)))))\r
+ \r
+ (defvar notmuch-show-stash-map\r
+ (let ((map (make-sparse-keymap)))\r
+-- \r
+1.7.7.3\r
+\r