[PATCH v2 1/3] emacs: show: make refresh fix point(ish)
authorMark Walters <markwalters1009@gmail.com>
Mon, 3 Dec 2012 00:58:35 +0000 (00:58 +0000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:51:21 +0000 (09:51 -0800)
df/7f1b2371f9d143b64d242539f7d7ee41bc815d [new file with mode: 0644]

diff --git a/df/7f1b2371f9d143b64d242539f7d7ee41bc815d b/df/7f1b2371f9d143b64d242539f7d7ee41bc815d
new file mode 100644 (file)
index 0000000..ade2f69
--- /dev/null
@@ -0,0 +1,132 @@
+Return-Path: <markwalters1009@gmail.com>\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 95771431FBC\r
+       for <notmuch@notmuchmail.org>; Sun,  2 Dec 2012 16:58:50 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.201\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
+       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 ZMeKvM3wYpM2 for <notmuch@notmuchmail.org>;\r
+       Sun,  2 Dec 2012 16:58:50 -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 E8FB6431FAE\r
+       for <notmuch@notmuchmail.org>; Sun,  2 Dec 2012 16:58:49 -0800 (PST)\r
+Received: by mail-wi0-f181.google.com with SMTP id hm9so717986wib.2\r
+       for <notmuch@notmuchmail.org>; Sun, 02 Dec 2012 16:58:48 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+       h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
+       bh=Ie2vyI3sDwmHFt0xL79oaSqrrtgpzgKhSJ/r8vfpKdo=;\r
+       b=CycFB17cMkHWBDyU47wgDTDXcH2YCveqq3z6j6CA5RgQGrTz+hwK8PPYgu4SFbhEi6\r
+       +iLNWRzvKj84qHbMNykO6Rkcf84NYNlKH2+vRKR64mDD+BxMkCBChcVuBtAPiNz8UCPR\r
+       rpGlG6TvIz5UVInT5J22yxkcPZnk3wnlv8KVJd76/1nBCMXQ3Q6BouP+Xi/ScsD5ioSJ\r
+       /TY1BkPORn3EsHiZwgWmq8BG7J2Bt5IDZWbr06YqIYnjTl+gtcoLUEyZ5plPOZI45HxJ\r
+       j8aTzmgCm2VLJ2NNGW/0cR5euNepCmzoy8mpOl7NM7DBzKRi+sZyHWniXeHQcpg4Xwqk\r
+       D4hQ==\r
+Received: by 10.180.93.69 with SMTP id cs5mr6918960wib.3.1354496328805;\r
+       Sun, 02 Dec 2012 16:58:48 -0800 (PST)\r
+Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
+       by mx.google.com with ESMTPS id cf6sm10289166wib.3.2012.12.02.16.58.47\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Sun, 02 Dec 2012 16:58:47 -0800 (PST)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 1/3] emacs: show: make refresh fix point(ish)\r
+Date: Mon,  3 Dec 2012 00:58:35 +0000\r
+Message-Id: <1354496317-24564-2-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <1354496317-24564-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1354496317-24564-1-git-send-email-markwalters1009@gmail.com>\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, 03 Dec 2012 00:58:50 -0000\r
+\r
+This makes a moderate attempt to keep the screen and point in the same\r
+place when refreshing (unless we are resetting state). It does this by\r
+moving to the same point relative to the start of the message, and\r
+moving that to the same line position in the screen relative to the\r
+top of the window.\r
+\r
+This fixes some mild annoyances like the whole message resetting when\r
+toggling indentation when reading a diff (ie currently you lose your\r
+place). It also makes the follow up patches in this series for\r
+toggling parts work much more nicely.\r
+---\r
+ emacs/notmuch-show.el |   25 ++++++++++++++++++-------\r
+ 1 files changed, 18 insertions(+), 7 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index 489e32c..cc0487c 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -1137,8 +1137,13 @@ function is used."\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
++ - the current message\r
++ - point relative to the top of this message\r
++ - current line number on screen of point."\r
++  (list (count-lines (window-start) (point))\r
++      (- (point) (notmuch-show-message-top))\r
++      (notmuch-show-get-message-id)\r
++      (notmuch-show-get-message-ids-for-open-messages)))\r
\r
+ (defun notmuch-show-apply-state (state)\r
+   "Apply STATE to the current buffer.\r
+@@ -1147,8 +1152,10 @@ 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
++  (let* ((height (pop state))\r
++       (relative-point (pop state))\r
++       (current (pop state))\r
++       (open (pop state)))\r
\r
+     ;; Open those that were open.\r
+     (goto-char (point-min))\r
+@@ -1158,12 +1165,16 @@ This includes:\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
++    (if (loop if (string= current (notmuch-show-get-message-id))\r
+                 return t\r
+                 until (not (notmuch-show-goto-message-next)))\r
++      (progn\r
++        (notmuch-show-message-adjust)\r
++        (forward-char relative-point)\r
++        (recenter height))\r
+       (goto-char (point-min))\r
+-      (message "Previously current message not found."))\r
+-    (notmuch-show-message-adjust)))\r
++      (message "Previously current message not found.")\r
++      (notmuch-show-message-adjust))))\r
\r
+ (defun notmuch-show-refresh-view (&optional reset-state)\r
+   "Refresh the current view.\r
+-- \r
+1.7.9.1\r
+\r