Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 04 / a125e9b5fba631401936f9db89e3315a317ed0
1 Return-Path: <dme@dme.org>\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 2D724431FDF\r
6         for <notmuch@notmuchmail.org>; Mon, 12 May 2014 05:29:38 -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.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id eT9If0j9fzpa for <notmuch@notmuchmail.org>;\r
16         Mon, 12 May 2014 05:29:33 -0700 (PDT)\r
17 Received: from mail-we0-f177.google.com (mail-we0-f177.google.com\r
18         [74.125.82.177]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id 407A4431FC7\r
21         for <notmuch@notmuchmail.org>; Mon, 12 May 2014 05:29:33 -0700 (PDT)\r
22 Received: by mail-we0-f177.google.com with SMTP id x48so6656003wes.22\r
23         for <notmuch@notmuchmail.org>; Mon, 12 May 2014 05:29:32 -0700 (PDT)\r
24 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
25         d=1e100.net; s=20130820;\r
26         h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to\r
27         :references;\r
28         bh=fQ6nCL7txEWTecPqU4ztiDfdNjKVzxU2hdZiGm++bhk=;\r
29         b=ACsfd8P31jenGKdJe/IGdvWwFs6ygp6wuy6dzCG6TinRTGMDTzTegBUVKKX5IdVhsq\r
30         4GawgUtdU+XIIXKj0r6fAUvrff7+xsIjpPbnBoemVSATCqcMDYZ48zEmVnN/HsA788T+\r
31         TNSPP5F4meGR8ngt57iyjHIVIcii5vCKLZFmi+1hxuvHap7v9VjgY5P8YHEN4XGgRknZ\r
32         wFNt84vW5twhFW5lSyazHfhV0HDxnAJ6nltI9b3oRsm6HQNPGXDZPzXiD6ks8SjGcsM9\r
33         /lRnd1mUmBbhz35yIMD7Ke/X5g+MmD+4KVpiAd7miGoFGgp8VMI4xEiFSBBNnFboVPZC\r
34         wZGw==\r
35 X-Gm-Message-State:\r
36  ALoCoQnOAJNcXF6xzo1X1z1Kxbcmy7mgOhYQgedp4XMwVys7Bs5Ac29qxAMnNjiBBhBcxQboTisL\r
37 X-Received: by 10.180.78.5 with SMTP id x5mr15515388wiw.12.1399897771989;\r
38         Mon, 12 May 2014 05:29:31 -0700 (PDT)\r
39 Received: from hotblack-desiato.hh.sledj.net\r
40         ([2a01:348:1a2:1:a288:b4ff:fe8a:77d8])\r
41         by mx.google.com with ESMTPSA id\r
42         fu10sm15873680wib.11.2014.05.12.05.29.30\r
43         for <notmuch@notmuchmail.org>\r
44         (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
45         Mon, 12 May 2014 05:29:30 -0700 (PDT)\r
46 Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)\r
47         id 395A710B324; Mon, 12 May 2014 13:29:29 +0100 (BST)\r
48 From: David Edmondson <dme@dme.org>\r
49 To: notmuch@notmuchmail.org\r
50 Subject: [PATCH v3 2/9] emacs/show: Allow the user to decide when part headers\r
51         should be inserted\r
52 Date: Mon, 12 May 2014 13:29:22 +0100\r
53 Message-Id: <1399897769-26809-3-git-send-email-dme@dme.org>\r
54 X-Mailer: git-send-email 2.0.0.rc0\r
55 In-Reply-To: <1399897769-26809-1-git-send-email-dme@dme.org>\r
56 References: <87sixdujkv.fsf@qmul.ac.uk>\r
57         <1399897769-26809-1-git-send-email-dme@dme.org>\r
58 X-BeenThere: notmuch@notmuchmail.org\r
59 X-Mailman-Version: 2.1.13\r
60 Precedence: list\r
61 List-Id: "Use and development of the notmuch mail system."\r
62         <notmuch.notmuchmail.org>\r
63 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
64         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
65 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
66 List-Post: <mailto:notmuch@notmuchmail.org>\r
67 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
68 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
69         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
70 X-List-Received-Date: Mon, 12 May 2014 12:29:38 -0000\r
71 \r
72 Make the function that determines whether a part header should be\r
73 inserted a user controlled, with some example functions.\r
74 ---\r
75  emacs/notmuch-show.el | 21 +++++++++++++++++++--\r
76  1 file changed, 19 insertions(+), 2 deletions(-)\r
77 \r
78 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
79 index ec99141..f78a0ab 100644\r
80 --- a/emacs/notmuch-show.el\r
81 +++ b/emacs/notmuch-show.el\r
82 @@ -135,6 +135,17 @@ indentation."\r
83    :type 'boolean\r
84    :group 'notmuch-show)\r
85  \r
86 +(defcustom notmuch-show-insert-header-p-function 'notmuch-show-insert-header-p-smart\r
87 +  "A function to call to determine whether a MIME part should have a header button.\r
88 +\r
89 +The function is passed one argument, PART - the MIME part in\r
90 +question."\r
91 +  :type 'function\r
92 +  :group 'notmuch-show\r
93 +  :options '(notmuch-show-insert-header-p-smart\r
94 +            notmuch-show-insert-header-p-always\r
95 +            notmuch-show-insert-header-p-never))\r
96 +\r
97  (defvar notmuch-show-thread-id nil)\r
98  (make-variable-buffer-local 'notmuch-show-thread-id)\r
99  (put 'notmuch-show-thread-id 'permanent-local t)\r
100 @@ -880,12 +891,18 @@ message at DEPTH in the current thread."\r
101              "text/x-diff")\r
102         content-type)))\r
103  \r
104 -(defun notmuch-show-insert-header-p (part)\r
105 +(defun notmuch-show-insert-header-p-smart (part)\r
106    "Return non-NIL if a header button should be inserted for this part."\r
107    (let ((mime-type (notmuch-show-mime-type part)))\r
108      (not (and (string= mime-type "text/plain")\r
109               (<= (plist-get part :id) 1)))))\r
110  \r
111 +(defun notmuch-show-insert-header-p-always (part)\r
112 +  t)\r
113 +\r
114 +(defun notmuch-show-insert-header-p-never (part)\r
115 +  nil)\r
116 +\r
117  (defun notmuch-show-insert-bodypart (msg part depth &optional hide)\r
118    "Insert the body part PART at depth DEPTH in the current thread.\r
119  \r
120 @@ -904,7 +921,7 @@ useful for quoting in replies)."\r
121          ;; We omit the part button for the first (or only) part if\r
122          ;; this is text/plain, or HIDE is 'no-buttons.\r
123          (button (when (and (not (equal hide 'no-buttons))\r
124 -                           (notmuch-show-insert-header-p part))\r
125 +                           (funcall notmuch-show-insert-header-p-function part))\r
126                    (notmuch-show-insert-part-header nth mime-type content-type (plist-get part :filename))))\r
127          (content-beg (point)))\r
128  \r
129 -- \r
130 2.0.0.rc0\r
131 \r