With the help of these questions, I managed to prompt the user for a file name in org-capture and combine it with a timestamp.
(defun my/generate-org-note-name () (let ((name (read-string "Name: ")) (time (format-time-string "%Y%m%d%H%M%S"))) (expand-file-name (format "%s-%s.org" time name) "~/org-wiki"))) (setq org-capture-templates '(("n" "note" plain (file (my/generate-org-note-name)) "#+TITLE: "))) Now I would like to reuse this name and timestamp in the actual template.
- File name:
2018010101230456-myfile.org Template:
#+TITLE: my file #+STAMP: 2018010101230456
I am trying to return a list with file path and template from my/generate-org-note-name and then append it to the first 3 elements. But it looks like something (maybe my quoting) is wrong:
(defun my/generate-org-note-name () (interactive) (let ((name (read-string "Name: ")) (time (format-time-string "%Y%m%d%H%M%S"))) (list (file (expand-file-name (format "%s-%s.org" time name) "~/org-wiki"))) (format "#+TITLE: %s\n#+STAMP: %s\n" name time)) (setq org-capture-templates '((apply #'append (list (list "n" "note" 'plain) (call-interactively #'my/generate-org-note-name))))) The call to apply fails every time.