0

I am looking for a way to export the html/text body part generated by org-mime-htmlize without the header.

I use notmuch mail for most of my mailing and threading is very important to me, so I want to stay within one thread when replying. When I send code snippets I use org-mime-htmlize for quick editing. But currently I have to open an org-mode buffer, htmlize it, select and copy the body part from it and paste it in to my reply mail.

I was wondering if it is possible to only export the body part to speed up copying and pasting?

Before doing something with within text searches, I wanted to ask, if there is maybe already a solution out there?

4
  • I use Gnus, there org-mime-htmilize doesn't cause me to lose thread. I'm not sure how'd it do it, since it doesn't modify subject and other fields like from/reply-to etc. Can you explain in more detail the undesired effect you see when you try to run org-mime-htmlize on your email? Also, what about narrowing to region before htmlizing?
    – wvxvw
    Aug 17 '16 at 15:57
  • How do you do the htmlization in Gnus? Basically the process is I mark an org-mode region and use org-mime-htmlize which open up a new mail buffer. However the header is blank, leaving me to fill it in, or copy the message body into my reply mail. Aug 17 '16 at 16:29
  • 1
    I just write Org markup inside the mail buffer and then call org-mime-htmlize on it. It knows not to touch the header fields / put the generated HTML in the appropriate tags by creating a multipart message and putting the HTML in the parts with types text/plain and text/html.
    – wvxvw
    Aug 17 '16 at 16:35
  • Oh, great that actually works. Never came to my mind to try it like this. Is this behaviour documented anywhere? I think it might be helpful for people to know. If you put it as an answer, I will accept it. Aug 17 '16 at 16:46
1

I was looking for the place in the documentation where it might say explicitly how to use it inside email buffers, but it doesn't. In retrospect you could guess it, since the documentation tells you to add hooks to mml mode, but there's still some guesswork involved. The quote below is from the documentation embedded in org-mime.el. Again, not exactly saying how to use it inside the email buffer, but close.

;;; Commentary:

;; WYSWYG, html mime composition using org-mode
;;
;; For mail composed using the orgstruct-mode minor mode, this
;; provides a function for converting all or part of your mail buffer
;; to embedded html as exported by org-mode.  Call `org-mime-htmlize'
;; in a message buffer to convert either the active region or the
;; entire buffer to html.
;;
;; Similarly the `org-mime-org-buffer-htmlize' function can be called
;; from within an org-mode buffer to convert the buffer to html, and
;; package the results into an email handling with appropriate MIME
;; encoding.
;;
;; you might want to bind this to a key with something like the
;; following message-mode binding
;;
;;   (add-hook 'message-mode-hook
;;             (lambda ()
;;               (local-set-key "\C-c\M-o" 'org-mime-htmlize)))
;;
;; and the following org-mode binding
;;
;;   (add-hook 'org-mode-hook
;;             (lambda ()
;;               (local-set-key "\C-c\M-o" 'org-mime-org-buffer-htmlize)))

So, basically, you'd add a hook to message-mode and call this function using whatever keybinding you assign to it to get the message converted to HTML.

2
  • 1
    Great! Thank you. I added three evil-mode keybindings. One to switch to org-mode, one to switch back to message-mode and one for the org-mime-htmlize. (Apparently it needs to be in message-mode to recognize that it doesn't have to write the header and signature.) Works like a charm. Aug 21 '16 at 6:28
  • After converting the message buffer to org-mode and back to message-mode I get an FCC error. Does this happen to you? (Mail sends fine though.) Aug 30 '16 at 13:36

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.