Frequently, I find myself having to send code snippets to teammates, etc.
Therefore, I decided to write the following elisp to simplify the process. I am using mutt as the email client, but the only issue with this is the fact that the code is not properly formatted in the email.
(defun email_mark (addr subj)
(interactive "sEnter email address: \nsEnter email subject: ")
(let ((fname "~/.emacs.d/files/email.txt"))
(write-region (region-beginning) (region-end) fname)
(shell-command (format "mutt -e 'set content_type=text/html' -s '%s' -- '%s' < %s" subj addr fname))))
(global-set-key "\C-x\m" 'email_mark)
Screenshot of email sent using this function:
Any suggestions?
write-region
call works for me and reproduces indentation exactly (I assume you're using spaces rather than tabs?). Hence, I'm guessing your problem is in the call toformat
.