Re: [PATCH v2] emacs: insert quotable parts in reply as they are displayed in show view

Subject: Re: [PATCH v2] emacs: insert quotable parts in reply as they are displayed in show view

Date: Fri, 30 Aug 2013 13:18:07 -0400

To: Mark Walters

Cc: Tomi Ollila, notmuch@notmuchmail.org

From: Austin Clements


Quoth Mark Walters on Aug 30 at  5:49 pm:
> 
> > 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.
> 
> I slightly worry that some text-properties or similar from notmuch-show
> could make their way into the reply buffer: in particular it would be
> very bad if any invisible character made it into the buffer. I don't
> think this is actually a problem currently but just in case (and to
> avoid future problems) how about the following on top of the parent
> patch?

I haven't tested this, but I like the idea.  It won't actually help
with invisible text (though we could fix that in the future if
necessary), but there are plenty of other properties and overlays you
wouldn't want bleeding into the reply buffer.  This puts a clear wall
between the potentially interactive but read-only show output and the
plain but editable reply text.

> Best wishes
> 
> Mark
> 
> ---
>  emacs/notmuch-mua.el |    8 +++++---
>  1 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
> index e7cc94e..9e4a232 100644
> --- a/emacs/notmuch-mua.el
> +++ b/emacs/notmuch-mua.el
> @@ -134,9 +134,11 @@ list."
>      (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))
> +    (insert (with-temp-buffer
> +	      (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))
> +	      (buffer-substring-no-properties (point-min) (point-max))))
>      (goto-char (point-max))))
>  
>  ;; There is a bug in emacs 23's message.el that results in a newline

Thread: