[PATCH 2/2] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 03 / f832f443df5fea03dc5778c0f87b420e7a8334
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 arlo.cworth.org (Postfix) with ESMTP id 9E3F46DE1704\r
6  for <notmuch@notmuchmail.org>; Sat,  7 Nov 2015 03:04:47 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0.216\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.216 tagged_above=-999 required=5 tests=[AWL=0.086, \r
12  DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13  FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001,\r
14  RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001]\r
15  autolearn=disabled\r
16 Received: from arlo.cworth.org ([127.0.0.1])\r
17  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
18  with ESMTP id JPS_-oNifwib for <notmuch@notmuchmail.org>;\r
19  Sat,  7 Nov 2015 03:04:45 -0800 (PST)\r
20 Received: from mail-wm0-f43.google.com (mail-wm0-f43.google.com\r
21  [74.125.82.43]) by arlo.cworth.org (Postfix) with ESMTPS id 79D4E6DE1638 for\r
22  <notmuch@notmuchmail.org>; Sat,  7 Nov 2015 03:04:45 -0800 (PST)\r
23 Received: by wmec201 with SMTP id c201so36450094wme.1\r
24  for <notmuch@notmuchmail.org>; Sat, 07 Nov 2015 03:04:43 -0800 (PST)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
26  h=from:to:cc:subject:date:message-id:in-reply-to:references;\r
27  bh=J/qV1mSM63xzZqbo3TsxfCcFBNS/xFk3u/GRd8Szh6Q=;\r
28  b=PTVsNniNA+r61PuykV9umQAiYPkfK+PA+R2y8RIqPp3XUkPm2H7F8vZzp2YVyVWs7n\r
29  rJ8t36JEp8DwlRK18kQs+ZI7uF8rw7hAiFB86FivPa0wptHJS7iJvmkbs4x39MP4b68z\r
30  XE52qRXqcovDZp9IMxMnJ099smU+SHKfM+9ptKPS/5kZHiooXZUXTkggCV7eq2w3GJTC\r
31  XXFNVTxuv1pTA2pxu3GprvUPXcZHN4BkFzdp7evhmv98eu+XEsL+KjThKW2UA5boysH9\r
32  ACYO/Sf6Nfkun4yoCDI6F9X88qZBQm6KRy0lUCxQ8MMn4vZJponOJeAuPs+e/dqrQZTK\r
33  7Unw==\r
34 X-Received: by 10.28.137.194 with SMTP id l185mr14649082wmd.21.1446894283619; \r
35  Sat, 07 Nov 2015 03:04:43 -0800 (PST)\r
36 Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162])\r
37  by smtp.gmail.com with ESMTPSA id 71sm3418994wmm.24.2015.11.07.03.04.42\r
38  (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
39  Sat, 07 Nov 2015 03:04:42 -0800 (PST)\r
40 From: Mark Walters <markwalters1009@gmail.com>\r
41 To: notmuch@notmuchmail.org\r
42 Subject: [PATCH v4 1/7] emacs/show: Re-arrange determination if a part header\r
43  is necessary\r
44 Date: Sat,  7 Nov 2015 11:04:30 +0000\r
45 Message-Id: <1446894276-7814-2-git-send-email-markwalters1009@gmail.com>\r
46 X-Mailer: git-send-email 2.1.4\r
47 In-Reply-To: <1446894276-7814-1-git-send-email-markwalters1009@gmail.com>\r
48 References: <1446894276-7814-1-git-send-email-markwalters1009@gmail.com>\r
49 X-BeenThere: notmuch@notmuchmail.org\r
50 X-Mailman-Version: 2.1.20\r
51 Precedence: list\r
52 List-Id: "Use and development of the notmuch mail system."\r
53  <notmuch.notmuchmail.org>\r
54 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
55  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
56 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
57 List-Post: <mailto:notmuch@notmuchmail.org>\r
58 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
59 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
60  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
61 X-List-Received-Date: Sat, 07 Nov 2015 11:04:47 -0000\r
62 \r
63 From: David Edmondson <dme@dme.org>\r
64 \r
65 Move the determination of whether a part header is required to a\r
66 distinct function.\r
67 ---\r
68  emacs/notmuch-show.el | 25 ++++++++++++++++++-------\r
69  1 file changed, 18 insertions(+), 7 deletions(-)\r
70 \r
71 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
72 index 49fd198..47a02e5 100644\r
73 --- a/emacs/notmuch-show.el\r
74 +++ b/emacs/notmuch-show.el\r
75 @@ -929,6 +929,21 @@ (defun notmuch-show-lazy-part (part-args button)\r
76        ;; showable this returns nil.\r
77        (notmuch-show-create-part-overlays button part-beg part-end))))\r
78  \r
79 +(defun notmuch-show-mime-type (part)\r
80 +  "Return the correct mime-type to use for PART."\r
81 +  (let ((content-type (downcase (plist-get part :content-type))))\r
82 +    (or (and (string= content-type "application/octet-stream")\r
83 +            (notmuch-show-get-mime-type-of-application/octet-stream part))\r
84 +       (and (string= content-type "inline patch")\r
85 +            "text/x-diff")\r
86 +       content-type)))\r
87 +\r
88 +(defun notmuch-show-insert-header-p (part hide)\r
89 +  "Return non-NIL if a header button should be inserted for this part."\r
90 +  (let ((mime-type (notmuch-show-mime-type part)))\r
91 +    (not (and (string= mime-type "text/plain")\r
92 +             (<= (plist-get part :id) 1)))))\r
93 +\r
94  (defun notmuch-show-insert-bodypart (msg part depth &optional hide)\r
95    "Insert the body part PART at depth DEPTH in the current thread.\r
96  \r
97 @@ -939,11 +954,7 @@ (defun notmuch-show-insert-bodypart (msg part depth &optional hide)\r
98  useful for quoting in replies)."\r
99  \r
100    (let* ((content-type (downcase (plist-get part :content-type)))\r
101 -        (mime-type (or (and (string= content-type "application/octet-stream")\r
102 -                            (notmuch-show-get-mime-type-of-application/octet-stream part))\r
103 -                       (and (string= content-type "inline patch")\r
104 -                            "text/x-diff")\r
105 -                       content-type))\r
106 +        (mime-type (notmuch-show-mime-type part))\r
107          (nth (plist-get part :id))\r
108          (long (and (notmuch-match-content-type mime-type "text/*")\r
109                     (> notmuch-show-max-text-part-size 0)\r
110 @@ -951,8 +962,8 @@ (defun notmuch-show-insert-bodypart (msg part depth &optional hide)\r
111          (beg (point))\r
112          ;; We omit the part button for the first (or only) part if\r
113          ;; this is text/plain, or HIDE is 'no-buttons.\r
114 -        (button (unless (or (equal hide 'no-buttons)\r
115 -                            (and (string= mime-type "text/plain") (<= nth 1)))\r
116 +        (button (when (and (not (equal hide 'no-buttons))\r
117 +                           (notmuch-show-insert-header-p part hide))\r
118                    (notmuch-show-insert-part-header nth mime-type content-type (plist-get part :filename))))\r
119          ;; Hide the part initially if HIDE is t, or if it is too long\r
120          ;; and we have a button to allow toggling (thus reply which\r
121 -- \r
122 2.1.4\r
123 \r