[PATCH] RFC: all deleting all properties with a given key
[notmuch-archives.git] / c6 / 2dfa70a05852b62fdba00fb619370f552bcbae
1 Return-Path: <alex.boterolowry@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 32363431FD6\r
6         for <notmuch@notmuchmail.org>; Mon, 23 Nov 2009 23:45:29 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 Received: from olra.theworths.org ([127.0.0.1])\r
9         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
10         with ESMTP id JtOc5ycgyMSk for <notmuch@notmuchmail.org>;\r
11         Mon, 23 Nov 2009 23:45:26 -0800 (PST)\r
12 Received: from mail-yw0-f200.google.com (mail-yw0-f200.google.com\r
13         [209.85.211.200])\r
14         by olra.theworths.org (Postfix) with ESMTP id C53B2431FC2\r
15         for <notmuch@notmuchmail.org>; Mon, 23 Nov 2009 23:45:22 -0800 (PST)\r
16 Received: by mail-yw0-f200.google.com with SMTP id 38so5718812ywh.6\r
17         for <notmuch@notmuchmail.org>; Mon, 23 Nov 2009 23:45:22 -0800 (PST)\r
18 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
19         h=domainkey-signature:received:received:received:from:to:cc:subject\r
20         :date:message-id:x-mailer:in-reply-to:references;\r
21         bh=R1U0OvrP+WaIKX3PV3pf97l9MctI1czkDdSybtDMfFw=;\r
22         b=u6w3fNaSLM3Vdt0qSBfjSUqaawi49oQZlW5s8u7EDShzOkJD//wzsnHdbvYKgpCkgX\r
23         xIQZoPDdW1j8FhGBZ3aC3+hPsnRzufd2P9byBMLasS1E08xRHDTfST6JdXsT29NwGIJK\r
24         k7Ch4fjH6/iiXtB6EKD/mW+Hp1+tTdYGWIWrw=\r
25 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;\r
26         h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
27         b=kFLmcwtRjT82tKaJUyr0lvFp3tJ43o6q2B7Zl/JSXz/covDrfVP3lTwG5SzM0BQN+2\r
28         qAzgML/DTfpIvk6lWWDhYam5/7YgcvRDa68xx6sn1UXWrztWgFWpcIP0sgvB4BnD0wod\r
29         tRCTB/X5SaMvEOUZzDyFWe4qZUbZigdlRwVPg=\r
30 Received: by 10.150.235.5 with SMTP id i5mr10478286ybh.271.1259048722445;\r
31         Mon, 23 Nov 2009 23:45:22 -0800 (PST)\r
32 Received: from fortitudo (70-36-144-85.dsl.dynamic.sonic.net [70.36.144.85])\r
33         by mx.google.com with ESMTPS id 16sm2529192gxk.15.2009.11.23.23.45.20\r
34         (version=TLSv1/SSLv3 cipher=RC4-MD5);\r
35         Mon, 23 Nov 2009 23:45:21 -0800 (PST)\r
36 Received: from alexbl (uid 1001) (envelope-from alexbl@fortitudo) id 705c\r
37         by fortitudo (DragonFly Mail Agent) Mon, 23 Nov 2009 23:45:25 -0800\r
38 From: Alexander Botero-Lowry <alex.boterolowry@gmail.com>\r
39 To: notmuch@notmuchmail.org\r
40 Date: Mon, 23 Nov 2009 23:45:06 -0800\r
41 Message-Id: <1259048707-3062-4-git-send-email-alex.boterolowry@gmail.com>\r
42 X-Mailer: git-send-email 1.6.5.2\r
43 In-Reply-To: <1259048707-3062-3-git-send-email-alex.boterolowry@gmail.com>\r
44 References: <1259048707-3062-1-git-send-email-alex.boterolowry@gmail.com>\r
45         <1259048707-3062-2-git-send-email-alex.boterolowry@gmail.com>\r
46         <1259048707-3062-3-git-send-email-alex.boterolowry@gmail.com>\r
47 Subject: [notmuch] [PATCH 4/5] Make bodies locally toggleable\r
48 X-BeenThere: notmuch@notmuchmail.org\r
49 X-Mailman-Version: 2.1.12\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, 24 Nov 2009 07:45:29 -0000\r
61 \r
62 Having actually implemented this, I realized that my\r
63 initial approach of providing a function to configure\r
64 a button was wrong. Instead I've replaced that with\r
65 button types. This then makes it possible to provide\r
66 the fully expanded view when all threads in a message\r
67 are unread.\r
68 \r
69 It also has the potential to allow global-expansion functions\r
70 if that is desireable\r
71 ---\r
72  notmuch.el |   89 +++++++++++++++++++++++++++++++----------------------------\r
73  1 files changed, 47 insertions(+), 42 deletions(-)\r
74 \r
75 diff --git a/notmuch.el b/notmuch.el\r
76 index 23a07cc..af0c487 100644\r
77 --- a/notmuch.el\r
78 +++ b/notmuch.el\r
79 @@ -497,12 +497,15 @@ which this thread was originally shown."\r
80    (force-window-update)\r
81    (redisplay t))\r
82  \r
83 -(defun notmuch-configure-invisibility-button (btn invis-spec help-msg)\r
84 -  (button-put btn 'invisibility-spec invis-spec)\r
85 -  (button-put btn 'action 'notmuch-toggle-invisible-action)\r
86 -  (button-put btn 'follow-link t)\r
87 -  (button-put btn 'help-echo (concat "mouse-1, RET: " help-msg))\r
88 -)\r
89 +(define-button-type 'notmuch-button-invisibility-toggle-type 'action 'notmuch-toggle-invisible-action 'follow-link t)\r
90 +(define-button-type 'notmuch-button-citation-toggle-type 'help-echo "mouse-1, RET: Show citation"\r
91 +  :supertype 'notmuch-button-invisibility-toggle-type)\r
92 +(define-button-type 'notmuch-button-signature-toggle-type 'help-echo "mouse-1, RET: Show signature"\r
93 +  :supertype 'notmuch-button-invisibility-toggle-type)\r
94 +(define-button-type 'notmuch-button-headers-toggle-type 'help-echo "mouse-1, RET: Show headers"\r
95 +  :supertype 'notmuch-button-invisibility-toggle-type)\r
96 +(define-button-type 'notmuch-button-body-toggle-type 'help-echo "mouse-1, RET: Show message"\r
97 +  :supertype 'notmuch-button-invisibility-toggle-type)\r
98  \r
99  (defun notmuch-show-markup-citations-region (beg end depth)\r
100    (goto-char beg)\r
101 @@ -525,7 +528,9 @@ which this thread was originally shown."\r
102                               "-line citation.]")))\r
103                  (goto-char (- beg-sub 1))\r
104                  (insert (concat "\n" indent))\r
105 -                (notmuch-configure-invisibility-button (insert-button cite-button-text) invis-spec "Show citation")\r
106 +                (insert-button cite-button-text\r
107 +                               'invisibility-spec invis-spec\r
108 +                               :type 'notmuch-button-citation-toggle-type)\r
109                  (insert "\n")\r
110                  (goto-char (+ (length cite-button-text) p))\r
111                ))))\r
112 @@ -541,9 +546,11 @@ which this thread was originally shown."\r
113                    \r
114                      (goto-char (- beg-sub 1))\r
115                      (insert (concat "\n" indent))\r
116 -                    (notmuch-configure-invisibility-button\r
117 -                     (insert-button (concat "[" (number-to-string sig-lines)\r
118 -                                            "-line signature.]"))  invis-spec "Show signature")\r
119 +                    (let ((sig-button-text (concat "[" (number-to-string sig-lines)\r
120 +                                                   "-line signature.]")))\r
121 +                      (insert-button sig-button-text 'invisibility-spec invis-spec\r
122 +                                     :type 'notmuch-button-signature-toggle-type)\r
123 +                     )\r
124                      (insert "\n")\r
125                      (goto-char end))))))\r
126        (forward-line))))\r
127 @@ -572,16 +579,19 @@ which this thread was originally shown."\r
128      (while (< (point) end)\r
129        (notmuch-show-markup-part beg end depth))))\r
130  \r
131 -(defun notmuch-show-markup-body (depth)\r
132 +(defun notmuch-show-markup-body (depth btn)\r
133    (re-search-forward notmuch-show-body-begin-regexp)\r
134    (forward-line)\r
135    (let ((beg (point-marker)))\r
136      (re-search-forward notmuch-show-body-end-regexp)\r
137      (let ((end (copy-marker (match-beginning 0))))\r
138        (notmuch-show-markup-parts-region beg end depth)\r
139 -      (if (not (notmuch-show-message-unread-p))\r
140 -         (overlay-put (make-overlay beg end)\r
141 -                      'invisible 'notmuch-show-body-read))\r
142 +      (let ((invis-spec (make-symbol "notmuch-show-body-read")))\r
143 +        (overlay-put (make-overlay beg end)\r
144 +                     'invisible invis-spec)\r
145 +        (button-put btn 'invisibility-spec invis-spec)\r
146 +        (if (not (notmuch-show-message-unread-p))\r
147 +            (add-to-invisibility-spec invis-spec)))\r
148        (set-marker beg nil)\r
149        (set-marker end nil)\r
150        )))\r
151 @@ -589,10 +599,12 @@ which this thread was originally shown."\r
152  (defun notmuch-show-markup-header (depth)\r
153    (re-search-forward notmuch-show-header-begin-regexp)\r
154    (forward-line)\r
155 -  (let ((beg (point-marker)))\r
156 +  (let ((beg (point-marker))\r
157 +        (btn nil))\r
158      (end-of-line)\r
159      ; Inverse video for subject\r
160      (overlay-put (make-overlay beg (point)) 'face '(:inverse-video t))\r
161 +    (setq btn (make-button beg (point) :type 'notmuch-button-body-toggle-type))\r
162      (forward-line 1)\r
163      (end-of-line)\r
164      (let ((beg-hidden (point-marker)))\r
165 @@ -614,23 +626,25 @@ which this thread was originally shown."\r
166                         'invisible invis-spec)\r
167            (goto-char beg)\r
168            (forward-line)\r
169 -          (notmuch-configure-invisibility-button\r
170 -           (make-button (line-beginning-position) (line-end-position))\r
171 -           (cons invis-spec t) "Show headers"))\r
172 +          (make-button (line-beginning-position) (line-end-position)\r
173 +                        'invisibility-spec (cons invis-spec t)\r
174 +                        :type 'notmuch-button-headers-toggle-type))\r
175          (goto-char end)\r
176          (insert "\n")\r
177         (set-marker beg nil)\r
178         (set-marker beg-hidden nil)\r
179         (set-marker end nil)\r
180 -       ))))\r
181 +       ))\r
182 +    btn))\r
183  \r
184  (defun notmuch-show-markup-message ()\r
185    (if (re-search-forward notmuch-show-message-begin-regexp nil t)\r
186        (progn\r
187         (re-search-forward notmuch-show-depth-regexp)\r
188 -       (let ((depth (string-to-number (buffer-substring (match-beginning 1) (match-end 1)))))\r
189 -         (notmuch-show-markup-header depth)\r
190 -         (notmuch-show-markup-body depth)))\r
191 +       (let ((depth (string-to-number (buffer-substring (match-beginning 1) (match-end 1))))\r
192 +              (btn nil))\r
193 +         (setq btn (notmuch-show-markup-header depth))\r
194 +         (notmuch-show-markup-body depth btn)))\r
195      (goto-char (point-max))))\r
196  \r
197  (defun notmuch-show-hide-markers ()\r
198 @@ -650,17 +664,6 @@ which this thread was originally shown."\r
199        (notmuch-show-markup-message)))\r
200    (notmuch-show-hide-markers))\r
201  \r
202 -(defun notmuch-show-toggle-body-read-visible ()\r
203 -  "Toggle visibility of message bodies of read messages"\r
204 -  (interactive)\r
205 -  (if notmuch-show-body-read-visible\r
206 -      (add-to-invisibility-spec 'notmuch-show-body-read)\r
207 -    (remove-from-invisibility-spec 'notmuch-show-body-read))\r
208 -  (set 'notmuch-show-body-read-visible (not notmuch-show-body-read-visible))\r
209 -  ; Need to force the redisplay for some reason\r
210 -  (force-window-update)\r
211 -  (redisplay t))\r
212 -\r
213  ;;;###autoload\r
214  (defun notmuch-show-mode ()\r
215    "Major mode for viewing a thread with notmuch.\r
216 @@ -689,14 +692,6 @@ view, (remove the \"inbox\" tag from each), with\r
217  \\{notmuch-show-mode-map}"\r
218    (interactive)\r
219    (kill-all-local-variables)\r
220 -  (set (make-local-variable 'notmuch-show-headers-visible) t)\r
221 -  (notmuch-show-toggle-headers-visible)\r
222 -  (set (make-local-variable 'notmuch-show-body-read-visible) t)\r
223 -  (notmuch-show-toggle-body-read-visible)\r
224 -  (set (make-local-variable 'notmuch-show-citations-visible) t)\r
225 -  (notmuch-show-toggle-citations-visible)\r
226 -  (set (make-local-variable 'notmuch-show-signatures-visible) t)\r
227 -  (notmuch-show-toggle-signatures-visible)\r
228    (add-to-invisibility-spec 'notmuch-show-marker)\r
229    (use-local-map notmuch-show-mode-map)\r
230    (setq major-mode 'notmuch-show-mode\r
231 @@ -765,7 +760,16 @@ thread from that buffer can be show when done with this one)."\r
232             (if (not (notmuch-show-message-unread-p))\r
233                 (progn\r
234                   (goto-char (point-min))\r
235 -                 (notmuch-show-toggle-body-read-visible)))))\r
236 +                  (let ((btn (forward-button 1)))\r
237 +                    (while btn\r
238 +                      (if (button-has-type-p btn 'notmuch-button-body-toggle-type)\r
239 +                          (push-button))\r
240 +                      (condition-case err\r
241 +                          (setq btn (forward-button 1))\r
242 +                        (error (setq btn nil)))\r
243 +                    ))\r
244 +                  (beginning-of-buffer)\r
245 +                  ))))\r
246        )))\r
247  \r
248  (defvar notmuch-search-authors-width 40\r
249 @@ -803,6 +807,7 @@ thread from that buffer can be show when done with this one)."\r
250  (defvar notmuch-search-query-string)\r
251  (defvar notmuch-search-oldest-first)\r
252  \r
253 +\r
254  (defun notmuch-search-scroll-up ()\r
255    "Scroll up, moving point to last message in thread if at end."\r
256    (interactive)\r
257 -- \r
258 1.6.5.2\r
259 \r