emacs/layers.personal/mylangs/mypollen/funcs.el
2018-04-07 10:54:04 +08:00

31 lines
1.6 KiB
EmacsLisp

;; add functions here which can be used in mypollen layer
(defun generate-pollen-document (name)
(let ((context (concat "#lang pollen\n"
"◊(define-meta title \"Sample Pollen Document\")\n"
"◊(define-meta author \"Rongsong Shen\")\n"
"◊(define-meta publisher \"GNU Publisher\")\n"
"◊(define-meta thanklessauthor \"autherX\")"
"◊(define-meta thankslesspublisher \"GNU Less Publisher\")"
"◊(define-meta doc-publish-date \"2016-10-17\")\n"
"◊;using ◊part{} ◊chapter{} as the top two levels of book\n"
"◊;using ◊section{} and ◊subsection{} in tufte-handout\n"
"\n◊;add document here\n")))
(append-to-file context nil name)))
(defun pollen-use-template (template destdir)
(interactive
(let ((template-used (read-directory-name "Choose template:"
(expand-file-name pollen-templates-directory)
nil nil nil))
(destdir-used (read-string "Destination:")))
(list template-used destdir-used)))
(when (and template destdir)
(let ((tmp-buf (current-buffer)))
(apply 'make-comint "/bin/sh" "/bin/sh" nil
(list "-c" (concat "cp -Rf " template " " destdir)))
(switch-to-buffer tmp-buf)
(switch-to-buffer-other-window "* SHELL *")
(let ((name (concat destdir "/doc.poly.pm")))
(generate-pollen-document name)))))