Skip to content

Instantly share code, notes, and snippets.

@theanalyst
Last active August 29, 2015 14:16
Show Gist options
  • Select an option

  • Save theanalyst/5e5d263adbacb887c3f5 to your computer and use it in GitHub Desktop.

Select an option

Save theanalyst/5e5d263adbacb887c3f5 to your computer and use it in GitHub Desktop.
(defun send-region-as-email (start end)
"A hacky function to send a region as mail
Assumes the region follows the below format
To: <recepient>
Subject: <subject>
<mail body>"
(interactive (if (use-region-p)
(list (region-beginning) (region-end))
(list nil nil)))
(let* ((selection (buffer-substring-no-properties start end))
(recepient (s-trim (cadr (s-split ":" (car (s-lines selection))))))
(subject (s-trim (cadr (s-split-up-to ":" (cadr (s-lines selection)) 1))))
(body (car (last (s-split-up-to "\n" selection 3)))))
(message-mail recepient subject)
(message-goto-body)
(insert body)
(message-send-and-exit)))
@shrayasr
Copy link

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment