Subject: bug#34387: 26.1; Gnus: handle empty message parts

From: Katsumi Yamaoka <[email-masked]>
Date: Thu, 14 Feb 2019 08:20:20 +0900

On Wed, 13 Feb 2019 18:26:44 +0100, Christophe Troestler wrote:
> Thanks for your analysis.  I indeed had an advice executed after
> mm-shr to remove trailing whitespace—these making sometimes the
> rendered text hard to read.  Deleting the advice makes the call
> work.

Bingo! :)

> What approach would you recommend to remove trailing whitespace
> after rendering HTML?

The point would be to delete only whitespace that mm-shr inserts.
How about this?

(defadvice mm-shr (around delete-leading-and-trailing-whitespace activate)
  "Delete leading and trailing whitespace in Gnus article buffer."
  (when (derived-mode-p 'gnus-article-mode)
    (save-restriction
      (narrow-to-region (point) (point))
      ad-do-it
      (goto-char (point-min))
      (skip-chars-forward "\t\n ")
      (delete-region (point-min) (point))
      (goto-char (point-max))
      (skip-chars-backward "\t\n ")
      (delete-region (point) (point-max))
      (insert "\n"))))

I'll close this thread after fixing the other two related bugs.

> 1. In the article buffer, pressing the RET key on an empty
>  text/plain attachment conceals the succeeding other attachments,
>  does not toggle.  `g' restores them of course, though.

> 2. Some kind of an empty mail isn't able to be edited using the
>  `e' command (gnus-summary-edit-article), that is, a single part
>  email whose body is an empty attachment.  Gnus misunderstands
>  that the header is its body.

Regards,