progfolio / doct

DOCT: Declarative Org Capture Templates for Emacs
GNU General Public License v3.0
375 stars 8 forks source link

Set up child-based category #7

Closed arkhan closed 4 years ago

arkhan commented 4 years ago

Regards,

Great job with this, it simplifies the templates for org-capture quite a bit.

I have a question or I don't know if it's a feature request.

How can I set the property: CATEGORY: based on a child, I am dealing with this:

(leaf doct
  :straight t
  :leaf-defer nil
  :commands (doct)
  :config
  (setq org-capture-templates
      (doct '(("Work" :keys "w"
               :file "~/org/work.org"
               :prepend t
               :template ("* %doct(todo-state) %^{Description}"
                          "SCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+0d\"))"
                          ":PROPERTIES:"
                          ":CREATED: %U"
                          ":CATEGORY: %doct(headline)%"
                          ":END:"
                          "%?")
               :children (("Task"  :keys "w"
                           :headline   "Task"
                           :todo-state "TODO"
                           :hook (lambda () (message "\"First Child\" selected.")))
                          ("Second Child" :keys "2"
                           :headline   "Two"
                           :todo-state "NEXT")
                          ("Third Child"  :keys "3"
                           :headline   "Three"
                           :todo-state "MAYBE")))))))

But it doesn't work, you can tell me if this can be done.

PS .: leaf.el the similar to use-package

Thank you

progfolio commented 4 years ago

Thanks for checking it out and the issue report. The function responsible for getting the values in %doct(keyword) expansion strings was only checking custom metada. No reason it can't do that and, if no custom metadata keyword is found, fallback to the the keywords present on the original declaration. I've pushed a patch with this behavior on this branch:

https://github.com/progfolio/doct/tree/fix-doct-get-recognized-keywords

Your example templates should work on that branch. Would you mind testing it?

Just read through the documentation for leaf.el. I like the flexibility it provides over use-package. I'll have to try it out.

arkhan commented 4 years ago

@progfolio I just tried it, and it works perfectly

progfolio commented 4 years ago

Excellent, I'll merge into master. Thanks again for the report. You've helped make doct a better package!