From: David Edmondson Date: Thu, 2 Feb 2012 11:23:50 +0000 (+0000) Subject: [PATCH v6 5/8] emacs: Optionally retain the state of the buffer during `notmuch-show... X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=f1d09faf7cd6039bfb3939de9ff60cbed6c11fd9;p=notmuch-archives.git [PATCH v6 5/8] emacs: Optionally retain the state of the buffer during `notmuch-show-refresh-view'. --- diff --git a/c4/2ff9913ef663f83cfe645ba834102c31a0724c b/c4/2ff9913ef663f83cfe645ba834102c31a0724c new file mode 100644 index 000000000..feeb30d44 --- /dev/null +++ b/c4/2ff9913ef663f83cfe645ba834102c31a0724c @@ -0,0 +1,164 @@ +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 A7C2E431FAF + for ; Thu, 2 Feb 2012 03:24:04 -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 CGZelIx0vmFN for ; + Thu, 2 Feb 2012 03:24:03 -0800 (PST) +Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com + [209.85.212.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 033A3431FC0 + for ; Thu, 2 Feb 2012 03:24:02 -0800 (PST) +Received: by mail-wi0-f181.google.com with SMTP id hi8so1799272wib.26 + for ; Thu, 02 Feb 2012 03:24:02 -0800 (PST) +Received: by 10.180.83.104 with SMTP id p8mr17322764wiy.4.1328181842730; + Thu, 02 Feb 2012 03:24:02 -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 l6sm50941630wiv.11.2012.02.02.03.23.59 + (version=TLSv1/SSLv3 cipher=OTHER); + Thu, 02 Feb 2012 03:24:00 -0800 (PST) +Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000) + id A761BA0601; Thu, 2 Feb 2012 11:23:54 +0000 (GMT) +From: David Edmondson +To: notmuch@notmuchmail.org +Subject: [PATCH v6 5/8] emacs: Optionally retain the state of the buffer + during `notmuch-show-refresh-view'. +Date: Thu, 2 Feb 2012 11:23:50 +0000 +Message-Id: <1328181833-14988-6-git-send-email-dme@dme.org> +X-Mailer: git-send-email 1.7.8.3 +In-Reply-To: <1328181833-14988-1-git-send-email-dme@dme.org> +References: <1327486729-18052-1-git-send-email-dme@dme.org> + <1328181833-14988-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: Thu, 02 Feb 2012 11:24:04 -0000 + +With an argument, record and reply 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. + +Traditional use of refresh with the = key does not retain the +state. The recently introduced toggle commands ($, !, < and >) do +retain the state. +--- + emacs/notmuch-show.el | 56 ++++++++++++++++++++++++++++++++++++++++++------- + 1 files changed, 48 insertions(+), 8 deletions(-) + +diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +index 8d318c9..1b31166 100644 +--- a/emacs/notmuch-show.el ++++ b/emacs/notmuch-show.el +@@ -938,7 +938,7 @@ current buffer, if possible." + (message (if notmuch-show-process-crypto + "Processing cryptographic MIME parts." + "Not processing cryptographic MIME parts.")) +- (notmuch-show-refresh-view)) ++ (notmuch-show-refresh-view t)) + + (defun notmuch-show-toggle-elide-non-matching () + "Toggle the display of non-matching messages." +@@ -947,7 +947,7 @@ current buffer, if possible." + (message (if notmuch-show-elide-non-matching-messages + "Showing matching messages only." + "Showing all messages.")) +- (notmuch-show-refresh-view)) ++ (notmuch-show-refresh-view t)) + + (defun notmuch-show-toggle-thread-indentation () + "Toggle the indentation of threads." +@@ -956,7 +956,7 @@ current buffer, if possible." + (message (if notmuch-show-indent-content + "Content is indented." + "Content is not indented.")) +- (notmuch-show-refresh-view)) ++ (notmuch-show-refresh-view t)) + + (defun notmuch-show-insert-tree (tree depth) + "Insert the message tree TREE at depth DEPTH in the current thread." +@@ -1060,14 +1060,54 @@ function is used." + + (notmuch-show-mark-read))) + +-(defun notmuch-show-refresh-view () ++(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))) ++ (goto-char (point-min)) ++ (message "Previously current message not found.")) ++ (notmuch-show-message-adjust))) ++ ++(defun notmuch-show-refresh-view (&optional retain-state) + "Refresh the current view. + +-Refreshes the current view, observing changes in cryptographic preferences." ++Refreshes the current view, observing changes in display ++preferences. If RETAIN-STATE is non-nil then the state of the ++buffer is stored and re-applied after the refresh." + (interactive) +- (let ((inhibit-read-only t)) +- (erase-buffer)) +- (notmuch-show-worker)) ++ (let ((inhibit-read-only t) ++ state) ++ (if retain-state ++ (setq state (notmuch-show-capture-state))) ++ (erase-buffer) ++ (notmuch-show-worker) ++ (if state ++ (notmuch-show-apply-state state)))) + + (defvar notmuch-show-stash-map + (let ((map (make-sparse-keymap))) +-- +1.7.8.3 +