From 3e38baa7851a67c47f032a98618a72a4e8fcec39 Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Thu, 29 Aug 2013 18:53:31 +0300 Subject: [PATCH] [PATCH v2] emacs: insert quotable parts in reply as they are displayed in show view --- 93/a394eb49e6f12685c2d0f1a643c91611ad1272 | 167 ++++++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100644 93/a394eb49e6f12685c2d0f1a643c91611ad1272 diff --git a/93/a394eb49e6f12685c2d0f1a643c91611ad1272 b/93/a394eb49e6f12685c2d0f1a643c91611ad1272 new file mode 100644 index 000000000..966d76a82 --- /dev/null +++ b/93/a394eb49e6f12685c2d0f1a643c91611ad1272 @@ -0,0 +1,167 @@ +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 82F3E431FAE + for ; Thu, 29 Aug 2013 08:53:41 -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 LdeckeKUBUKE for ; + Thu, 29 Aug 2013 08:53:34 -0700 (PDT) +Received: from mail-ee0-f47.google.com (mail-ee0-f47.google.com + [74.125.83.47]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client + certificate requested) by olra.theworths.org (Postfix) with ESMTPS id + C428D431FBC for ; Thu, 29 Aug 2013 08:53:33 -0700 + (PDT) +Received: by mail-ee0-f47.google.com with SMTP id d49so346684eek.34 + for ; Thu, 29 Aug 2013 08:53:32 -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:cc:subject:date:message-id:in-reply-to + :references; + bh=X4Re+1uHWI+JffJ4Ag7r3e3OK8so7mWZxZ9l7MTgitk=; + b=WTNTecKBTATvQ2jZU4suySveWmePgJJV98GDlWfFgRT9en3K0xVtLl2rhGySIGGhDa + MqfzZHGaIN2uBBMn3FgSuyKRCw6+g84hCJCw777QRvf865p5VWR/SELKSjS0iXGqc9qV + MTApJnSDMv08hhQUt/QKLiX/b7FFotSFvG4scss+R2wQbGlz7noMraDBx1v0MZUu5rpm + bQ+Ih7bOXLYxBPChlKyy/+5+lgQzvA2ETC7yaltFZ0YesQzFMa5Qt+7bv9X1D4mSBIgc + /h0T4lf9bSbaO/8swy3FyI3cei6iMw6AuP5uWtExVg+ufMh3u+b1iikRWy2U/syxdyIQ + fvxw== +X-Gm-Message-State: + ALoCoQkf5//GIwOgurlM2gaquLF8bbye+/mx4XOkTR/eAs0swP+3pmJS65uWSdousfrhdUkTt680 +X-Received: by 10.14.205.9 with SMTP id i9mr4318557eeo.72.1377791611353; + Thu, 29 Aug 2013 08:53:31 -0700 (PDT) +Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi. + [88.195.111.91]) by mx.google.com with ESMTPSA id + r48sm47189968eev.14.1969.12.31.16.00.00 + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Thu, 29 Aug 2013 08:53:30 -0700 (PDT) +From: Jani Nikula +To: notmuch@notmuchmail.org +Subject: [PATCH v2] emacs: insert quotable parts in reply as they are + displayed in show view +Date: Thu, 29 Aug 2013 18:53:31 +0300 +Message-Id: <1377791611-29506-1-git-send-email-jani@nikula.org> +X-Mailer: git-send-email 1.7.10.4 +In-Reply-To: <1377633044-22044-1-git-send-email-jani@nikula.org> +References: <1377633044-22044-1-git-send-email-jani@nikula.org> +Cc: Tomi Ollila +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: Thu, 29 Aug 2013 15:53:41 -0000 + +In reply, insert quotable parts using notmuch-show-insert-bodypart +instead of calling notmuch-mm-display-part-inline directly to render +the quoted parts as they are rendered in show view. + +The notable change is that replies to text/calendar parts quote the +pretty printed output of icalendar-import-buffer rather than the ugly +raw vcalendar. + +--- + +v2: use (narrow-to-region (point-min) (point)) in +notmuch-mua-insert-quotable-part instead of adding the ugly recenter +in notmuch-mua-reply. Thanks to Austin and Mark for figuring this out. +--- + emacs/notmuch-mua.el | 12 ++++++++---- + emacs/notmuch-show.el | 18 +++++++++++++----- + 2 files changed, 21 insertions(+), 9 deletions(-) + +diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el +index 2baae5f..e7cc94e 100644 +--- a/emacs/notmuch-mua.el ++++ b/emacs/notmuch-mua.el +@@ -28,6 +28,8 @@ + + (eval-when-compile (require 'cl)) + ++(declare-function notmuch-show-insert-bodypart "notmuch-show" (msg part depth &optional hide)) ++ + ;; + + (defcustom notmuch-mua-send-hook '(notmuch-mua-message-send-hook) +@@ -129,10 +131,12 @@ list." + + (defun notmuch-mua-insert-quotable-part (message part) + (save-restriction +- (narrow-to-region (point) (point)) +- (notmuch-mm-display-part-inline message part (plist-get part :id) +- (plist-get part :content-type) +- notmuch-show-process-crypto) ++ (narrow-to-region (point-min) (point)) ++ ;; We don't want hooks, such as notmuch-wash-*, to be run on the ++ ;; quotable part. ++ (let ((notmuch-show-insert-text/plain-hook nil)) ++ ;; Show the part but do not add buttons. ++ (notmuch-show-insert-bodypart message part 0 'no-buttons)) + (goto-char (point-max)))) + + ;; There is a bug in emacs 23's message.el that results in a newline +diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +index 2896aae..904b98e 100644 +--- a/emacs/notmuch-show.el ++++ b/emacs/notmuch-show.el +@@ -844,7 +844,11 @@ message at DEPTH in the current thread." + (defun notmuch-show-insert-bodypart (msg part depth &optional hide) + "Insert the body part PART at depth DEPTH in the current thread. + +-If HIDE is non-nil then initially hide this part." ++HIDE determines whether to show or hide the part and the button ++as follows: If HIDE is nil, show the part and the button. If HIDE ++is t, hide the part initially and show the button. If HIDE is ++'no-buttons, show the part but do not add any buttons (this is ++useful for quoting in replies)." + + (let* ((content-type (downcase (plist-get part :content-type))) + (mime-type (or (and (string= content-type "application/octet-stream") +@@ -854,15 +858,19 @@ If HIDE is non-nil then initially hide this part." + content-type)) + (nth (plist-get part :id)) + (beg (point)) +- ;; We omit the part button for the first (or only) part if this is text/plain. +- (button (unless (and (string= mime-type "text/plain") (<= nth 1)) ++ ;; Hide the part initially if HIDE is t. ++ (show-part (not (equal hide t))) ++ ;; We omit the part button for the first (or only) part if ++ ;; this is text/plain, or HIDE is 'no-buttons. ++ (button (unless (or (equal hide 'no-buttons) ++ (and (string= mime-type "text/plain") (<= nth 1))) + (notmuch-show-insert-part-header nth mime-type content-type (plist-get part :filename)))) + (content-beg (point))) + + ;; Store the computed mime-type for later use (e.g. by attachment handlers). + (plist-put part :computed-type mime-type) + +- (if (not hide) ++ (if show-part + (notmuch-show-insert-bodypart-internal msg part mime-type nth depth button) + (button-put button :notmuch-lazy-part + (list msg part mime-type nth depth button))) +@@ -875,7 +883,7 @@ If HIDE is non-nil then initially hide this part." + (insert "\n")) + ;; We do not create the overlay for hidden (lazy) parts until + ;; they are inserted. +- (if (not hide) ++ (if show-part + (notmuch-show-create-part-overlays button content-beg (point)) + (save-excursion + (notmuch-show-toggle-part-invisibility button))) +-- +1.7.10.4 + -- 2.26.2