Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / df / 7f1b2371f9d143b64d242539f7d7ee41bc815d
1 Return-Path: <markwalters1009@gmail.com>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 95771431FBC\r
6         for <notmuch@notmuchmail.org>; Sun,  2 Dec 2012 16:58:50 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0.201\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
14         RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
15 Received: from olra.theworths.org ([127.0.0.1])\r
16         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
17         with ESMTP id ZMeKvM3wYpM2 for <notmuch@notmuchmail.org>;\r
18         Sun,  2 Dec 2012 16:58:50 -0800 (PST)\r
19 Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com\r
20         [209.85.212.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
21         (No client certificate requested)\r
22         by olra.theworths.org (Postfix) with ESMTPS id E8FB6431FAE\r
23         for <notmuch@notmuchmail.org>; Sun,  2 Dec 2012 16:58:49 -0800 (PST)\r
24 Received: by mail-wi0-f181.google.com with SMTP id hm9so717986wib.2\r
25         for <notmuch@notmuchmail.org>; Sun, 02 Dec 2012 16:58:48 -0800 (PST)\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
27         h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
28         bh=Ie2vyI3sDwmHFt0xL79oaSqrrtgpzgKhSJ/r8vfpKdo=;\r
29         b=CycFB17cMkHWBDyU47wgDTDXcH2YCveqq3z6j6CA5RgQGrTz+hwK8PPYgu4SFbhEi6\r
30         +iLNWRzvKj84qHbMNykO6Rkcf84NYNlKH2+vRKR64mDD+BxMkCBChcVuBtAPiNz8UCPR\r
31         rpGlG6TvIz5UVInT5J22yxkcPZnk3wnlv8KVJd76/1nBCMXQ3Q6BouP+Xi/ScsD5ioSJ\r
32         /TY1BkPORn3EsHiZwgWmq8BG7J2Bt5IDZWbr06YqIYnjTl+gtcoLUEyZ5plPOZI45HxJ\r
33         j8aTzmgCm2VLJ2NNGW/0cR5euNepCmzoy8mpOl7NM7DBzKRi+sZyHWniXeHQcpg4Xwqk\r
34         D4hQ==\r
35 Received: by 10.180.93.69 with SMTP id cs5mr6918960wib.3.1354496328805;\r
36         Sun, 02 Dec 2012 16:58:48 -0800 (PST)\r
37 Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
38         by mx.google.com with ESMTPS id cf6sm10289166wib.3.2012.12.02.16.58.47\r
39         (version=TLSv1/SSLv3 cipher=OTHER);\r
40         Sun, 02 Dec 2012 16:58:47 -0800 (PST)\r
41 From: Mark Walters <markwalters1009@gmail.com>\r
42 To: notmuch@notmuchmail.org\r
43 Subject: [PATCH v2 1/3] emacs: show: make refresh fix point(ish)\r
44 Date: Mon,  3 Dec 2012 00:58:35 +0000\r
45 Message-Id: <1354496317-24564-2-git-send-email-markwalters1009@gmail.com>\r
46 X-Mailer: git-send-email 1.7.9.1\r
47 In-Reply-To: <1354496317-24564-1-git-send-email-markwalters1009@gmail.com>\r
48 References: <1354496317-24564-1-git-send-email-markwalters1009@gmail.com>\r
49 X-BeenThere: notmuch@notmuchmail.org\r
50 X-Mailman-Version: 2.1.13\r
51 Precedence: list\r
52 List-Id: "Use and development of the notmuch mail system."\r
53         <notmuch.notmuchmail.org>\r
54 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
55         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
56 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
57 List-Post: <mailto:notmuch@notmuchmail.org>\r
58 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
59 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
60         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
61 X-List-Received-Date: Mon, 03 Dec 2012 00:58:50 -0000\r
62 \r
63 This makes a moderate attempt to keep the screen and point in the same\r
64 place when refreshing (unless we are resetting state). It does this by\r
65 moving to the same point relative to the start of the message, and\r
66 moving that to the same line position in the screen relative to the\r
67 top of the window.\r
68 \r
69 This fixes some mild annoyances like the whole message resetting when\r
70 toggling indentation when reading a diff (ie currently you lose your\r
71 place). It also makes the follow up patches in this series for\r
72 toggling parts work much more nicely.\r
73 ---\r
74  emacs/notmuch-show.el |   25 ++++++++++++++++++-------\r
75  1 files changed, 18 insertions(+), 7 deletions(-)\r
76 \r
77 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
78 index 489e32c..cc0487c 100644\r
79 --- a/emacs/notmuch-show.el\r
80 +++ b/emacs/notmuch-show.el\r
81 @@ -1137,8 +1137,13 @@ function is used."\r
82  \r
83  This includes:\r
84   - the list of open messages,\r
85 - - the current message."\r
86 -  (list (notmuch-show-get-message-id) (notmuch-show-get-message-ids-for-open-messages)))\r
87 + - the current message\r
88 + - point relative to the top of this message\r
89 + - current line number on screen of point."\r
90 +  (list (count-lines (window-start) (point))\r
91 +       (- (point) (notmuch-show-message-top))\r
92 +       (notmuch-show-get-message-id)\r
93 +       (notmuch-show-get-message-ids-for-open-messages)))\r
94  \r
95  (defun notmuch-show-apply-state (state)\r
96    "Apply STATE to the current buffer.\r
97 @@ -1147,8 +1152,10 @@ This includes:\r
98   - opening the messages previously opened,\r
99   - closing all other messages,\r
100   - moving to the correct current message."\r
101 -  (let ((current (car state))\r
102 -       (open (cadr state)))\r
103 +  (let* ((height (pop state))\r
104 +        (relative-point (pop state))\r
105 +        (current (pop state))\r
106 +        (open (pop state)))\r
107  \r
108      ;; Open those that were open.\r
109      (goto-char (point-min))\r
110 @@ -1158,12 +1165,16 @@ This includes:\r
111  \r
112      ;; Go to the previously open message.\r
113      (goto-char (point-min))\r
114 -    (unless (loop if (string= current (notmuch-show-get-message-id))\r
115 +    (if (loop if (string= current (notmuch-show-get-message-id))\r
116                   return t\r
117                   until (not (notmuch-show-goto-message-next)))\r
118 +       (progn\r
119 +         (notmuch-show-message-adjust)\r
120 +         (forward-char relative-point)\r
121 +         (recenter height))\r
122        (goto-char (point-min))\r
123 -      (message "Previously current message not found."))\r
124 -    (notmuch-show-message-adjust)))\r
125 +      (message "Previously current message not found.")\r
126 +      (notmuch-show-message-adjust))))\r
127  \r
128  (defun notmuch-show-refresh-view (&optional reset-state)\r
129    "Refresh the current view.\r
130 -- \r
131 1.7.9.1\r
132 \r