mirror of
https://git.sr.ht/~magic_rb/dotfiles
synced 2024-11-21 23:54:22 +01:00
Support ~org-roam~ recipes based on tempel
Signed-off-by: Magic_RB <magic_rb@redalder.org>
This commit is contained in:
parent
ca4d125b23
commit
07ffaccb58
|
@ -47,25 +47,78 @@ So the process for capturing is to trigger the capture with ~C-c o c~ and then q
|
||||||
"${body}")
|
"${body}")
|
||||||
:target (file+olp "inbox.org" ("Shopping list")))))
|
:target (file+olp "inbox.org" ("Shopping list")))))
|
||||||
|
|
||||||
|
(defun org-roam-tempel-recipe ()
|
||||||
|
"."
|
||||||
|
(setq-local org-roam-node org-roam-capture--node)
|
||||||
|
(org-entry-delete nil "ID")
|
||||||
|
(tempel-insert
|
||||||
|
'(":PROPERTIES:" n
|
||||||
|
":CREATED: " (org-capture-fill-template "%U")
|
||||||
|
":ID: " (org-roam-node-id org-roam-node) n
|
||||||
|
":servings: " p n
|
||||||
|
":prep-time: " (s prep-time) " m" n
|
||||||
|
":cook-time: " (s cook-time) " m" n
|
||||||
|
":ready-in: " (when-let ((prep (and prep-time (string-to-number prep-time)))
|
||||||
|
(cook (and cook-time (string-to-number cook-time))))
|
||||||
|
(number-to-string (+ prep cook))) " m" n
|
||||||
|
":END:" n
|
||||||
|
"#+title: " (org-roam-node-title org-roam-node) n
|
||||||
|
"#+filetags: :recipe:" n
|
||||||
|
"* Ingredients" n
|
||||||
|
" - " r n
|
||||||
|
"* Directions" n
|
||||||
|
" - " n)))
|
||||||
|
|
||||||
|
(defun org-roam-tempel-web-resource ()
|
||||||
|
"."
|
||||||
|
(setq-local org-roam-node org-roam-capture--node)
|
||||||
|
(org-entry-delete nil "ID")
|
||||||
|
(tempel-insert
|
||||||
|
'(":PROPERTIES:" n
|
||||||
|
":CREATED: " (org-capture-fill-template "%U") n
|
||||||
|
":ID: " (org-roam-node-id org-roam-node) n
|
||||||
|
":ROAM_REFS: " (completing-read \"URL for resource: \" nil nil nil nil nil (or (substring-no-properties (car kill-ring)) nil)) n
|
||||||
|
":END:" n
|
||||||
|
"#+title: " (org-roam-node-title org-roam-node) n
|
||||||
|
"#+filetags: :resource:" n n)))
|
||||||
|
|
||||||
|
(defun org-roam-tempel-node (standalone)
|
||||||
|
"."
|
||||||
|
(setq-local org-roam-node org-roam-capture--node)
|
||||||
|
(org-entry-delete nil "ID")
|
||||||
|
(tempel-insert
|
||||||
|
`(,@(unless standalone '("* ${title} :inbox:" n))
|
||||||
|
":PROPERTIES:" n
|
||||||
|
":ID: " (org-roam-node-id org-roam-node) n
|
||||||
|
":CREATED: " (org-capture-fill-template "%U")
|
||||||
|
":END:" n
|
||||||
|
"#+setupfile: ~/roam/emacs-lisp/setupfiles/latex-base.org" n
|
||||||
|
,@(when standalone '("#+title: " (org-roam-node-title org-roam-node) n)) n
|
||||||
|
)))
|
||||||
|
|
||||||
|
(defun org-roam-tempel-task ()
|
||||||
|
"."
|
||||||
|
(setq-local org-roam-node org-roam-capture--node)
|
||||||
|
(setf (org-roam-node-id org-roam-node) (org-id-uuid))
|
||||||
|
(tempel-insert
|
||||||
|
`(":PROPERTIES:" n
|
||||||
|
":CREATED: " (org-capture-fill-template "%U")
|
||||||
|
":ID: " (org-roam-node-id org-roam-node) n
|
||||||
|
":Effort: " p n
|
||||||
|
":END:" n
|
||||||
|
)))
|
||||||
|
|
||||||
(setq org-roam-capture-templates
|
(setq org-roam-capture-templates
|
||||||
`(("i" "Inbox" entry
|
`(("i" "Inbox" entry
|
||||||
,(concat "* ${title} :inbox:\n"
|
"%?"
|
||||||
":PROPERTIES:\n"
|
:target (file+olp "inbox.org" ("Shopping list"))
|
||||||
":CREATED: %U\n"
|
:hook (lambda () (org-roam-tempel-node nil)))
|
||||||
":ID: %(org-id-uuid)\n"
|
|
||||||
":END:\n"
|
("f" "File" plain
|
||||||
"#+setupfile: ~/roam/emacs-lisp/setupfiles/latex-base.org\n\n"
|
"%?"
|
||||||
"%?")
|
:target (file "${slug}.org")
|
||||||
:target (file+olp "inbox.org" ("Shopping list")))
|
:hook (lambda () (org-roam-tempel-node t)))
|
||||||
("f" "File" plain "%?"
|
|
||||||
:target (file+head "${slug}.org"
|
|
||||||
,(concat ":PROPERTIES:\n"
|
|
||||||
":CREATED: %U\n"
|
|
||||||
":ID: %(org-id-uuid)\n"
|
|
||||||
":END:\n"
|
|
||||||
"#+setupfile: ~/roam/emacs-lisp/setupfiles/latex-base.org\n\n"
|
|
||||||
"#+title: ${title}\n"
|
|
||||||
"")))
|
|
||||||
("@" "Inbox [mu4e]" entry
|
("@" "Inbox [mu4e]" entry
|
||||||
,(concat "* Process \"%a\" %? :inbox:\n"
|
,(concat "* Process \"%a\" %? :inbox:\n"
|
||||||
":PROPERTIES:\n"
|
":PROPERTIES:\n"
|
||||||
|
@ -74,23 +127,26 @@ So the process for capturing is to trigger the capture with ~C-c o c~ and then q
|
||||||
":END:\n\n"
|
":END:\n\n"
|
||||||
"%?")
|
"%?")
|
||||||
:target (file+olp "inbox.org" ("All")))
|
:target (file+olp "inbox.org" ("All")))
|
||||||
("t" "TODO" entry
|
|
||||||
,(concat "* TODO ${title} :inbox:\n"
|
("t" "Task" entry
|
||||||
":PROPERTIES:\n"
|
,(concat "* TODO ${title}\n"
|
||||||
":CREATED: %U\n"
|
|
||||||
":ID: %(org-id-uuid)\n"
|
|
||||||
":END:\n\n"
|
|
||||||
"%?")
|
"%?")
|
||||||
:target (file+olp "inbox.org" ("Todo")))
|
:target (file "tasks.org")
|
||||||
|
:empty-lines 1
|
||||||
|
:hook org-roam-tempel-task)
|
||||||
|
|
||||||
("r" "Resource")
|
("r" "Resource")
|
||||||
("rw" "Web resource" entry
|
|
||||||
,(concat "* ${title} :resource:inbox:\n"
|
("rw" "Web resource" plain
|
||||||
":PROPERTIES:\n"
|
"%?"
|
||||||
":CREATED: %U\n"
|
:target (file "web-${slug}.org")
|
||||||
":ROAM_REFS: %(completing-read \"URL for resource: \" nil nil nil nil nil (or (substring-no-properties (car kill-ring)) nil))\n"
|
:hook org-roam-tempel-web-resource)
|
||||||
":ID: %(org-id-uuid)\n"
|
|
||||||
":END:\n\n")
|
("rr" "Recipe" plain
|
||||||
:target (file+olp "inbox.org" ("Resources" "Web")))
|
"%?"
|
||||||
|
:target (file "recipe-${slug}.org")
|
||||||
|
:hook org-roam-tempel-recipe)
|
||||||
|
|
||||||
("E" "Event" entry
|
("E" "Event" entry
|
||||||
,(concat "* ${title} :event:inbox:\n"
|
,(concat "* ${title} :event:inbox:\n"
|
||||||
":PROPERTIES:\n"
|
":PROPERTIES:\n"
|
||||||
|
@ -237,37 +293,23 @@ Now the fun part. I only define one unified agenda view for now. It allows
|
||||||
|
|
||||||
(setq org-agenda-custom-commands
|
(setq org-agenda-custom-commands
|
||||||
'(("g" "Get Things Done (GTD)"
|
'(("g" "Get Things Done (GTD)"
|
||||||
((agenda ""
|
((agenda "")
|
||||||
((org-agenda-skip-function
|
(org-ql-block '(and (todo "INPROGRESS")
|
||||||
'(org-agenda-skip-entry-if 'deadline))
|
(not (deadline)))
|
||||||
(org-deadline-warning-days 0)))
|
((org-ql-block-header "Tasks Started")))
|
||||||
(todo "INPROGRESS"
|
(org-ql-block '(and (todo "NEXT")
|
||||||
((org-agenda-skip-function
|
(not (deadline)))
|
||||||
'(org-agenda-skip-entry-if 'deadline))
|
((org-ql-block-header "Tasks Planned")))
|
||||||
(org-agenda-prefix-format " %i %-12:c [%e] ")
|
(org-ql-block '(and (deadline "21d")
|
||||||
(org-agenda-overriding-header "\nTasks started\n")))
|
(not (or (todo "NEXT") (todo "CANCELLED") (todo "DONE"))))
|
||||||
(todo "NEXT"
|
((org-ql-block-header "Deadlines")))
|
||||||
((org-agenda-skip-function
|
(org-ql-block '(and (todo "TODO")
|
||||||
'(org-agenda-skip-entry-if 'deadline))
|
(not (deadline)))
|
||||||
(org-agenda-prefix-format " %i %-12:c [%e] ")
|
((org-ql-block-header "To be Done")))
|
||||||
(org-agenda-overriding-header "\nTasks planned\n")))
|
(org-ql-block '(and (tags "inbox"))
|
||||||
(agenda nil
|
((org-ql-block-header "Inbox")))
|
||||||
((org-agenda-entry-types '(:deadline))
|
(org-ql-block '(and (or (todo "CANCELLED") (todo "DONE")) (closed :on today))
|
||||||
(org-agenda-format-date "")
|
((org-ql-block-header "Completed today")))))))
|
||||||
(org-deadline-warning-days 21)
|
|
||||||
(org-agenda-skip-function
|
|
||||||
'(org-agenda-skip-entry-if 'notregexp "\\* NEXT"))
|
|
||||||
(org-agenda-overriding-header "\nDeadlines")))
|
|
||||||
(todo "TODO"
|
|
||||||
((org-agenda-prefix-format " %?-12t% s")
|
|
||||||
(org-agenda-skip-function
|
|
||||||
'(my/org-agenda-skip-without-match "-inbox"))
|
|
||||||
(org-agenda-overriding-header "\nTo be done\n")))
|
|
||||||
(tags "inbox"
|
|
||||||
((org-agenda-prefix-format " %?-12t% s")
|
|
||||||
(org-agenda-overriding-header "\nInbox\n")))
|
|
||||||
(tags "CLOSED>=\"<today>\""
|
|
||||||
((org-agenda-overriding-header "\nCompleted today\n")))))))
|
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
** Keybindings
|
** Keybindings
|
||||||
|
@ -292,3 +334,11 @@ Now the fun part. I only define one unified agenda view for now. It allows
|
||||||
:keymaps '(mu4e-headers-mode-map mu4e-view-mode-map)
|
:keymaps '(mu4e-headers-mode-map mu4e-view-mode-map)
|
||||||
"C-c i" 'org-capture-mail)
|
"C-c i" 'org-capture-mail)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
** Org QL
|
||||||
|
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(use-package org-ql
|
||||||
|
:straight (org-ql :fetcher github :repo "alphapapa/org-ql"
|
||||||
|
:files (:defaults (:exclude "helm-org-ql.el"))))
|
||||||
|
#+end_src
|
||||||
|
|
Loading…
Reference in a new issue