只需要安装 xsltproc
,对应的 RelaxNG 语法,XSL stylesheet,和一个函数:
(defun lsml-compose ()
"Compose mail from current lsml file."
(interactive)
(let (dom content subject to otherheader)
(let ((b (current-buffer)))
(with-temp-buffer
(insert-buffer-substring b)
(setq dom (assoc 'head (libxml-parse-xml-region 1 (point-max))))
(call-process-region
nil 0 "xsltproc" t
t nil
(expand-file-name "~/.emacs.d/mail/lsml.xsl") "-")
(setq content (buffer-string))))
(setq subject (cadr (assoc-default 'subject dom 'eq '(nil . nil))))
(setq to (cadr (assoc-default 'to dom 'eq '(nil . nil))))
(setq otherheader
(cons (cons "body"
(concat "--[[text/html]]\n" content))
(mapcar (lambda (x)
(cons (symbol-name (car x))
(cdr x)))
(car (assoc-default 'headers dom)))))
(compose-mail to subject otherheader)))
用 XML 写完之后 M-x lsml-compose
,就可以用 Wanderlust 发邮件,稍微改下也可给其它支持 compose-mail 界面的 email client 用。