Permalink
Browse files

emacs: initial crack at cl-message-multipart-pandoc

  • Loading branch information...
1 parent 002287d commit 33075822b7c5560de741be614edce732c80f3ebc @league committed Mar 30, 2012
Showing with 42 additions and 0 deletions.
  1. +40 −0 emacs.el
  2. +2 −0 muttrc
View
40 emacs.el
@@ -337,6 +337,46 @@
(re-search-forward re)
(replace-match new t t nil 1)))))
+(defun cl-message-multipart-pandoc ()
+ (interactive)
+ (save-excursion
+ ;; To preserve quoting in pandoc, we need blank lines whenever
+ ;; changing indent levels. That is,
+ ;; > > INDENTED becomes > > INDENTED
+ ;; > OUTDENTED >
+ ;; > OUTDENTED
+ (message-goto-body)
+ (while (re-search-forward
+ "^\\(\\(> \\)*\\)\\(> [^>\n].*\\)\n\\1\\([^>\n].*\\)" nil t)
+ (replace-match "\\1\\3\n\\1\n\\1\\4" nil nil))
+ ;; and
+ ;; > OUTDENTED becomes > OUTDENTED
+ ;; > > INDENTED >
+ ;; > > INDENTED
+ (message-goto-body)
+ (while (re-search-forward
+ "^\\(\\(> \\)*\\)\\([^>\n].*\\)\n\\1\\(> .*\\)" nil t)
+ (replace-match "\\1\\3\n\\1\n\\1\\4" nil nil))
+ ;;
+ (message-goto-body)
+ (let* ((start (point)) end)
+ (goto-char (or (search-forward "\n<#" nil t)
+ (point-max)))
+ (beginning-of-line)
+ (kill-region start (point))
+ (message-goto-body)
+ (insert "<#multipart type=alternative>\n")
+ (yank)
+ (insert "<#part type=text/html charset=utf-8>\n")
+ (setq start (point))
+ (yank)
+ (setq end (point))
+ (insert "<#/multipart>\n")
+ (shell-command-on-region start end "pandoc -S -s -r markdown -w html" t t)
+ )))
+
+(add-hook 'message-send-hook 'cl-message-multipart-pandoc)
+
;;; Documentation
(setq woman-use-own-frame nil)
(setq woman-fill-column 70)
View
2 muttrc
@@ -7,6 +7,8 @@ alternates '^christopher\.league@liu\.edu$'
#alternates '^cleague@gmail\.com$'
#alternates '^league@acm\.org$'
+set attribution="*On %d, %n wrote:*"
+
## Sending via MSMTPQ
set sendmail="/usr/local/sbin/msmtpQ --read-envelope-from --read-recipients"
set sendmail_wait = -1

0 comments on commit 3307582

Please sign in to comment.