--- /dev/null
+Return-Path: <dme@dme.org>\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 1C5D24196EC\r
+ for <notmuch@notmuchmail.org>; Mon, 30 Jan 2012 08:31:23 -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 rVsTs3Ko+pFR for <notmuch@notmuchmail.org>;\r
+ Mon, 30 Jan 2012 08:31:21 -0800 (PST)\r
+Received: from mail-ww0-f45.google.com (mail-ww0-f45.google.com\r
+ [74.125.82.45]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client\r
+ certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
+ D2AA241ED91 for <notmuch@notmuchmail.org>; Mon, 30 Jan 2012 08:31:12 -0800\r
+ (PST)\r
+Received: by mail-ww0-f45.google.com with SMTP id dt12so4198685wgb.2\r
+ for <notmuch@notmuchmail.org>; Mon, 30 Jan 2012 08:31:12 -0800 (PST)\r
+Received: by 10.180.101.101 with SMTP id ff5mr29335143wib.14.1327941072534;\r
+ Mon, 30 Jan 2012 08:31:12 -0800 (PST)\r
+Received: from hotblack-desiato.hh.sledj.net\r
+ (host81-149-164-25.in-addr.btopenworld.com. [81.149.164.25])\r
+ by mx.google.com with ESMTPS id t15sm31314359wiv.6.2012.01.30.08.31.10\r
+ (version=TLSv1/SSLv3 cipher=OTHER);\r
+ Mon, 30 Jan 2012 08:31:11 -0800 (PST)\r
+Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)\r
+ id 19441A0141; Mon, 30 Jan 2012 16:31:06 +0000 (GMT)\r
+From: David Edmondson <dme@dme.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 5/5] emacs: Retain the state of the buffer during\r
+ `notmuch-show-refresh-view'.\r
+Date: Mon, 30 Jan 2012 16:31:04 +0000\r
+Message-Id: <1327941064-20027-6-git-send-email-dme@dme.org>\r
+X-Mailer: git-send-email 1.7.8.3\r
+In-Reply-To: <1327941064-20027-1-git-send-email-dme@dme.org>\r
+References: <1327486729-18052-1-git-send-email-dme@dme.org>\r
+ <1327941064-20027-1-git-send-email-dme@dme.org>\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: Mon, 30 Jan 2012 16:31:23 -0000\r
+\r
+Record the state of the buffer during `notmuch-show-refresh-view'.\r
+\r
+In this context, "state" is defined as:\r
+ - the open/closed state of each message,\r
+ - the current message.\r
+---\r
+ emacs/notmuch-show.el | 41 +++++++++++++++++++++++++++++++++++++----\r
+ 1 files changed, 37 insertions(+), 4 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index 8b07adf..a77cd52 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -1053,15 +1053,48 @@ function is used."\r
+ \r
+ (notmuch-show-mark-read)))\r
+ \r
++(defun notmuch-show-capture-state ()\r
++ "Capture the state of the current buffer.\r
++\r
++This includes:\r
++ - the list of open messages,\r
++ - the current message."\r
++ (list (notmuch-show-get-message-id) (notmuch-show-get-message-ids-for-open-messages)))\r
++\r
++(defun notmuch-show-apply-state (state)\r
++ "Apply STATE to the current buffer.\r
++\r
++This includes:\r
++ - opening the messages previously opened,\r
++ - closing all other messages,\r
++ - moving to the correct current message."\r
++ (let ((current (car state))\r
++ (open (cadr state)))\r
++\r
++ ;; Open those that were open.\r
++ (goto-char (point-min))\r
++ (loop do (notmuch-show-message-visible (notmuch-show-get-message-properties)\r
++ (member (notmuch-show-get-message-id) open))\r
++ until (not (notmuch-show-goto-message-next)))\r
++\r
++ ;; Go to the previously open message.\r
++ (goto-char (point-min))\r
++ (unless (loop if (string= current (notmuch-show-get-message-id))\r
++ return t\r
++ until (not (notmuch-show-goto-message-next)))\r
++ (message "Previously current message not found."))))\r
++\r
+ (defun notmuch-show-refresh-view ()\r
+ "Refresh the current view.\r
+ \r
+ Refreshes the current view, observing changes in cryptographic preferences."\r
+ (interactive)\r
+- (let ((inhibit-read-only t))\r
+- (erase-buffer))\r
+- (notmuch-show-worker notmuch-show-thread-id notmuch-show-parent-buffer\r
+- notmuch-show-query-context))\r
++ (let ((inhibit-read-only t)\r
++ (state (notmuch-show-capture-state)))\r
++ (erase-buffer)\r
++ (notmuch-show-worker notmuch-show-thread-id notmuch-show-parent-buffer\r
++ notmuch-show-query-context)\r
++ (notmuch-show-apply-state state)))\r
+ \r
+ (defvar notmuch-show-stash-map\r
+ (let ((map (make-sparse-keymap)))\r
+-- \r
+1.7.8.3\r
+\r