[PATCH v6 5/8] emacs: Optionally retain the state of the buffer during `notmuch-show...
authorDavid Edmondson <dme@dme.org>
Thu, 2 Feb 2012 11:23:50 +0000 (11:23 +0000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:43:56 +0000 (09:43 -0800)
c4/2ff9913ef663f83cfe645ba834102c31a0724c [new file with mode: 0644]

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