[PATCH 0/2] emacs: wash: word-wrap bugfix and tweak
[notmuch-archives.git] / 0f / 5ffe2c924014f51ca442eab425d6361da7c5dd
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 1DDED431FAF\r
6         for <notmuch@notmuchmail.org>; Sun,  9 Jun 2013 21:57:39 -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.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 ex8p8YgYjjPS for <notmuch@notmuchmail.org>;\r
18         Sun,  9 Jun 2013 21:57:33 -0700 (PDT)\r
19 Received: from mail-ea0-f179.google.com (mail-ea0-f179.google.com\r
20         [209.85.215.179]) (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 AD80C431FBD\r
23         for <notmuch@notmuchmail.org>; Sun,  9 Jun 2013 21:57:26 -0700 (PDT)\r
24 Received: by mail-ea0-f179.google.com with SMTP id b15so3882109eae.24\r
25         for <notmuch@notmuchmail.org>; Sun, 09 Jun 2013 21:57:25 -0700 (PDT)\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=/rjrXVYrKPJtKMwtmKMl31jf2/xCmRSmYTgBB3dJN8s=;\r
29         b=GYX7Zt6nRbfrfzc1848gx92gr8ng6b0eP/v4R7t1ymzln5G3fZkCIFrnLKAIWMABto\r
30         uCC1yKC5IjDYWo7LKlLwt4dksiIcRjrdQFVgyowjN5EURuygchjJRhxN4lE6pIeP70Iu\r
31         zZQd64pajfuXJULaDi+IzDTClrJMXOwFSwy2WGIEJxcn1Jfk4kX5wkd0u0UdtNUbQZCL\r
32         55l9ig6IS1p0PhZqDfN+BymcjeXgkmaT9kj24twKK64/ZbYmHb4RGKA4YKDtK81VT7/k\r
33         JXR9nefs2AymXuB7E9n5traXxynjU9xgwb5J1SDvjdXX+W9Y++bAD+Q3i4ML2UiIe/Z1\r
34         qIPw==\r
35 X-Received: by 10.14.98.194 with SMTP id v42mr9072097eef.61.1370840245520;\r
36         Sun, 09 Jun 2013 21:57:25 -0700 (PDT)\r
37 Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
38         by mx.google.com with ESMTPSA id y2sm20318516eeu.2.2013.06.09.21.57.24\r
39         for <multiple recipients>\r
40         (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
41         Sun, 09 Jun 2013 21:57:25 -0700 (PDT)\r
42 From: Mark Walters <markwalters1009@gmail.com>\r
43 To: notmuch@notmuchmail.org,\r
44         Austin Clements <aclements@csail.mit.edu>\r
45 Subject: [PATCH v5 4/6] emacs: show: modify the way hidden state is recorded.\r
46 Date: Mon, 10 Jun 2013 05:57:11 +0100\r
47 Message-Id: <1370840233-23258-5-git-send-email-markwalters1009@gmail.com>\r
48 X-Mailer: git-send-email 1.7.9.1\r
49 In-Reply-To: <1370840233-23258-1-git-send-email-markwalters1009@gmail.com>\r
50 References: <1370840233-23258-1-git-send-email-markwalters1009@gmail.com>\r
51 X-BeenThere: notmuch@notmuchmail.org\r
52 X-Mailman-Version: 2.1.13\r
53 Precedence: list\r
54 List-Id: "Use and development of the notmuch mail system."\r
55         <notmuch.notmuchmail.org>\r
56 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
57         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
58 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
59 List-Post: <mailto:notmuch@notmuchmail.org>\r
60 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
61 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
62         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
63 X-List-Received-Date: Mon, 10 Jun 2013 04:57:39 -0000\r
64 \r
65 Previously, whether a part was hidden or shown was recorded in the\r
66 invisibility/visibility of the part overlay. Since we are going to\r
67 have lazily rendered parts with no overlay store the hidden/shown\r
68 state in the part button itself.\r
69 \r
70 Additionally, in preparation for the invisible part handling move the\r
71 actual hiding of the hidden parts to insert-bodypart from\r
72 create-part-overlays.\r
73 \r
74 Finally, we will need to know whether a part-insertion has done\r
75 anything (it won't if the invisible part cannot be displayed by emacs)\r
76 so we slightly rejig the code order in\r
77 notmuch-show-toggle-part-invisibility to make it easier for the\r
78 function to set an appropriate return value.\r
79 ---\r
80  emacs/notmuch-show.el |   25 ++++++++++++++-----------\r
81  1 files changed, 14 insertions(+), 11 deletions(-)\r
82 \r
83 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
84 index 0a0451b..43aa88b 100644\r
85 --- a/emacs/notmuch-show.el\r
86 +++ b/emacs/notmuch-show.el\r
87 @@ -482,7 +482,8 @@ message at DEPTH in the current thread."\r
88           (insert-button\r
89            (concat "[ " base-label " ]")\r
90            :base-label base-label\r
91 -          :type 'notmuch-show-part-button-type))\r
92 +          :type 'notmuch-show-part-button-type\r
93 +          :notmuch-part-hidden nil))\r
94      (insert "\n")\r
95      ;; return button\r
96      button))\r
97 @@ -493,20 +494,22 @@ message at DEPTH in the current thread."\r
98    (let* ((button (or button (button-at (point))))\r
99          (overlay (button-get button 'overlay)))\r
100      (when overlay\r
101 -      (let* ((show (overlay-get overlay 'invisible))\r
102 +      (let* ((show (button-get button :notmuch-part-hidden))\r
103              (new-start (button-start button))\r
104              (button-label (button-get button :base-label))\r
105              (old-point (point))\r
106              (properties (text-properties-at (point)))\r
107              (inhibit-read-only t))\r
108 -       (overlay-put overlay 'invisible (not show))\r
109 +       ;; Toggle the button itself.\r
110 +       (button-put button :notmuch-part-hidden (not show))\r
111         (goto-char new-start)\r
112         (insert "[ " button-label (if show " ]" " (hidden) ]"))\r
113         (set-text-properties new-start (point) properties)\r
114         (let ((old-end (button-end button)))\r
115           (move-overlay button new-start (point))\r
116           (delete-region (point) old-end))\r
117 -       (goto-char (min old-point (1- (button-end button))))))))\r
118 +       (goto-char (min old-point (1- (button-end button))))\r
119 +       (overlay-put overlay 'invisible (not show))))))\r
120  \r
121  ;; MIME part renderers\r
122  \r
123 @@ -793,7 +796,7 @@ message at DEPTH in the current thread."\r
124        (setq handlers (cdr handlers))))\r
125    t)\r
126  \r
127 -(defun notmuch-show-create-part-overlays (button beg end hide)\r
128 +(defun notmuch-show-create-part-overlays (button beg end)\r
129    "Add an overlay to the part between BEG and END"\r
130  \r
131    ;; If there is no button (i.e., the part is text/plain and the first\r
132 @@ -801,11 +804,8 @@ message at DEPTH in the current thread."\r
133    ;; toggleable.\r
134    (when (and button (/= beg end))\r
135      (button-put button 'overlay (make-overlay beg end))\r
136 -    ;; We toggle the button for hidden parts as that gets the\r
137 -    ;; button label right.\r
138 -    (save-excursion\r
139 -      (when hide\r
140 -       (notmuch-show-toggle-part-invisibility button)))))\r
141 +    ;; Return true if we created an overlay.\r
142 +    t))\r
143  \r
144  (defun notmuch-show-insert-bodypart (msg part depth &optional hide)\r
145    "Insert the body part PART at depth DEPTH in the current thread.\r
146 @@ -832,7 +832,10 @@ If HIDE is non-nil then initially hide this part."\r
147      ;; Ensure that the part ends with a carriage return.\r
148      (unless (bolp)\r
149        (insert "\n"))\r
150 -    (notmuch-show-create-part-overlays button content-beg (point) hide)\r
151 +    (notmuch-show-create-part-overlays button content-beg (point))\r
152 +    (when hide\r
153 +      (save-excursion\r
154 +       (notmuch-show-toggle-part-invisibility button)))\r
155      ;; Record part information.  Since we already inserted subparts,\r
156      ;; don't override existing :notmuch-part properties.\r
157      (notmuch-map-text-property beg (point) :notmuch-part\r
158 -- \r
159 1.7.9.1\r
160 \r