Re: [PATCH] emacs: address completion, allow sender/recipient and filters
[notmuch-archives.git] / 3e / 9d5ca84d5d1978105c29a0bd3a45288943e4ac
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 9B70D431FAF\r
6         for <notmuch@notmuchmail.org>; Tue, 18 Dec 2012 11:28:11 -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: 2.7\r
10 X-Spam-Level: **\r
11 X-Spam-Status: No, score=2.7 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         FREEMAIL_REPLY=2.499, 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 EOZ6o5apODAN for <notmuch@notmuchmail.org>;\r
18         Tue, 18 Dec 2012 11:28:11 -0800 (PST)\r
19 Received: from mail-wg0-f52.google.com (mail-wg0-f52.google.com\r
20  [74.125.82.52])        (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
21  certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
22  7D8C4431FAE    for <notmuch@notmuchmail.org>; Tue, 18 Dec 2012 11:28:10 -0800\r
23  (PST)\r
24 Received: by mail-wg0-f52.google.com with SMTP id 12so496982wgh.31\r
25         for <notmuch@notmuchmail.org>; Tue, 18 Dec 2012 11:28:09 -0800 (PST)\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
27         h=x-received:from:to:cc:subject:date:message-id:x-mailer;\r
28         bh=WbrqUykMafe+qR1Y6fmZb6pAGyKZN1kVLK9nywv9Clo=;\r
29         b=ij9xh3aI2lLGMj84MG3qCPEq/behGHDFm3azU34Y+gwmjbeThN4pfJ8YdF+6G3MVwq\r
30         WvmdSHkdHvdb4y9rVS9l/IMhYa5dtMJyFDlr9qCkW1TbOad6dK/50VjPgTuGMOSeJOtH\r
31         TxPP7porW2a61h22dcvMPSAKxShobWMJH10HqzQx+zBrYYJ8mW7ZAU2ZAjOuV1jaflvZ\r
32         VeJ/JeWgbW0aymKuDOVGwFRPj13DljyuTC1NMoQjXijqOC6EbOARGKeLGNct2zSiW5NF\r
33         eiT7hmLZGrcWubhYbCgWPzE3tqGYy3o5hN3VaeDkJ0u2PIDp+ehpIwzFQDdRG4DCLnpq\r
34         jaKA==\r
35 X-Received: by 10.194.87.200 with SMTP id ba8mr6767409wjb.22.1355858889083;\r
36         Tue, 18 Dec 2012 11:28:09 -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 bz12sm4119492wib.5.2012.12.18.11.28.04\r
39         (version=TLSv1/SSLv3 cipher=OTHER);\r
40         Tue, 18 Dec 2012 11:28:06 -0800 (PST)\r
41 From: Mark Walters <markwalters1009@gmail.com>\r
42 To: notmuch@notmuchmail.org\r
43 Subject: [PATCH v5 0/4] Use invisibility to toggle display of all parts\r
44         including multipart\r
45 Date: Tue, 18 Dec 2012 19:27:56 +0000\r
46 Message-Id: <1355858880-16329-1-git-send-email-markwalters1009@gmail.com>\r
47 X-Mailer: git-send-email 1.7.9.1\r
48 X-BeenThere: notmuch@notmuchmail.org\r
49 X-Mailman-Version: 2.1.13\r
50 Precedence: list\r
51 List-Id: "Use and development of the notmuch mail system."\r
52         <notmuch.notmuchmail.org>\r
53 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
54         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
55 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
56 List-Post: <mailto:notmuch@notmuchmail.org>\r
57 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
58 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
59         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
60 X-List-Received-Date: Tue, 18 Dec 2012 19:28:11 -0000\r
61 \r
62 This is an alternative version of\r
63 id:1355781287-6010-1-git-send-email-markwalters1009@gmail.com based on\r
64 top of Austin's patch at\r
65 id:1355812810-32747-1-git-send-email-amdragon@mit.edu\r
66 \r
67 Austin's patch significantly simplifies the invisibility handling\r
68 taking this series down from 90/27 to 68/26 in diffstat terms.\r
69 \r
70 In general terms Austin's approach has to be the right thing to do:\r
71 what we want to do just before the freeze is less clear. My view is\r
72 that we should go with Austin's approach now so that at least any bugs\r
73 we get from it and (more likely) from this series apply to master as\r
74 well. \r
75 \r
76 I am posting this series to make it easier for people to judge the two\r
77 approaches when finished (ie with part invisibility too).\r
78 \r
79 I attach a trimmed diff from v4 below the diffstat (note this was a\r
80 diff with -U10 which I have trimmed so it is purely for information)\r
81 \r
82 Note we no longer need patch 4/5 because in this approach the overlays\r
83 do not need to know about other overlays.\r
84 \r
85 Best wishes\r
86 \r
87 Mark\r
88 \r
89 \r
90 \r
91 \r
92 \r
93 \r
94 Mark Walters (4):\r
95   emacs: show: modify insert-part-header to save the button text\r
96   emacs: show: add overlays for each part\r
97   emacs: show: add invisibility button action\r
98   emacs: show: set default show-all-multipart/alternatives to nil\r
99 \r
100  emacs/notmuch-show.el |   94 +++++++++++++++++++++++++++++++++++-------------\r
101  1 files changed, 68 insertions(+), 26 deletions(-)\r
102 \r
103 \r
104 Diff from v4\r
105 \r
106  emacs/notmuch-show.el |   33 ++++++---------------------------\r
107  emacs/notmuch-wash.el |    2 +-\r
108  2 files changed, 7 insertions(+), 28 deletions(-)\r
109 \r
110 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
111 index ee67fec..5751d98 100644\r
112 --- a/emacs/notmuch-show.el\r
113 +++ b/emacs/notmuch-show.el\r
114 @@ -551,31 +551,28 @@ message at DEPTH in the current thread."\r
115  \r
116  ;; This is taken from notmuch-wash: maybe it should be unified?\r
117  (defun notmuch-show-toggle-part-invisibility (&optional button)\r
118    (interactive)\r
119    (let* ((button (or button (button-at (point))))\r
120 -        (overlay (button-get button 'overlay))\r
121 -        (invis-spec (button-get button 'invisibility-spec))\r
122 -        (show (invisible-p invis-spec)))\r
123 +        (overlay (button-get button 'overlay)))\r
124      (when overlay\r
125 -      (if show\r
126 -         (remove-from-invisibility-spec invis-spec)\r
127 -       (add-to-invisibility-spec invis-spec))\r
128 -      (let* ((new-start (button-start button))\r
129 +      (let* ((show (overlay-get overlay 'invisible))\r
130 +            (new-start (button-start button))\r
131              (button-label (button-get button :base-label))\r
132              (old-point (point))\r
133              (inhibit-read-only t))\r
134 +       (overlay-put overlay 'invisible (not show))\r
135         (goto-char new-start)\r
136         (insert "[ " button-label (if show " ]" " (hidden) ]"))\r
137         (let ((old-end (button-end button)))\r
138           (move-overlay button new-start (point))\r
139           (delete-region (point) old-end))\r
140         (goto-char (min old-point (1- (button-end button))))))))\r
141 \r
142 @@ -862,39 +859,21 @@ message at DEPTH in the current thread."\r
143  \r
144  (defun notmuch-show-create-part-overlays (msg beg end hide)\r
145    "Add an overlay to the part between BEG and END"\r
146    (let* ((button (button-at beg))\r
147          (part-beg (and button (1+ (button-end button)))))\r
148  \r
149      ;; If the part contains no text we do not make it toggleable. We\r
150      ;; also need to check that the button is a genuine part button not\r
151      ;; a notmuch-wash button.\r
152      (when (and button (/= part-beg end) (button-get button :base-label))\r
153 -      (let ((base-label (button-get button :base-label))\r
154 -           (overlay (make-overlay part-beg end))\r
155 -           (message-invis-spec (plist-get msg :message-invis-spec))\r
156 -           (invis-spec (make-symbol "notmuch-part-region")))\r
157 -\r
158 -       (overlay-put overlay 'invisible (list invis-spec message-invis-spec))\r
159 -       (overlay-put overlay 'priority 10)\r
160 -       ;; Now we have to add invis-spec to every overlay this\r
161 -       ;; overlay contains, otherwise these inner overlays will\r
162 -       ;; override this one.\r
163 -       (dolist (inner (overlays-in part-beg end))\r
164 -         (when (and (>= (overlay-start inner) part-beg)\r
165 -                          (<= (overlay-end inner) end))\r
166 -                 (overlay-put inner 'invisible\r
167 -                              (cons invis-spec (overlay-get inner 'invisible)))))\r
168 -\r
169 -       (button-put button 'invisibility-spec invis-spec)\r
170 -       (button-put button 'overlay overlay))\r
171 -\r
172 +      (button-put button 'overlay (make-overlay part-beg end))\r
173        ;; We toggle the button for hidden parts as that gets the\r
174        ;; button label right.\r
175        (save-excursion\r
176         (when hide\r
177           (notmuch-show-toggle-part-invisibility button))))))\r
178 \r
179 @@ -1992,21 +1971,21 @@ If optional argument MLA is non-nil, use the provided key instead of prompting\r
180  (defun notmuch-show-part-button-default (&optional button)\r
181    (interactive)\r
182    (let ((button (or button (button-at (point)))))\r
183 -    (if (button-get button 'invisibility-spec)\r
184 +    (if (button-get button 'overlay)\r
185         (notmuch-show-toggle-part-invisibility button)\r
186        (notmuch-show-part-button-internal button notmuch-show-part-button-default-action))))\r
187 \r
188 diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el\r
189 index e10ab66..d6db4fa 100644\r
190 --- a/emacs/notmuch-wash.el\r
191 +++ b/emacs/notmuch-wash.el\r
192 @@ -365,15 +365,15 @@ for error."\r
193        (save-restriction\r
194         (narrow-to-region patch-start patch-end)\r
195         (setq part (plist-put part :content-type "inline-patch-fake-part"))\r
196         (setq part (plist-put part :content (buffer-string)))\r
197         (setq part (plist-put part :id -1))\r
198         (setq part (plist-put part :filename\r
199                               (notmuch-wash-subject-to-patch-filename\r
200                                (plist-get\r
201                                 (plist-get msg :headers) :Subject))))\r
202         (delete-region (point-min) (point-max))\r
203 -       (notmuch-show-insert-bodypart msg part depth)))))\r
204 +       (notmuch-show-insert-bodypart nil part depth)))))\r
205  \r
206  ;;\r
207  \r
208  (provide 'notmuch-wash)\r
209 \r
210 -- \r
211 1.7.9.1\r
212 \r