From 10e71fad9fb407b4efe7127a9bfb48323b6ab7ed Mon Sep 17 00:00:00 2001 From: Tomi Ollila Date: Tue, 27 Aug 2013 23:14:32 +0300 Subject: [PATCH] Re: [PATCH v2] emacs: insert quotable parts in reply as they are displayed in show view --- 39/47958acd7465044c3ab86e8fbfc324a0deac0d | 170 ++++++++++++++++++++++ 1 file changed, 170 insertions(+) create mode 100644 39/47958acd7465044c3ab86e8fbfc324a0deac0d diff --git a/39/47958acd7465044c3ab86e8fbfc324a0deac0d b/39/47958acd7465044c3ab86e8fbfc324a0deac0d new file mode 100644 index 000000000..93c8c2cf5 --- /dev/null +++ b/39/47958acd7465044c3ab86e8fbfc324a0deac0d @@ -0,0 +1,170 @@ +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 48E51431FD7 + for ; Tue, 27 Aug 2013 13:14:50 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] + 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 QCwiYgZ6HvTe for ; + Tue, 27 Aug 2013 13:14:40 -0700 (PDT) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by olra.theworths.org (Postfix) with ESMTP id 88768431FD6 + for ; Tue, 27 Aug 2013 13:14:40 -0700 (PDT) +Received: from guru.guru-group.fi (localhost [IPv6:::1]) + by guru.guru-group.fi (Postfix) with ESMTP id DE4D6100030; + Tue, 27 Aug 2013 23:14:32 +0300 (EEST) +From: Tomi Ollila +To: Jani Nikula , +Subject: Re: [PATCH v2] emacs: insert quotable parts in reply as they are + displayed in show view +In-Reply-To: <1377633044-22044-1-git-send-email-jani@nikula.org> +References: <1377633044-22044-1-git-send-email-jani@nikula.org> +User-Agent: Notmuch/0.16+42~g385e6f3 (http://notmuchmail.org) Emacs/24.3.1 + (x86_64-unknown-linux-gnu) +X-Face: HhBM'cA~ +MIME-Version: 1.0 +Content-Type: text/plain +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: Tue, 27 Aug 2013 20:14:50 -0000 + +On Tue, Aug 27 2013, Jani Nikula wrote: + +> 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. +> --- + +Good stuff, I put this to test (in all of my 3 hosts I run notmuch-emacs) + +Vcalendars render fine. Have to find some html-only mail... + +The first line 'From:' is outside the top of the window for me -- have +to play with recenter or something a bit... + +Tomi + + +> emacs/notmuch-mua.el | 13 ++++++++++--- +> emacs/notmuch-show.el | 18 +++++++++++++----- +> 2 files changed, 23 insertions(+), 8 deletions(-) +> +> diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el +> index 2baae5f..c3aca80 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) +> @@ -130,9 +132,11 @@ 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) +> + ;; 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 +> @@ -219,6 +223,9 @@ list." +> (goto-char (point-max)) +> (push-mark) +> (message-goto-body) +> + +> + ;; Display message from the beginning if possible. +> + (recenter (- (line-number-at-pos) 1)) +> (set-buffer-modified-p nil)) +> +> (defun notmuch-mua-forward-message () +> 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 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch -- 2.26.2