From 9f4195ac46d28f3031eb21defc0a59843b0d44ec Mon Sep 17 00:00:00 2001 From: David Edmondson Date: Wed, 10 Feb 2016 08:07:12 +0000 Subject: [PATCH] Re: [PATCH v4 6/7] emacs/mua: Let user specify which parts get a header in citations. --- fa/5a1597036c966e1f83359fa81ddf348ba31cf1 | 194 ++++++++++++++++++++++ 1 file changed, 194 insertions(+) create mode 100644 fa/5a1597036c966e1f83359fa81ddf348ba31cf1 diff --git a/fa/5a1597036c966e1f83359fa81ddf348ba31cf1 b/fa/5a1597036c966e1f83359fa81ddf348ba31cf1 new file mode 100644 index 000000000..cbb35d052 --- /dev/null +++ b/fa/5a1597036c966e1f83359fa81ddf348ba31cf1 @@ -0,0 +1,194 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id C11776DE0231 + for ; Wed, 10 Feb 2016 00:07:19 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: -0.106 +X-Spam-Level: +X-Spam-Status: No, score=-0.106 tagged_above=-999 required=5 + tests=[AWL=-0.039, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, + RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, + RCVD_IN_MSPIKE_WL=-0.01, SPF_NEUTRAL=0.652, UNPARSEABLE_RELAY=0.001] + autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id RpDomREGh3Aq for ; + Wed, 10 Feb 2016 00:07:17 -0800 (PST) +Received: from mail-wm0-f46.google.com (mail-wm0-f46.google.com + [74.125.82.46]) by arlo.cworth.org (Postfix) with ESMTPS id 3D12F6DE021E for + ; Wed, 10 Feb 2016 00:07:16 -0800 (PST) +Received: by mail-wm0-f46.google.com with SMTP id g62so15304741wme.0 + for ; Wed, 10 Feb 2016 00:07:16 -0800 (PST) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=dme-org.20150623.gappssmtp.com; s=20150623; + h=to:subject:in-reply-to:references:from:date:message-id:mime-version + :content-type; bh=eyZ4zFpTc9jbadsGRx/x5MxsScoPB/WR2wXzmnCddfc=; + b=xhk8L+Oy7csrICgcO14/w2YU6/PQccSHzty4W2bC++d77sknT5xM5/WVgGVOa+buoi + BfMhpTh/MAkGO/mhuJURvFtCxuiu4g9ygjiO3fqoqfsG5IW9EwDDVA2/HiMIu1UmI314 + Ckdg8Znwg60Al8sKW0hHQ0GrECMsP/3+8F4lWnVqLbwBCI5/+yWRMCholDjFYo3ZYScR + E+X5dgDOyjIIBZQRDnfydK0yXDR9WtBCmZ4rhLsx5VpnVVlwMRs2K7U/Cu2nALMT+Vzx + v0ieZzxstzHZn+47Ydka3We3HposFSFiwUZADowGb75aLdm0lmWk3o8BX6O2yY0gBaHg + hwrQ== +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20130820; + h=x-gm-message-state:to:subject:in-reply-to:references:from:date + :message-id:mime-version:content-type; + bh=eyZ4zFpTc9jbadsGRx/x5MxsScoPB/WR2wXzmnCddfc=; + b=CVwqlz3fux71u6dbfXBu4K+NaCfDkehxpHYzl1eMfvEqP6cvpwtgAf6zefKnZ9xFDa + zXE/a9D/cs73j7YA7uSSzN1Re1AAN7O5g/VBw87OTXFhdx/dId4AWt0zxQYAukSH8g/+ + 38lvVxAonmI/X/NK1wgX+sUCJHOVB7I70maQ5an6U25aBF+dO0U8LvBigFDHPMkBcXp6 + 9GAW+Vu/dTc+7S52iMmL+wwKdXkS+jen1p9PHmD+4c/bSUvwwqYOSAkET1Qqu4QvHxwx + SH+B+8ysZ7fSBnk71LGA0ICoaWke4i1+e96EkPKBgmzWV5U7/hlJLYQmNkGvdcgQJtQT + DRvg== +X-Gm-Message-State: + AG10YOS5pE5a3H63VOqd5gHIY8zJSSsy9NHxgc+sSIbgAD8NXDPcQJUVlOXxdtgn6oXoGA== +X-Received: by 10.194.172.228 with SMTP id bf4mr43156123wjc.109.1455091635408; + Wed, 10 Feb 2016 00:07:15 -0800 (PST) +Received: from disaster-area.hh.sledj.net + ([2a01:348:1a2:1:ea39:35ff:fe2c:a227]) + by smtp.gmail.com with ESMTPSA id i1sm1698530wjs.45.2016.02.10.00.07.13 + (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); + Wed, 10 Feb 2016 00:07:13 -0800 (PST) +Received: from localhost (disaster-area.hh.sledj.net [local]) + by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id 7737de0b; + Wed, 10 Feb 2016 08:07:12 +0000 (UTC) +To: Mark Walters , notmuch@notmuchmail.org +Subject: Re: [PATCH v4 6/7] emacs/mua: Let user specify which parts get a + header in citations. +In-Reply-To: <87twlh5x69.fsf@qmul.ac.uk> +References: <1446894276-7814-1-git-send-email-markwalters1009@gmail.com> + <1446894276-7814-7-git-send-email-markwalters1009@gmail.com> + <87twlh5x69.fsf@qmul.ac.uk> +From: David Edmondson +Date: Wed, 10 Feb 2016 08:07:12 +0000 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.20 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Wed, 10 Feb 2016 08:07:20 -0000 + +On Tue, Feb 09 2016, Mark Walters wrote: +> On Tue, 09 Feb 2016, David Edmondson wrote: +>> On Sat, Nov 07 2015, Mark Walters wrote: +>>> From: David Edmondson +>>> +>>> Add a customizable function specifying which parts get a header when +>>> replying, and give some sensible possiblities. These are, +>>> +>>> 1) all parts except multipart/*. (Subparts of a multipart part do +>>> receive a header button.) +>>> +>>> 2) only included text/* parts. +>>> +>>> 3) Exactly as in the show buffer. +>>> +>>> 4) None at all. This means the reply contains a mish-mash of all the +>>> original message's parts. +>>> --- +>>> emacs/notmuch-mua.el | 30 ++++++++++++++++++++++++++---- +>>> emacs/notmuch-show.el | 13 +++++++++++++ +>>> 2 files changed, 39 insertions(+), 4 deletions(-) +>>> +>>> diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el +>>> index 2f7abb0..a675f47 100644 +>>> --- a/emacs/notmuch-mua.el +>>> +++ b/emacs/notmuch-mua.el +>>> @@ -91,6 +91,23 @@ (defcustom notmuch-mua-cite-function 'message-cite-original +>>> :link '(custom-manual "(message)Insertion Variables") +>>> :group 'notmuch-reply) +>>> +>>> +(defcustom notmuch-mua-reply-insert-header-p-function +>>> + 'notmuch-show-reply-insert-header-p-trimmed +>>> + "Function to decide which parts get a header when replying. +>>> + +>>> +This function specifies which parts of a mime message with +>>> +mutiple parts get a header." +>>> + :type '(radio (const :tag "All except multipart/* and hidden parts" +>>> + notmuch-show-reply-insert-header-p-trimmed) +>>> + (const :tag "Only for included text parts" +>>> + notmuch-show-reply-insert-header-p-minimal) +>>> + (const :tag "Exactly as in show view" +>>> + notmuch-show-insert-header-p) +>>> + (const :tag "No part headers" +>>> + notmuch-show-reply-insert-header-p-never) +>>> + (function :tag "Other")) +>>> + :group 'notmuch-reply) +>>> + +>> +>> These are all functions - should we be `declare-function'ing them, given +>> that they come from elsewhere? Presumably the compiler is not clever +>> enough to complain if we don't. +> +> The compiler doesn't seem to complain. But I don't know if we should +> have the declare functions anyway? Any thoughts? + +It doesn't seem to be common, so let's leave it alone. + +> Best wishes +> +> Mark +> +>> +>>> ;; +>>> +>>> (defun notmuch-mua-get-switch-function () +>>> @@ -221,10 +238,15 @@ (defun notmuch-mua-reply (query-string &optional sender reply-all) +>>> (insert "Date: " date "\n\n") +>>> +>>> (insert (with-temp-buffer +>>> - ;; Don't attempt to clean up messages, excerpt +>>> - ;; citations, etc. in the original message before +>>> - ;; quoting. +>>> - (let ((notmuch-show-insert-text/plain-hook nil)) +>>> + (let +>>> + ;; Don't attempt to clean up messages, excerpt +>>> + ;; citations, etc. in the original message before +>>> + ;; quoting. +>>> + ((notmuch-show-insert-text/plain-hook nil) +>>> + ;; Don't omit long parts. +>>> + (notmuch-show-max-text-part-size 0) +>>> + ;; Insert headers for parts as appropriate for replying. +>>> + (notmuch-show-insert-header-p-function notmuch-mua-reply-insert-header-p-function)) +>>> (notmuch-show-insert-body original (plist-get original :body) 0) +>>> (buffer-substring-no-properties (point-min) (point-max))))) +>>> +>>> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +>>> index f4a65cc..7ff9ed5 100644 +>>> --- a/emacs/notmuch-show.el +>>> +++ b/emacs/notmuch-show.el +>>> @@ -959,6 +959,19 @@ (defun notmuch-show-insert-header-p (part hide) +>>> (not (and (string= mime-type "text/plain") +>>> (<= (plist-get part :id) 1))))) +>>> +>>> +(defun notmuch-show-reply-insert-header-p-never (part hide) +>>> + nil) +>>> + +>>> +(defun notmuch-show-reply-insert-header-p-trimmed (part hide) +>>> + (let ((mime-type (notmuch-show-mime-type part))) +>>> + (and (not (notmuch-match-content-type mime-type "multipart/*")) +>>> + (not hide)))) +>>> + +>>> +(defun notmuch-show-reply-insert-header-p-minimal (part hide) +>>> + (let ((mime-type (notmuch-show-mime-type part))) +>>> + (and (notmuch-match-content-type mime-type "text/*") +>>> + (not hide)))) +>>> + +>>> (defun notmuch-show-insert-bodypart (msg part depth &optional hide) +>>> "Insert the body part PART at depth DEPTH in the current thread. +>>> +>>> -- +>>> 2.1.4 -- 2.26.2