Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / f6 / 1cfdfa5dc1f05730f09645de68a52bcbba6c65
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 EDE216DE1ABD\r
6  for <notmuch@notmuchmail.org>; Sun, 14 Feb 2016 10:40:22 -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.245\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.245 tagged_above=-999 required=5 tests=[AWL=0.325,\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, RCVD_IN_DNSWL_LOW=-0.7,\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 6_C7_sSPvTsp for <notmuch@notmuchmail.org>;\r
19  Sun, 14 Feb 2016 10:40:21 -0800 (PST)\r
20 Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com\r
21  [74.125.82.67]) by arlo.cworth.org (Postfix) with ESMTPS id AFEC06DE10C1 for\r
22  <notmuch@notmuchmail.org>; Sun, 14 Feb 2016 10:40:13 -0800 (PST)\r
23 Received: by mail-wm0-f67.google.com with SMTP id b205so4795312wmb.1\r
24  for <notmuch@notmuchmail.org>; Sun, 14 Feb 2016 10:40:13 -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=cz2au64fdOj5I+AU71A0uiMe2HpsCJ7bi5iFMjCPT4U=;\r
28  b=W8ju5XDl9F1vbCbKoeQ+B4cyiCMisx18nahqNBl8UQM+XjgymU9sGN4/N9jhrkKn5Z\r
29  ZZA57zjjlgn7kI1MVD7oG60TUZnRN8ScKyD1HoSHHmpL0Yp+WO9tTQuDh9mLXWISaj8O\r
30  G8npDCX3uWFGwuYw4boW7Ek1cj/YzoOCpb+SyjwsgI5T6se9FmkXAQnxOea1dyq1iIN7\r
31  5GfD7si6vgusAG59zlBiUIr7YIcZpJo7CS5QXtuLUaAip4VhnDKKmJTVbpdDfESQY/CO\r
32  u5loI20LsEGBgx/tuFvRmMSEAWeGd8A+36vNrE/pzlkQISEzMoRQ0nKjZZ5aobEotsVu\r
33  jg/A==\r
34 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
35  d=1e100.net; s=20130820;\r
36  h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\r
37  :references;\r
38  bh=cz2au64fdOj5I+AU71A0uiMe2HpsCJ7bi5iFMjCPT4U=;\r
39  b=NbAEqy7+EhDW9oR03mrOAUw8Y1DNeWj/8qq9cZR27939HxP2HHQ1SDEWKYnpGSunYV\r
40  T5D4wdXyNpZpzWdQZPBxmaNctQWUS5asko1FuwSg4e+L+NZwPGH80KJJ47JfZ16at/o9\r
41  QTFULp9g7YGwdXA5bZK/Clan40TDbfrIz4o4XtNkBe6P/+cvFGCu4lBUHvEWhh55s56p\r
42  SKv4eTvV+bhfX3GDVDM6S9ubVjTj3m7s5S0uOD4y2bqftMF8Cj9/6Zyr2/4h2RkVb600\r
43  1bzGgQteaSmhlYcpZKEInjnHEZYhyCsmYFdWhw92HCtPlwJtZd3V4uEnV7gFiJpJF5yz\r
44  OplA==\r
45 X-Gm-Message-State:\r
46  AG10YOQy+d0BmgXCaZUKT+TpJ+LtPQh0FvpRBBEcFRuX+fsXGx7EimWslNAuiJ4gaSDx4w==\r
47 X-Received: by 10.28.54.22 with SMTP id d22mr8191133wma.72.1455475212380;\r
48  Sun, 14 Feb 2016 10:40:12 -0800 (PST)\r
49 Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162])\r
50  by smtp.gmail.com with ESMTPSA id a128sm12051876wmh.6.2016.02.14.10.40.10\r
51  (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
52  Sun, 14 Feb 2016 10:40:11 -0800 (PST)\r
53 From: Mark Walters <markwalters1009@gmail.com>\r
54 To: notmuch@notmuchmail.org\r
55 Subject: [PATCH v5 1/7] emacs/show: Re-arrange determination if a part header\r
56  is necessary\r
57 Date: Sun, 14 Feb 2016 18:39:53 +0000\r
58 Message-Id: <1455475199-32622-2-git-send-email-markwalters1009@gmail.com>\r
59 X-Mailer: git-send-email 2.1.4\r
60 In-Reply-To: <1455475199-32622-1-git-send-email-markwalters1009@gmail.com>\r
61 References: <1455475199-32622-1-git-send-email-markwalters1009@gmail.com>\r
62 X-BeenThere: notmuch@notmuchmail.org\r
63 X-Mailman-Version: 2.1.20\r
64 Precedence: list\r
65 List-Id: "Use and development of the notmuch mail system."\r
66  <notmuch.notmuchmail.org>\r
67 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
68  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
69 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
70 List-Post: <mailto:notmuch@notmuchmail.org>\r
71 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
72 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
73  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
74 X-List-Received-Date: Sun, 14 Feb 2016 18:40:23 -0000\r
75 \r
76 From: David Edmondson <dme@dme.org>\r
77 \r
78 Move the determination of whether a part header is required to a\r
79 distinct function.\r
80 ---\r
81  emacs/notmuch-show.el | 30 +++++++++++++++++++++---------\r
82  1 file changed, 21 insertions(+), 9 deletions(-)\r
83 \r
84 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
85 index 3345878..70cdb9d 100644\r
86 --- a/emacs/notmuch-show.el\r
87 +++ b/emacs/notmuch-show.el\r
88 @@ -927,6 +927,22 @@ will return nil if the CID is unknown or cannot be retrieved."\r
89        ;; showable this returns nil.\r
90        (notmuch-show-create-part-overlays button part-beg part-end))))\r
91  \r
92 +(defun notmuch-show-mime-type (part)\r
93 +  "Return the correct mime-type to use for PART."\r
94 +  (let ((content-type (downcase (plist-get part :content-type))))\r
95 +    (or (and (string= content-type "application/octet-stream")\r
96 +            (notmuch-show-get-mime-type-of-application/octet-stream part))\r
97 +       (and (string= content-type "inline patch")\r
98 +            "text/x-diff")\r
99 +       content-type)))\r
100 +\r
101 +(defun notmuch-show-insert-header-p (part hide)\r
102 +  "Return non-NIL if a header button should be inserted for this part."\r
103 +  ;; Show all part buttons except for the first part if it is text/plain.\r
104 +  (let ((mime-type (notmuch-show-mime-type part)))\r
105 +    (not (and (string= mime-type "text/plain")\r
106 +             (<= (plist-get part :id) 1)))))\r
107 +\r
108  (defun notmuch-show-insert-bodypart (msg part depth &optional hide)\r
109    "Insert the body part PART at depth DEPTH in the current thread.\r
110  \r
111 @@ -937,20 +953,16 @@ is t, hide the part initially and show the button. If HIDE is\r
112  useful for quoting in replies)."\r
113  \r
114    (let* ((content-type (downcase (plist-get part :content-type)))\r
115 -        (mime-type (or (and (string= content-type "application/octet-stream")\r
116 -                            (notmuch-show-get-mime-type-of-application/octet-stream part))\r
117 -                       (and (string= content-type "inline patch")\r
118 -                            "text/x-diff")\r
119 -                       content-type))\r
120 +        (mime-type (notmuch-show-mime-type part))\r
121          (nth (plist-get part :id))\r
122          (long (and (notmuch-match-content-type mime-type "text/*")\r
123                     (> notmuch-show-max-text-part-size 0)\r
124                     (> (length (plist-get part :content)) notmuch-show-max-text-part-size)))\r
125          (beg (point))\r
126 -        ;; We omit the part button for the first (or only) part if\r
127 -        ;; this is text/plain, or HIDE is 'no-buttons.\r
128 -        (button (unless (or (equal hide 'no-buttons)\r
129 -                            (and (string= mime-type "text/plain") (<= nth 1)))\r
130 +        ;; We show the part button if notmuch-show-insert-header-p\r
131 +        ;; says to, unless HIDE is 'no-buttons.\r
132 +        (button (when (and (not (equal hide 'no-buttons))\r
133 +                           (notmuch-show-insert-header-p part hide))\r
134                    (notmuch-show-insert-part-header nth mime-type content-type (plist-get part :filename))))\r
135          ;; Hide the part initially if HIDE is t, or if it is too long\r
136          ;; and we have a button to allow toggling (thus reply which\r
137 -- \r
138 2.1.4\r
139 \r