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