From 4fe4345b88d0e19170b43d1fbb0c658b792c9adb Mon Sep 17 00:00:00 2001 From: Philipp Ittershagen Date: Wed, 10 Oct 2018 14:22:27 +0200 Subject: [PATCH] mu4e: restrict deleting trailing whitespace to region If no region is selected, mu4e-fill-paragraph will delete trailing whitespace on all lines in the buffer. This might not be desired, e.g. when adding a signature to the mail which is delimited by the line '-- '. --- mu4e/mu4e-compose.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mu4e/mu4e-compose.el b/mu4e/mu4e-compose.el index 7fea7250..e91aef0d 100644 --- a/mu4e/mu4e-compose.el +++ b/mu4e/mu4e-compose.el @@ -401,9 +401,11 @@ simply executes `fill-paragraph'." (if mu4e-compose-format-flowed (let ((fill-column (point-max)) (use-hard-newlines nil)); rfill "across" hard newlines - (delete-trailing-whitespace) + (when (use-region-p) + (delete-trailing-whitespace (region-beginning) (region-end))) (fill-paragraph nil region)) - (delete-trailing-whitespace) + (when (use-region-p) + (delete-trailing-whitespace (region-beginning) (region-end))) (fill-paragraph nil region))) (defun mu4e-toggle-use-hard-newlines ()