Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / a2 / 23c5a148f70249ddd61e22bc9dbb0610926615
1 Return-Path: <cworth@cworth.org>\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 AC4DF431FD0\r
6         for <notmuch@notmuchmail.org>; Tue, 24 May 2011 16:20:42 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id GyIuJHuueBrN for <notmuch@notmuchmail.org>;\r
16         Tue, 24 May 2011 16:20:42 -0700 (PDT)\r
17 Received: from arlo.cworth.org (arlo.cworth.org [50.43.72.2])\r
18         by olra.theworths.org (Postfix) with ESMTP id 0A485431FB6\r
19         for <notmuch@notmuchmail.org>; Tue, 24 May 2011 16:20:42 -0700 (PDT)\r
20 Received: from yoom.home.cworth.org (localhost [127.0.0.1])\r
21         by arlo.cworth.org (Postfix) with ESMTP id 7D5DA29A482;\r
22         Tue, 24 May 2011 16:20:40 -0700 (PDT)\r
23 Received: by yoom.home.cworth.org (Postfix, from userid 1000)\r
24         id 6D5E625417E; Tue, 24 May 2011 16:20:40 -0700 (PDT)\r
25 From: Carl Worth <cworth@cworth.org>\r
26 To: Austin Clements <amdragon@mit.edu>,\r
27         Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
28 Subject: Re: [PATCH] Save and restore point explicitly in\r
29         `notmuch-wash-toggle-invisible-action'.\r
30 In-Reply-To: <BANLkTi=_PszwPDRbRxVpVhkT=YRAi5dGDQ@mail.gmail.com>\r
31 References: <1306090675-26982-1-git-send-email-dmitry.kurochkin@gmail.com>\r
32         <1306164587-20326-1-git-send-email-dmitry.kurochkin@gmail.com>\r
33         <87oc2rlujb.fsf@yoom.home.cworth.org> <8762ozrfrr.fsf@gmail.com>\r
34         <87oc2rvjvj.fsf@yoom.home.cworth.org> <871uznrbh5.fsf@gmail.com>\r
35         <BANLkTi=_PszwPDRbRxVpVhkT=YRAi5dGDQ@mail.gmail.com>\r
36 User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.3.1\r
37         (i486-pc-linux-gnu)\r
38 Date: Tue, 24 May 2011 16:20:34 -0700\r
39 Message-ID: <87d3j7bs8t.fsf@yoom.home.cworth.org>\r
40 MIME-Version: 1.0\r
41 Content-Type: multipart/signed; boundary="==-=-=";\r
42         micalg=pgp-sha1; protocol="application/pgp-signature"\r
43 Cc: notmuch@notmuchmail.org\r
44 X-BeenThere: notmuch@notmuchmail.org\r
45 X-Mailman-Version: 2.1.13\r
46 Precedence: list\r
47 List-Id: "Use and development of the notmuch mail system."\r
48         <notmuch.notmuchmail.org>\r
49 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
50         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
51 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
52 List-Post: <mailto:notmuch@notmuchmail.org>\r
53 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
54 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
55         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
56 X-List-Received-Date: Tue, 24 May 2011 23:20:42 -0000\r
57 \r
58 --==-=-=\r
59 Content-Type: multipart/mixed; boundary="=-=-="\r
60 \r
61 --=-=-=\r
62 Content-Transfer-Encoding: quoted-printable\r
63 \r
64 On Tue, 24 May 2011 18:43:41 -0400, Austin Clements <amdragon@mit.edu> wrot=\r
65 e:\r
66 > Saving point this way is a bit dangerous, though.  For example, if\r
67 > you're near the end of the buffer and shorten the label, attempting to\r
68 > restore the point could result in an error (or, a more benign example:\r
69 > the cursor could wind up outside the label so pressing RET repeatedly\r
70 > won't toggle it).\r
71 >=20\r
72 > Unfortunately, I don't know of a clean solution to this, but I think I\r
73 > would rather the cursor move, but stay within the label (probably\r
74 > moving to the beginning), than have problems like the above.\r
75 \r
76 Here's my fix. Let me know what you think.\r
77 \r
78 =2DCarl\r
79 \r
80 \r
81 --=-=-=\r
82 Content-Type: text/x-diff\r
83 Content-Disposition: inline;\r
84  filename=0001-Carefully-preverse-point-when-changing-button-text-i.patch\r
85 Content-Transfer-Encoding: quoted-printable\r
86 \r
87 From=20a32e02bf0d2b57d51695f7d4ea6cdda9acb21322 Mon Sep 17 00:00:00 2001\r
88 From: Carl Worth <cworth@cworth.org>\r
89 Date: Mon, 23 May 2011 19:29:46 +0400\r
90 Subject: [PATCH] Carefully preverse point when changing button text in\r
91  `notmuch-wash-toggle-invisible-action'.\r
92 \r
93 Previously, save-excursion was used to attempt to save the point, but\r
94 this was unreliable since the region containing the marker saved by\r
95 save-excursion was deleted. Instead, we save an integer position\r
96 indicating the offset of point within the old button. Then, we restore\r
97 point to the same offset within the new button, (but cap the offset to\r
98 avoid leaving the button entirely).\r
99 =2D--\r
100  emacs/notmuch-wash.el |   13 +++++++------\r
101  1 files changed, 7 insertions(+), 6 deletions(-)\r
102 \r
103 diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el\r
104 index 8455eee..3dceb8b 100644\r
105 =2D-- a/emacs/notmuch-wash.el\r
106 +++ b/emacs/notmuch-wash.el\r
107 @@ -82,13 +82,14 @@ collapse the remaining lines into a button.")\r
108    (let* ((new-start (button-start cite-button))\r
109          (overlay (button-get cite-button 'overlay))\r
110          (button-label (notmuch-wash-button-label overlay))\r
111 +        (button-offset (- (point) new-start))\r
112          (inhibit-read-only t))\r
113 =2D    (save-excursion\r
114 =2D      (goto-char new-start)\r
115 =2D      (insert button-label)\r
116 =2D      (let ((old-end (button-end cite-button)))\r
117 =2D     (move-overlay cite-button new-start (point))\r
118 =2D     (delete-region (point) old-end))))\r
119 +    (goto-char new-start)\r
120 +    (insert button-label)\r
121 +    (let ((old-end (button-end cite-button)))\r
122 +      (move-overlay cite-button new-start (point))\r
123 +      (delete-region (point) old-end))\r
124 +    (goto-char (min (button-end cite-button) (+ new-start button-offset))))\r
125    (force-window-update)\r
126    (redisplay t))\r
127 =20\r
128 =2D-=20\r
129 1.7.5.1\r
130 \r
131 \r
132 --=-=-=--\r
133 \r
134 --==-=-=\r
135 Content-Type: application/pgp-signature\r
136 \r
137 -----BEGIN PGP SIGNATURE-----\r
138 Version: GnuPG v1.4.11 (GNU/Linux)\r
139 \r
140 iEYEARECAAYFAk3cPUIACgkQ6JDdNq8qSWh5CQCfS5/Ou7cLRlPUPCR1cdsZyndT\r
141 kaEAnRLbfPoD2mFfLD2Y+c7A/PqEERkY\r
142 =IDmP\r
143 -----END PGP SIGNATURE-----\r
144 --==-=-=--\r