On 14 February 2019 at 00:20 CET, Katsumi Yamaoka wrote: > > 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")))) The point is to delete all trailing whitespace coming from the conversion of HTML to text. Without this, some emails (such as the one attached) are hard to read because the lines end with so many whitespaces that they take several lines on the screen (filled with spaces). The following does what I want (and does not trigger the bug, thanks to the narrowing). (define-advice mm-shr (:around (oldfn &rest handle) delete-trailing-whitespace) "Delete leading and trailing whitespace in Gnus article buffer." (when (derived-mode-p 'gnus-article-mode) (save-restriction (narrow-to-region (point) (point)) (apply oldfn handle) (delete-trailing-whitespace)))) Thanks, C.