Re: [PATCH 2/3] Go bindings: wrap notmuch_message_get_date
[notmuch-archives.git] / bc / eff3737cf786cda6b12f061949aa88934f3027
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 B8B9D431FAF\r
6         for <notmuch@notmuchmail.org>; Thu, 25 Oct 2012 01:09:35 -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.224\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.224 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         HS_INDEX_PARAM=0.023, 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 GVWLE-NwvY5R for <notmuch@notmuchmail.org>;\r
18         Thu, 25 Oct 2012 01:09:34 -0700 (PDT)\r
19 Received: from mail-wg0-f45.google.com (mail-wg0-f45.google.com\r
20  [74.125.82.45])        (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  805AB431FB6    for <notmuch@notmuchmail.org>; Thu, 25 Oct 2012 01:09:34 -0700\r
23  (PDT)\r
24 Received: by mail-wg0-f45.google.com with SMTP id dq12so897880wgb.2\r
25         for <notmuch@notmuchmail.org>; Thu, 25 Oct 2012 01:09:34 -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=h/qeN0c4LCP9QLKd8DlGceDUWyKHZ7WpnaiVtjcMaDg=;\r
29         b=XWDgaoOfjGiFZk5lEokPhkNgLGcgDG8lYVg9O5qze93DJEWAMB15zhaAK6ojLF4BX0\r
30         rSkvtB1jpz6vtcSdXKBvkSBqWpeWYZJY17xSGMpN7cq4R9FAUUYKl0BW4GCgZ+ZTP+li\r
31         BjdWUd8nv9WxK9+4rjccDjJX/z941M/HC5Aw3GBtoWEOxXf7ba4nZe6Vu4bkpzJjaWvj\r
32         07rR8hQ2gfeXpamlVSQOOWWfmlB1EhJj7k2W+MfHilYzZBzJCKa1KCWwPcDZiblzL7Fr\r
33         vKCWHux0EiBAs8lS34Z0U2kstcrkbb61JWtuE47sW0f1mp3InxoD833IOC1o9Sw4jd+F\r
34         HsSQ==\r
35 Received: by 10.180.82.72 with SMTP id g8mr8438486wiy.20.1351152574147;\r
36         Thu, 25 Oct 2012 01:09:34 -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 ESMTPS id b7sm8758781wiz.3.2012.10.25.01.09.32\r
39         (version=TLSv1/SSLv3 cipher=OTHER);\r
40         Thu, 25 Oct 2012 01:09:33 -0700 (PDT)\r
41 From: Mark Walters <markwalters1009@gmail.com>\r
42 To: notmuch@notmuchmail.org\r
43 Subject: [PATCH (draft) 1/2] emacs: allow the user to toggle the visibility of\r
44         multipart/alternative parts\r
45 Date: Thu, 25 Oct 2012 09:09:22 +0100\r
46 Message-Id: <1351152563-27277-2-git-send-email-markwalters1009@gmail.com>\r
47 X-Mailer: git-send-email 1.7.9.1\r
48 In-Reply-To: <1351152563-27277-1-git-send-email-markwalters1009@gmail.com>\r
49 References: <1351152563-27277-1-git-send-email-markwalters1009@gmail.com>\r
50 X-BeenThere: notmuch@notmuchmail.org\r
51 X-Mailman-Version: 2.1.13\r
52 Precedence: list\r
53 List-Id: "Use and development of the notmuch mail system."\r
54         <notmuch.notmuchmail.org>\r
55 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
56         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
57 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
58 List-Post: <mailto:notmuch@notmuchmail.org>\r
59 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
60 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
61         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
62 X-List-Received-Date: Thu, 25 Oct 2012 08:09:36 -0000\r
63 \r
64 This patch adds a keybinding to the buttons in the notmuch-show emacs\r
65 buffer to allow the user to toggle the visibility of each part of a\r
66 message in the show buffer.  This is particularly useful for\r
67 multipart/alternative parts where the parts are not really\r
68 alternatives but contain different information.\r
69 ---\r
70  emacs/notmuch-show.el |   47 +++++++++++++++++++++++++++++++++++++++--------\r
71  1 files changed, 39 insertions(+), 8 deletions(-)\r
72 \r
73 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
74 index 0f54259..9157669 100644\r
75 --- a/emacs/notmuch-show.el\r
76 +++ b/emacs/notmuch-show.el\r
77 @@ -155,6 +155,10 @@ indentation."\r
78  (make-variable-buffer-local 'notmuch-show-indent-content)\r
79  (put 'notmuch-show-indent-content 'permanent-local t)\r
80  \r
81 +(defvar notmuch-show-message-multipart/alternative-display-parts nil)\r
82 +(make-variable-buffer-local 'notmuch-show-message-multipart/alternative-display-parts)\r
83 +(put 'notmuch-show-message-multipart/alternative-display-parts 'permanent-local t)\r
84 +\r
85  (defcustom notmuch-show-stash-mlarchive-link-alist\r
86    '(("Gmane" . "http://mid.gmane.org/")\r
87      ("MARC" . "http://marc.info/?i=")\r
88 @@ -455,6 +459,7 @@ message at DEPTH in the current thread."\r
89      (define-key map "v" 'notmuch-show-part-button-view)\r
90      (define-key map "o" 'notmuch-show-part-button-interactively-view)\r
91      (define-key map "|" 'notmuch-show-part-button-pipe)\r
92 +    (define-key map "t" 'notmuch-show-part-button-internally-show)\r
93      map)\r
94    "Submap for button commands")\r
95  (fset 'notmuch-show-part-button-map notmuch-show-part-button-map)\r
96 @@ -531,6 +536,16 @@ message at DEPTH in the current thread."\r
97      (let ((handle (mm-make-handle (current-buffer) (list content-type))))\r
98        (mm-pipe-part handle))))\r
99  \r
100 +(defun notmuch-show-internally-show-part (message-id nth &optional filename content-type)\r
101 +  "Set a part to be displayed internally"\r
102 +  (let ((current-parts (lax-plist-get notmuch-show-message-multipart/alternative-display-parts message-id)))\r
103 +    (setq notmuch-show-message-multipart/alternative-display-parts\r
104 +         (lax-plist-put notmuch-show-message-multipart/alternative-display-parts message-id\r
105 +                        (if (memq nth current-parts)\r
106 +                            (delq nth current-parts)\r
107 +                          (cons nth current-parts)))))\r
108 +  (notmuch-show-refresh-view))\r
109 +\r
110  (defun notmuch-show-multipart/*-to-list (part)\r
111    (mapcar (lambda (inner-part) (plist-get inner-part :content-type))\r
112           (plist-get part :content)))\r
113 @@ -543,12 +558,15 @@ message at DEPTH in the current thread."\r
114      ;; This inserts all parts of the chosen type rather than just one,\r
115      ;; but it's not clear that this is the wrong thing to do - which\r
116      ;; should be chosen if there are more than one that match?\r
117 +\r
118 +    ;; The variable user-parts says which parts should override the\r
119 +    ;; default so we use xor (handcoded since lisp does not have it).\r
120 +\r
121      (mapc (lambda (inner-part)\r
122             (let ((inner-type (plist-get inner-part :content-type)))\r
123 -             (if (or notmuch-show-all-multipart/alternative-parts\r
124 -                     (string= chosen-type inner-type))\r
125 -                 (notmuch-show-insert-bodypart msg inner-part depth)\r
126 -               (notmuch-show-insert-part-header (plist-get inner-part :id) inner-type inner-type nil " (not shown)"))))\r
127 +             (notmuch-show-insert-bodypart msg inner-part depth\r
128 +                                           (not (or notmuch-show-all-multipart/alternative-parts\r
129 +                                                    (string= chosen-type inner-type))))))\r
130           inner-parts)\r
131  \r
132      (when notmuch-show-indent-multipart\r
133 @@ -806,11 +824,20 @@ message at DEPTH in the current thread."\r
134        (setq handlers (cdr handlers))))\r
135    t)\r
136  \r
137 -(defun notmuch-show-insert-bodypart (msg part depth)\r
138 -  "Insert the body part PART at depth DEPTH in the current thread."\r
139 -  (let ((content-type (downcase (plist-get part :content-type)))\r
140 +(defun notmuch-show-insert-bodypart (msg part depth &optional not-shown)\r
141 +  "Insert the body part PART at depth DEPTH in the current thread.\r
142 +\r
143 +If not-shown is TRUE then do not show the part unless the user\r
144 +has overridden the default for this part"\r
145 +  (let ((user-parts (lax-plist-get notmuch-show-message-multipart/alternative-display-parts\r
146 +                                  (notmuch-id-to-query (plist-get msg :id))))\r
147 +       (content-type (downcase (plist-get part :content-type)))\r
148         (nth (plist-get part :id)))\r
149 -    (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type))\r
150 +    (when (memq nth user-parts)\r
151 +      (setq not-shown (not not-shown)))\r
152 +    (if not-shown\r
153 +       (notmuch-show-insert-part-header nth content-type content-type nil " (not shown)")\r
154 +      (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type)))\r
155    ;; Some of the body part handlers leave point somewhere up in the\r
156    ;; part, so we make sure that we're down at the end.\r
157    (goto-char (point-max))\r
158 @@ -1895,6 +1922,10 @@ the user (see `notmuch-show-stash-mlarchive-link-alist')."\r
159    (interactive)\r
160    (notmuch-show-part-button-internal button #'notmuch-show-pipe-part))\r
161  \r
162 +(defun notmuch-show-part-button-internally-show (&optional button)\r
163 +  (interactive)\r
164 +  (notmuch-show-part-button-internal button #'notmuch-show-internally-show-part))\r
165 +\r
166  (defun notmuch-show-part-button-internal (button handler)\r
167    (let ((button (or button (button-at (point)))))\r
168      (if button\r
169 -- \r
170 1.7.9.1\r
171 \r