Re: [PATCH v2] Omit User-Agent: header by default
[notmuch-archives.git] / c4 / cf61ed43d7306e9384288a9b58f010a53f34b6
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 AEA41431FBC\r
6         for <notmuch@notmuchmail.org>; Sun,  2 Dec 2012 16:59:04 -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: 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 PEcaEqbEhoq8 for <notmuch@notmuchmail.org>;\r
18         Sun,  2 Dec 2012 16:59:00 -0800 (PST)\r
19 Received: from mail-wg0-f47.google.com (mail-wg0-f47.google.com\r
20  [74.125.82.47])        (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  8C1A1431FC0    for <notmuch@notmuchmail.org>; Sun,  2 Dec 2012 16:58:52 -0800\r
23  (PST)\r
24 Received: by mail-wg0-f47.google.com with SMTP id dq11so1088819wgb.2\r
25         for <notmuch@notmuchmail.org>; Sun, 02 Dec 2012 16:58:51 -0800 (PST)\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=5wd9b27rjZYb3raJe7qIguUAH0rI2LNuqZOy14ACoVs=;\r
29         b=v4bVfzUySonKeR4Jha9t5iFtfA/7TQ8oYUvnwuVG+Aqgg/EcGSS6dGoO4u/JrQT/CG\r
30         37ux78gYnXoCq8pKIkVt1iRGCd5SqMU+V1Utl43n3MivSNvW+Gnh4JEA1ZC9Kmb9dAet\r
31         Pa5iuKhTzGk/gVKjWIiZN04gq574X+LY03qGqJX/aCGTe9b6apCUXxzBa723iI0FJRPS\r
32         DPU/ovWGE1nePYkQLKGXvTTkZ/0BrOa5mTTcToWIucdfzAcA+/vLWTvsVAeX/N956mj0\r
33         v1lN4FkZNAxaT3Y7N5/lMKPjwEAgZNYSW4Fx0vrrfs6XuBT+kF25VelzaArhvHCCx5ao\r
34         qT2A==\r
35 Received: by 10.180.73.80 with SMTP id j16mr6912588wiv.5.1354496331325;\r
36         Sun, 02 Dec 2012 16:58:51 -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 en20sm10287474wid.4.2012.12.02.16.58.49\r
39         (version=TLSv1/SSLv3 cipher=OTHER);\r
40         Sun, 02 Dec 2012 16:58:50 -0800 (PST)\r
41 From: Mark Walters <markwalters1009@gmail.com>\r
42 To: notmuch@notmuchmail.org\r
43 Subject: [PATCH v2 2/3] emacs: allow the user to toggle the visibility of\r
44         multipart/alternative parts\r
45 Date: Mon,  3 Dec 2012 00:58:36 +0000\r
46 Message-Id: <1354496317-24564-3-git-send-email-markwalters1009@gmail.com>\r
47 X-Mailer: git-send-email 1.7.9.1\r
48 In-Reply-To: <1354496317-24564-1-git-send-email-markwalters1009@gmail.com>\r
49 References: <1354496317-24564-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: Mon, 03 Dec 2012 00:59:04 -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 |   48 +++++++++++++++++++++++++++++++++++++++---------\r
71  1 files changed, 39 insertions(+), 9 deletions(-)\r
72 \r
73 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
74 index cc0487c..9a33d28 100644\r
75 --- a/emacs/notmuch-show.el\r
76 +++ b/emacs/notmuch-show.el\r
77 @@ -154,6 +154,11 @@ 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 +  "A list of message-ids/parts where the user has overridden notmuch display choice")\r
83 +(make-variable-buffer-local 'notmuch-show-message-multipart/alternative-display-parts)\r
84 +(put 'notmuch-show-message-multipart/alternative-display-parts 'permanent-local t)\r
85 +\r
86  (defcustom notmuch-show-stash-mlarchive-link-alist\r
87    '(("Gmane" . "http://mid.gmane.org/")\r
88      ("MARC" . "http://marc.info/?i=")\r
89 @@ -469,6 +474,7 @@ message at DEPTH in the current thread."\r
90      (define-key map "v" 'notmuch-show-part-button-view)\r
91      (define-key map "o" 'notmuch-show-part-button-interactively-view)\r
92      (define-key map "|" 'notmuch-show-part-button-pipe)\r
93 +    (define-key map "t" 'notmuch-show-part-button-internally-show)\r
94      map)\r
95    "Submap for button commands")\r
96  (fset 'notmuch-show-part-button-map notmuch-show-part-button-map)\r
97 @@ -545,6 +551,16 @@ message at DEPTH in the current thread."\r
98      (let ((handle (mm-make-handle (current-buffer) (list content-type))))\r
99        (mm-pipe-part handle))))\r
100  \r
101 +(defun notmuch-show-internally-show-part (message-id nth &optional filename content-type)\r
102 +  "Set a part to be displayed internally"\r
103 +  (let ((current-parts (lax-plist-get notmuch-show-message-multipart/alternative-display-parts message-id)))\r
104 +    (setq notmuch-show-message-multipart/alternative-display-parts\r
105 +         (lax-plist-put notmuch-show-message-multipart/alternative-display-parts message-id\r
106 +                        (if (memq nth current-parts)\r
107 +                            (delq nth current-parts)\r
108 +                          (cons nth current-parts)))))\r
109 +  (notmuch-show-refresh-view))\r
110 +\r
111  (defun notmuch-show-multipart/*-to-list (part)\r
112    (mapcar (lambda (inner-part) (plist-get inner-part :content-type))\r
113           (plist-get part :content)))\r
114 @@ -557,12 +573,12 @@ message at DEPTH in the current thread."\r
115      ;; This inserts all parts of the chosen type rather than just one,\r
116      ;; but it's not clear that this is the wrong thing to do - which\r
117      ;; should be chosen if there are more than one that match?\r
118 +\r
119      (mapc (lambda (inner-part)\r
120             (let ((inner-type (plist-get inner-part :content-type)))\r
121 -             (if (or notmuch-show-all-multipart/alternative-parts\r
122 -                     (string= chosen-type inner-type))\r
123 -                 (notmuch-show-insert-bodypart msg inner-part depth)\r
124 -               (notmuch-show-insert-part-header (plist-get inner-part :id) inner-type inner-type nil " (not shown)"))))\r
125 +             (notmuch-show-insert-bodypart msg inner-part depth\r
126 +                                           (not (or notmuch-show-all-multipart/alternative-parts\r
127 +                                                    (string= chosen-type inner-type))))))\r
128           inner-parts)\r
129  \r
130      (when notmuch-show-indent-multipart\r
131 @@ -830,11 +846,20 @@ message at DEPTH in the current thread."\r
132        (setq handlers (cdr handlers))))\r
133    t)\r
134  \r
135 -(defun notmuch-show-insert-bodypart (msg part depth)\r
136 -  "Insert the body part PART at depth DEPTH in the current thread."\r
137 -  (let ((content-type (downcase (plist-get part :content-type)))\r
138 +(defun notmuch-show-insert-bodypart (msg part depth &optional not-shown)\r
139 +  "Insert the body part PART at depth DEPTH in the current thread.\r
140 +\r
141 +If not-shown is TRUE then do not show the part unless the user\r
142 +has overridden the default for this part"\r
143 +  (let ((user-parts (lax-plist-get notmuch-show-message-multipart/alternative-display-parts\r
144 +                                  (notmuch-id-to-query (plist-get msg :id))))\r
145 +       (content-type (downcase (plist-get part :content-type)))\r
146         (nth (plist-get part :id)))\r
147 -    (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type))\r
148 +    (when (memq nth user-parts)\r
149 +      (setq not-shown (not not-shown)))\r
150 +    (if not-shown\r
151 +       (notmuch-show-insert-part-header nth content-type content-type nil " (not shown)")\r
152 +      (notmuch-show-insert-bodypart-internal msg part content-type nth depth content-type)))\r
153    ;; Some of the body part handlers leave point somewhere up in the\r
154    ;; part, so we make sure that we're down at the end.\r
155    (goto-char (point-max))\r
156 @@ -1185,7 +1210,8 @@ non-nil) then the state of the buffer (open/closed messages) is\r
157  reset based on the original query."\r
158    (interactive "P")\r
159    (let ((inhibit-read-only t)\r
160 -       (state (unless reset-state\r
161 +       (state (if reset-state\r
162 +                  (setq notmuch-show-message-multipart/alternative-display-parts nil)\r
163                  (notmuch-show-capture-state))))\r
164      (erase-buffer)\r
165      (notmuch-show-build-buffer)\r
166 @@ -1980,6 +2006,10 @@ the user (see `notmuch-show-stash-mlarchive-link-alist')."\r
167    (interactive)\r
168    (notmuch-show-part-button-internal button #'notmuch-show-pipe-part))\r
169  \r
170 +(defun notmuch-show-part-button-internally-show (&optional button)\r
171 +  (interactive)\r
172 +  (notmuch-show-part-button-internal button #'notmuch-show-internally-show-part))\r
173 +\r
174  (defun notmuch-show-part-button-internal (button handler)\r
175    (let ((button (or button (button-at (point)))))\r
176      (if button\r
177 -- \r
178 1.7.9.1\r
179 \r