From f377541a467ad25379f884eb740abdb89b6aca07 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Tue, 6 Jul 2021 00:34:18 -0700 Subject: [PATCH] [oni-org] Add capture template for CODE Magazine issues --- oni-org/oni-org.el | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/oni-org/oni-org.el b/oni-org/oni-org.el index f868eb0..0700376 100644 --- a/oni-org/oni-org.el +++ b/oni-org/oni-org.el @@ -4,7 +4,7 @@ ;; Author: Tom Willemse ;; Keywords: local -;; Version: 2021.0705.233009 +;; Version: 2021.0706.003249 ;; Package-Requires: (oni-yasnippet oni-alert oni-hydra org org-contrib org-bullets org-edna diminish all-the-icons olivetti) ;; This program is free software; you can redistribute it and/or modify @@ -510,22 +510,51 @@ After running it once remove it from `org-capture-after-finalize-hook'." (let ((title (oni-org-get-url-title url))) (format "[[%s][%s]]" url title))) +(defun oni-org-format-months () + (let* ((time (org-timestamp-to-time + (org-timestamp-from-string (concat "<" (org-read-date) ">")))) + (decoded (decode-time time)) + (next-month + (time-add time (days-to-time (date-days-in-month + (decoded-time-year decoded) + (decoded-time-month decoded)))))) + (concat (format-time-string "%b " time) + (format-time-string "%b " next-month) + (format-time-string "%Y" time)))) + +(defun oni-org-ask-names () + (let ((n 1) + article-name + names) + (while (not (string-empty-p (setq article-name (read-string (format "Article Name %d: " n))))) + (push article-name names) + (cl-incf n)) + (reverse names))) + +(defun oni-org-format-names (names) + (mapconcat (lambda (n) (format "** READ %s" n)) names "\n")) + (setq org-capture-templates `(("i" "Inbox" entry (file ,(oni-org-expand-to-home "documents/gtd/inbox.org")) (file ,(expand-file-name "inbox.org" oni-org-capture-template-directory))) ("I" "Inbox (add selection)" entry (file ,(oni-org-expand-to-home "documents/gtd/inbox.org")) (file ,(expand-file-name "inbox-with-selection.org" oni-org-capture-template-directory))) - ("a" "Album" entry (file ,(oni-org-expand-to-home "documents/gtd/inbox.org")) + ("a" "Appointment" entry (file "") + (file ,(expand-file-name "appointment.org" oni-org-capture-template-directory))) + ("A" "Album" entry (file ,(oni-org-expand-to-home "documents/gtd/inbox.org")) "* %^{Artist} - %^{Album Name} ** TODO Listen to %\\1 - %\\2 ** TODO Rip %\\1 - %\\2 to disk ** TODO Add album art to %\\1 - %\\2 ** TODO Transfer %\\1 - %\\2 to phone" :immediate-finish t) + ("m" "Code Magazine Issue" entry (file ,(oni-org-expand-to-home "documents/gtd/inbox.org")) + "* CODE Issue %(oni-org-format-months) +** READ Editorial +%(oni-org-format-names (oni-org-ask-names))" + :immediate-finish t) ("t" "Task" entry (file ,(oni-org-expand-to-home "documents/gtd/inbox.org")) (file ,(expand-file-name "task.org" oni-org-capture-template-directory))) - ("a" "Appointment" entry (file "") - (file ,(expand-file-name "appointment.org" oni-org-capture-template-directory))) ("u" "URL to read" entry (file ,(oni-org-expand-to-home "documents/gtd/inbox.org")) (file ,(expand-file-name "reading-url.org" oni-org-capture-template-directory)) :immediate-finish t)