Skip to content

Instantly share code, notes, and snippets.

@5hanth
Created February 22, 2016 18:04
Show Gist options
  • Save 5hanth/ba984fe09107f08c34ab to your computer and use it in GitHub Desktop.
Save 5hanth/ba984fe09107f08c34ab to your computer and use it in GitHub Desktop.
Format mails for interleaved response in emacs
(defun sha/format-mail-header ()
(interactive)
(with-current-buffer (current-buffer)
(let ((beg (region-beginning))
(end (region-end))
(fill-column 60))
(goto-char beg)
(insert "Hi,\n\n")
(forward-line 0)
(insert "---")
(end-of-line)
(newline)
(fill-individual-paragraphs (point) end)
(goto-char (+ 5 beg))
(forward-line)
(while (<= (point) (+ 3 1 (count-lines beg end) end))
(insert "| ")
(forward-line))
(insert "\\--\n\n"))))
(defun sha/format-mail-interleave ()
(interactive)
(with-current-buffer (current-buffer)
(let ((beg (region-beginning))
(end (region-end))
(fill-column 60))
(goto-char beg)
(forward-line 0)
(newline)
(insert "---")
(newline)
(goto-char end)
(end-of-line)
(newline)
(goto-char (+ beg 3 2))
(fill-individual-paragraphs (point) end)
(while (<= (point) (+ 1 3 1 (count-lines beg end) end))
(insert "| ")
(forward-line))
(insert "\\--\n\n"))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment