3

I would like to unfill all paragraphs before sending a message with mu4e. This is because format=flowed is not respected by all platforms (particularly Gmail).

I figure that message-send-hook is the right place to put it, but I do not know of a reliable way to select the whole message programmatically without unintentionally capturing the message headers or quoted citations.

1
+50

This works approximately:

(defun unfill-email-body ()
  (let ((fill-column most-positive-fixnum)
    (top ))
    (mu4e-compose-goto-top)
    (setq top (point))
    (mu4e-compose-goto-bottom)
    ;; now go backward by paragraph and unfill them unless the paragraph starts with >
    (while (and (> (point) top)
        (backward-paragraph))
      (unless (looking-at ">")
    (fill-paragraph)))))


(add-hook 'message-send-hook 'unfill-email-body)

The idea is to just iterate through the body by paragraph and unfill each one as long as it does not start with >.

I say approximately because it seems like some whitespace gets stripped in my setup which means this ends up unfilling the signature since there is trailing whitespace in the signature delimiter defined in message-signature-separator. I could fix that locally but I don't here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.