From: David Edmondson Date: Mon, 12 May 2014 12:29:28 +0000 (+0100) Subject: [PATCH v3 8/9] emacs/mua: Insert part headers depending on the message X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=6f64e4a0c5e3acc643e5968b349588db7d4fe737;p=notmuch-archives.git [PATCH v3 8/9] emacs/mua: Insert part headers depending on the message --- diff --git a/ef/098faa0a665e810e85536e3c9dbe7243580552 b/ef/098faa0a665e810e85536e3c9dbe7243580552 new file mode 100644 index 000000000..fb3f05626 --- /dev/null +++ b/ef/098faa0a665e810e85536e3c9dbe7243580552 @@ -0,0 +1,141 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id D3069431FD0 + for ; Mon, 12 May 2014 05:29:53 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 2W7vIhcP3GC1 for ; + Mon, 12 May 2014 05:29:49 -0700 (PDT) +Received: from mail-wi0-f176.google.com (mail-wi0-f176.google.com + [209.85.212.176]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 999F3431FDA + for ; Mon, 12 May 2014 05:29:35 -0700 (PDT) +Received: by mail-wi0-f176.google.com with SMTP id n15so4354394wiw.9 + for ; Mon, 12 May 2014 05:29:34 -0700 (PDT) +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20130820; + h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to + :references; + bh=/aQI20AsLdN5n9SeuaGD0ctiKhRr1Kp0qlguVsyliB8=; + b=VtqR+c6e5CJZispBqbRwQWzhWiii9c0lVsPHWNYGzK6MctT9U6fseI7pUbYZ4wYpgY + auCFzw8jp3/xOpSR3mdn0UwbUzMfmVHUM6nDE+w/hwsTLZyzqOg+RcoMcvpE/nuYd8V9 + hv+1dB85wnBwH2LV9K6AOftksyFbQjCnG9vUQhqmzYCv5qT13VFfHlaoR9hMWMXULCEL + R+x2prRBOJfvjWDIO0yil6/8rWebETcpZYeTdczdtcxF6/I9eMEndzjseb1iIdzJ8+3D + s9MvVDJ1NXIRP1gLM5Y6FHGHo1e+xrI5qqWKCjVVq6/0OFKW/NIhtOeXVEIlJuUkJvPP + 5eTQ== +X-Gm-Message-State: + ALoCoQkmHGZ9MS9L5jla3XNA4Q9Veb2b3WX1XHBZlxuKLiiMBV8g2keKC/Som1QcG1iPb7TyIHt9 +X-Received: by 10.180.100.41 with SMTP id ev9mr15439102wib.22.1399897774439; + Mon, 12 May 2014 05:29:34 -0700 (PDT) +Received: from hotblack-desiato.hh.sledj.net (disaster-area.hh.sledj.net. + [81.149.164.25]) by mx.google.com with ESMTPSA id + dn4sm15869601wib.18.2014.05.12.05.29.32 for + (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); + Mon, 12 May 2014 05:29:32 -0700 (PDT) +Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000) + id 4B31410B330; Mon, 12 May 2014 13:29:29 +0100 (BST) +From: David Edmondson +To: notmuch@notmuchmail.org +Subject: [PATCH v3 8/9] emacs/mua: Insert part headers depending on the + message +Date: Mon, 12 May 2014 13:29:28 +0100 +Message-Id: <1399897769-26809-9-git-send-email-dme@dme.org> +X-Mailer: git-send-email 2.0.0.rc0 +In-Reply-To: <1399897769-26809-1-git-send-email-dme@dme.org> +References: <87sixdujkv.fsf@qmul.ac.uk> + <1399897769-26809-1-git-send-email-dme@dme.org> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +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: Mon, 12 May 2014 12:29:54 -0000 + +Whether to insert part headers should depend on the details of the +message being cited. +--- + emacs/notmuch-mua.el | 45 +++++++++++++++++++++++++++++++++++++++++++-- + 1 file changed, 43 insertions(+), 2 deletions(-) + +diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el +index c800c38..239cc1a 100644 +--- a/emacs/notmuch-mua.el ++++ b/emacs/notmuch-mua.el +@@ -132,6 +132,47 @@ list." + (funcall original-func header references) + (unless (bolp) (insert "\n"))) + ++(defun notmuch-mua-reply-determine-part-function (message) ++ "Determine the part header rendering function to use when ++citing MESSAGE." ++ ++ (let* ((body (plist-get message :body)) ++ (first-part (car body))) ++ (cond ++ ;; If there are multiple top-level parts, we need the ++ ;; headers. Will this ever happen? ++ ((> (length body) 1) ++ #'notmuch-show-insert-header-p-always) ++ ++ ;; If the type of the part is multipart/mixed, we need to see the ++ ;; part headers. ++ ((notmuch-match-content-type (plist-get first-part :content-type) "multipart/mixed") ++ #'notmuch-show-insert-header-p-always) ++ ++ ;; If it is multipart/alternative the renderer will choose a ++ ;; default part and render it. There's no need to show the ++ ;; alternative part buttons, as they are not active. ++ ((notmuch-match-content-type (plist-get first-part :content-type) "multipart/alternative") ++ #'notmuch-show-insert-header-p-never) ++ ++ ;; If it's a multipart/signed with a single text/* part and a ++ ;; signature, we don't need to see the headers. ++ ((let ((inner-content (plist-get first-part :content))) ++ (and (notmuch-match-content-type (plist-get first-part :content-type) "multipart/signed") ++ (eq (length inner-content) 2) ++ (notmuch-match-content-type (plist-get (nth 0 inner-content) :content-type) "text/*") ++ (notmuch-match-content-type (plist-get (nth 1 inner-content) :content-type) "application/pgp-signature"))) ++ #'notmuch-show-insert-header-p-never) ++ ++ ;; If the type of the part is text/*, we don't need to see the ++ ;; part headers. ++ ((notmuch-match-content-type (plist-get first-part :content-type) "text/*") ++ #'notmuch-show-insert-header-p-never) ++ ++ ;; Otherwise insert the part headers. ++ (t ++ #'notmuch-show-insert-header-p-always)))) ++ + (defun notmuch-mua-reply (query-string &optional sender reply-all) + (let ((args '("reply" "--format=sexp" "--format-version=1")) + (process-crypto notmuch-show-process-crypto) +@@ -206,8 +247,8 @@ list." + ;; citations, etc. in the original message before + ;; quoting. + ((notmuch-show-insert-text/plain-hook nil) +- ;; Don't insert part buttons. +- (notmuch-show-insert-header-p-function #'notmuch-show-insert-header-p-never)) ++ ;; Determine how to insert part headers. ++ (notmuch-show-insert-header-p-function (notmuch-mua-reply-determine-part-function original))) + (notmuch-show-insert-body original (plist-get original :body) 0) + (buffer-substring-no-properties (point-min) (point-max))))) + +-- +2.0.0.rc0 +