unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Mark Walters <markwalters1009@gmail.com>
To: Adam Wolfe Gordon <awg+notmuch@xvx.ca>, notmuch@notmuchmail.org
Subject: Re: [PATCH 2/2] emacs: Correctly quote non-text/plain parts in reply
Date: Sun, 22 Apr 2012 09:10:59 +0100	[thread overview]
Message-ID: <87hawcuqy4.fsf@qmul.ac.uk> (raw)
In-Reply-To: <1335056093-17621-3-git-send-email-awg+notmuch@xvx.ca>

On Sun, 22 Apr 2012, Adam Wolfe Gordon <awg+notmuch@xvx.ca> wrote:
> Quote non-text parts nicely by displaying them with mm-display-part
> before calling message-cite-original to quote them. HTML-only emails
> can now be quoted correctly.

My instinct would have been to do this with a temporary buffer rather
than the narrowing but I am *definitely* too much of a lisp beginner to
say that either is better.

(I think notmuch-show-mm-display-part-inline uses the temporary buffer
approach.)

Anyway, as it is, it looks correct and seems to work! (and is obviously
useful functionality)

Best wishes

Mark

> Mark the test for this feature as not broken.
> ---
>  emacs/notmuch-mua.el |   20 +++++++++++++++-----
>  test/emacs           |    1 -
>  2 files changed, 15 insertions(+), 6 deletions(-)
>
> diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
> index 87bd88d..f7af789 100644
> --- a/emacs/notmuch-mua.el
> +++ b/emacs/notmuch-mua.el
> @@ -21,6 +21,7 @@
>  
>  (require 'json)
>  (require 'message)
> +(require 'mm-view)
>  (require 'format-spec)
>  
>  (require 'notmuch-lib)
> @@ -90,6 +91,19 @@ list."
>  	else if (notmuch-match-content-type (plist-get part :content-type) "text/*")
>  	  collect part))
>  
> +(defun notmuch-mua-insert-quotable-part (message part)
> +  (save-restriction
> +    (narrow-to-region (point) (point))
> +    (insert (notmuch-get-bodypart-content message part
> +					  (plist-get part :id)
> +					  notmuch-show-process-crypto))
> +    (let ((handle (mm-make-handle (current-buffer)
> +				  (list (plist-get part :content-type))))
> +	  (end-of-orig (point-max)))
> +      (mm-display-part handle)
> +      (kill-region (point-min) end-of-orig))
> +    (goto-char (point-max))))
> +
>  ;; There is a bug in emacs 23's message.el that results in a newline
>  ;; not being inserted after the References header, so the next header
>  ;; is concatenated to the end of it. This function fixes the problem,
> @@ -169,11 +183,7 @@ list."
>  	;; Get the parts of the original message that should be quoted; this includes
>  	;; all the text parts, except the non-preferred ones in a multipart/alternative.
>  	(let ((quotable-parts (notmuch-mua-get-quotable-parts (plist-get original :body))))
> -	  (mapc (lambda (part)
> -		  (insert (notmuch-get-bodypart-content original part
> -							(plist-get part :id)
> -							notmuch-show-process-crypto)))
> -		quotable-parts))
> +	  (mapc (apply-partially 'notmuch-mua-insert-quotable-part original) quotable-parts))
>  
>  	(set-mark (point))
>  	(goto-char start)
> diff --git a/test/emacs b/test/emacs
> index e648f80..579844f 100755
> --- a/test/emacs
> +++ b/test/emacs
> @@ -445,7 +445,6 @@ EOF
>  test_expect_equal_file OUTPUT EXPECTED
>  
>  test_begin_subtest "Reply within emacs to an html-only message"
> -test_subtest_known_broken
>  add_message '[content-type]="text/html"' \
>  	    '[body]="Hi,<br />This is an <b>HTML</b> test message.<br /><br />OK?"'
>  test_emacs "(let ((message-hidden-headers '()))
> -- 
> 1.7.5.4
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

  reply	other threads:[~2012-04-22  8:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-22  0:54 [PATCH 0/2] Replying to HTML-only emails Adam Wolfe Gordon
2012-04-22  0:54 ` [PATCH 1/2] test: Replying to an HTML-only message in emacs Adam Wolfe Gordon
2012-05-04 18:47   ` Austin Clements
2012-05-05 18:55     ` Adam Wolfe Gordon
2012-04-22  0:54 ` [PATCH 2/2] emacs: Correctly quote non-text/plain parts in reply Adam Wolfe Gordon
2012-04-22  8:10   ` Mark Walters [this message]
2012-05-04 19:05   ` Austin Clements
2012-05-05 19:17     ` Adam Wolfe Gordon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87hawcuqy4.fsf@qmul.ac.uk \
    --to=markwalters1009@gmail.com \
    --cc=awg+notmuch@xvx.ca \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).