I'm trying to write an org-capture-template and supporting functions for it, for a blogging setup that uses individual org files within a specific directory for posts. i want this to work such that I get prompted for a title, which is used to generate the file name, the title metadata of the file, and a description, which is also used to generate another metadata variable. Based on this answer, I've come up with this:
(defun org-new-blog-post () (setq date (format-time-string (org-time-stamp-format :long :inactive) (org-current-time))) (setq title (read-string "Post Title: ")) (setq fname (org-hugo-slug title)) (setq description (read-string "Description: ")) (expand-file-name (format "%s.org" fname) "~/git/personal/blog/org/blog/")) (setq org-capture-templates '(("n" "new post" plain (function org-new-blog-post) "%(format \"#+title: %s\n#+date: %s\n#+description: %s\n\n\" title date description)"))) But this doesn't seem to work, and it just prints the output in the buffer I started with.
I understand that setting global variables in a defun is bad practice but somehow using a let form doesn't allow me to reference those variables in the capture template.