progfolio / doct

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

Parent's :custom plist overrides children properties #28

Closed prashantnag93 closed 3 years ago

prashantnag93 commented 3 years ago

Part of my org-capture-template config is as follows:

    ("Project" :keys "p"
                   :icon ("repo" :set "octicon" :color "silver")
                   :prepend t
                   :type entry
                   :headline "Inbox"
                   :template ("* %{time-or-todo} %?"
                              "%i"
                              "%a")
                   :custom (:time-or-todo "")
                   :children (("Project-local todo" :keys "t"
                               :icon ("checklist" :set "octicon" :color "green")
                               :time-or-todo "TODO"
                               :function +org-capture-project-todo-file)
                              ("Project-local note" :keys "n"
                               :icon ("sticky-note" :set "faicon" :color "yellow")
                               :time-or-todo "%U"
                               :file +org-capture-project-notes-file)
                              ("Project-local changelog" :keys "c"
                               :icon ("list" :set "faicon" :color "blue")
                               :time-or-todo "%U"
                               :heading "Unreleased"
                               :file +org-capture-project-changelog-file))

This code is not using the specified templates. when I used "Project-local todo" it gives me this template: 3 when I used "Project-local changelog" it gives me this template: 1 when I used "Project-local note" it gives me this template: 2

progfolio commented 3 years ago

You haven't given enough context for me to help you. Please show the value of org-capture-templates and all code which is being used to set them. Be specific about what you expected to happen and what is actually happening.

prashantnag93 commented 3 years ago

This is my config:

    (setq org-capture-templates
          (doct `(("Personal todo" :keys "t"
                   :icon ("checklist" :set "octicon" :color "green")
                   :file +org-capture-todo-file
                   :prepend t
                   :headline "Inbox"
                   :type entry
                   :template ("* TODO %?"
                              "%i %a")
                   )
                  ("Personal note" :keys "n"
                   :icon ("sticky-note-o" :set "faicon" :color "green")
                   :file +org-capture-todo-file
                   :prepend t
                   :headline "Inbox"
                   :type entry
                   :template ("* %?"
                              "%i %a"))
                  ("Email" :keys "e"
                   :icon ("envelope" :set "faicon" :color "blue")
                   :file +org-capture-todo-file
                   :prepend t
                   :headline "Inbox"
                   :type entry
                   :template ("* TODO %^{type|reply to|contact} %\\3 %? :email:"
                              "Send an email %^{urgancy|soon|ASAP|anon|at some point|eventually} to %^{recipiant}"
                              "about %^{topic}"
                              "%U %i %a"))
                  ("Interesting" :keys "i"
                   :icon ("eye" :set "faicon" :color "lcyan")
                   :file +org-capture-todo-file
                   :prepend t
                   :headline "Interesting"
                   :type entry
                   :template ("* [ ] %{desc}%? :%{i-type}:"
                              "%i %a")
                   :children (("Webpage" :keys "w"
                               :icon ("globe" :set "faicon" :color "green")
                               :desc "%(org-cliplink-capture) "
                               :i-type "read:web"
                               )
                              ("Article" :keys "a"
                               :icon ("file-text" :set "octicon" :color "yellow")
                               :desc ""
                               :i-type "read:reaserch"
                               )
                              ("Information" :keys "i"
                               :icon ("info-circle" :set "faicon" :color "blue")
                               :desc ""
                               :i-type "read:info"
                               )
                              ("Idea" :keys "I"
                               :icon ("bubble_chart" :set "material" :color "silver")
                               :desc ""
                               :i-type "idea"
                               )))
                  ("Tasks" :keys "k"
                   :icon ("inbox" :set "octicon" :color "yellow")
                   :file +org-capture-todo-file
                   :prepend t
                   :headline "Tasks"
                   :type entry
                   :template ("* TODO %? %^G%{extra}"
                              "%i %a")
                   :children (("General Task" :keys "k"
                               :icon ("inbox" :set "octicon" :color "yellow")
                               :extra ""
                               )
                              ("Task with deadline" :keys "d"
                               :icon ("timer" :set "material" :color "orange" :v-adjust -0.1)
                               :extra "\nDEADLINE: %^{Deadline:}t"
                               )
                              ("Scheduled Task" :keys "s"
                               :icon ("calendar" :set "octicon" :color "orange")
                               :extra "\nSCHEDULED: %^{Start time:}t"
                               )
                              ))
                  ("Project" :keys "p"
                   :icon ("repo" :set "octicon" :color "silver")
                   :prepend t
                   :type entry
                   :headline "Inbox"
                   :template ("* %{time-or-todo} %?"
                              "%i"
                              "%a")
                   :custom (:time-or-todo "")
                   :children (("Project-local todo" :keys "t"
                               :icon ("checklist" :set "octicon" :color "green")
                               :time-or-todo "TODO"
                               :function +org-capture-project-todo-file)
                              ("Project-local note" :keys "n"
                               :icon ("sticky-note" :set "faicon" :color "yellow")
                               :time-or-todo "%U"
                               :file +org-capture-project-notes-file)
                              ("Project-local changelog" :keys "c"
                               :icon ("list" :set "faicon" :color "blue")
                               :time-or-todo "%U"
                               :heading "Unreleased"
                               :file +org-capture-project-changelog-file))
                   )
                  ("\tCentralised project templates"
                   :keys "o"
                   :type entry
                   :prepend t
                   :template ("* %{time-or-todo} %?"
                              "%i"
                              "%a")
                   :children (("Project todo"
                               :keys "t"
                               :prepend nil
                               :time-or-todo "TODO"
                               :heading "Tasks"
                               :file +org-capture-central-project-todo-file)
                              ("Project note"
                               :keys "n"
                               :time-or-todo "%U"
                               :heading "Notes"
                               :file +org-capture-central-project-notes-file)
                              ("Project changelog"
                               :keys "c"
                               :time-or-todo "%U"
                               :heading "Unreleased"
                               :file +org-capture-central-project-changelog-file))
                  )))))

Expected Behaviour: After invoking org-capture from inside a project then select the Project parent with the key p--> If I select t(Project todo) then It should capture the notes with the following template

:template ("* %{time-or-todo} %?"
                              "%i"
                              "%a")

but it is not using the above templates. instead, it just inserting the heading. Screenshot is attached 4 .

progfolio commented 3 years ago

I think I understand the issue. You've declared a :custom plist on the parent declaration which is overriding the property on the children because they are not declared as :custom. Here's a minimal reproduction case which illustrates this:

YODEL REPORT (2021-09-23 12:13:17):

(yodel
  :user-dir "doct-test.yodel"
  :formatter yodel-format-as-github-markdown
  :packages*
  (doct
   :ref "origin/master")
  :post*
  (yodel-file "./test.org"
    :overwrite t
    :save t
    :with*
    "")
  (setq org-directory default-directory org-capture-templates
        (doct
         '(("Parent"
            :keys "p"
            :file "test.org"
            :immediate-finish t
            :template
            ("* %{property}")
            :custom
            (:property "PARENT")
            :children
            (("A"
              :keys "a"
              :custom
              (:property "Explicit"))
             ("B"
              :keys "b"
              :property "Implicit")
             ("C"
              :keys "c"))))))
  (org-capture nil "pa")
  (org-capture nil "pb")
  (org-capture nil "pc")
  (princ
   (with-current-buffer
       (find-file "test.org")
     (buffer-substring-no-properties
      (point-min)
      (point-max)))))
STDOUT: ```emacs-lisp Loading /tmp/doct-test.yodel/straight-bootstrap-snippet.el (source)... Bootstrapping straight.el... Bootstrapping straight.el...done Rebuilding all packages due to build cache schema change Looking for gnu-elpa-mirror recipe → Cloning melpa... Looking for gnu-elpa-mirror recipe → Cloning melpa...done Looking for emacsmirror-mirror recipe → Cloning gnu-elpa-mirror... Looking for emacsmirror-mirror recipe → Cloning gnu-elpa-mirror...done Looking for emacsmirror-mirror recipe → Cloning el-get... Looking for emacsmirror-mirror recipe → Cloning el-get...done Looking for straight recipe → Cloning emacsmirror-mirror... Looking for straight recipe → Cloning emacsmirror-mirror...done Building straight... Building straight...done Cloning doct... Cloning doct...done Building doct... Building doct...done Clipboard pasted as level 1 subtree Clipboard pasted as level 1 subtree Clipboard pasted as level 1 subtree * Explicit * PARENT * PARENT ```
Environment - **emacs version**: GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.17.4, Xaw3d scroll bars) of 2021-09-16 - **system type**: gnu/linux
Packages | Name | Branch | Commit | Date | Source | |-------------------------------------------|----------------------------|-----------------------------------------------------------------------------------|------------|--------| | [doct](https://github.com/progfolio/doct) | straight-ref-origin/master | https://github.com/progfolio/doct/commit/bf8ba74cf29c876958e8c7249e044d7800145f9d | 2021-09-17 | melpa |

Here the implicitly declared :property is ignored when filling template B.

I've pushed a patch to the "development" branch which should correct this. Tested with the following:

YODEL REPORT (2021-09-23 12:27:53):

(yodel
  :user-dir "doct-test.yodel"
  :formatter yodel-format-as-github-markdown
  :packages*
  (doct
   :branch "development")
  :post*
  (yodel-file "./test.org"
    :overwrite t
    :save t
    :with*
    "")
  (setq org-directory default-directory org-capture-templates
        (doct
         '(("Parent"
            :keys "p"
            :file "test.org"
            :immediate-finish t
            :template
            ("* %{property}")
            :custom
            (:property "PARENT")
            :children
            (("A"
              :keys "a"
              :custom
              (:property "Explicit"))
             ("B"
              :keys "b"
              :property "Implicit")
             ("C"
              :keys "c"))))))
  (org-capture nil "pa")
  (org-capture nil "pb")
  (org-capture nil "pc")
  (princ
   (with-current-buffer
       (find-file "test.org")
     (buffer-substring-no-properties
      (point-min)
      (point-max)))))
STDOUT: ```emacs-lisp Loading /tmp/doct-test.yodel/straight-bootstrap-snippet.el (source)... Bootstrapping straight.el... Bootstrapping straight.el...done Rebuilding all packages due to build cache schema change Looking for gnu-elpa-mirror recipe → Cloning melpa... Looking for gnu-elpa-mirror recipe → Cloning melpa...done Looking for emacsmirror-mirror recipe → Cloning gnu-elpa-mirror... Looking for emacsmirror-mirror recipe → Cloning gnu-elpa-mirror...done Looking for emacsmirror-mirror recipe → Cloning el-get... Looking for emacsmirror-mirror recipe → Cloning el-get...done Looking for straight recipe → Cloning emacsmirror-mirror... Looking for straight recipe → Cloning emacsmirror-mirror...done Building straight... Building straight...done Cloning doct... Cloning doct...done Building doct... Building doct...done Clipboard pasted as level 1 subtree Clipboard pasted as level 1 subtree Clipboard pasted as level 1 subtree * Explicit * Implicit * PARENT ```
Environment - **emacs version**: GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.17.4, Xaw3d scroll bars) of 2021-09-16 - **system type**: gnu/linux
Packages | Name | Branch | Commit | Date | Source | |-------------------------------------------|-------------|-----------------------------------------------------------------------------------|------------|--------| | [doct](https://github.com/progfolio/doct) | development | https://github.com/progfolio/doct/commit/c38f65764e5be8d3b9705650c6a459e89a75ded3 | 2021-09-23 | melpa |

Here, child B's implicit :property is filled in correctly in the template. Would you mind testing the development branch to see if this fixes your issue?

As a side note, the :custom keyword isn't necessary in your declaration because time-or-todo is not a member of doct-recognized-keywords. It will automatically be considered custom. I've fixed it so that it will work the way you're using it, but really it's only necessary when you want to use a keyword which is already a member of doct-recognized-keywords. See the example using :keys here:

https://github.com/progfolio/doct#custom-data

prashantnag93 commented 3 years ago

Thank you @progfolio for quickly fixing the issue. Now the template-related issue is solved. but :function +org-capture-project-todo-file) is not able to find the right file. All the project-local-todo are going in the file opened in the current buffer.

progfolio commented 3 years ago

You're welcome. It's a little hard for me to diagnose what's wrong with that function considering you haven't provided the definition of that function.

prashantnag93 commented 3 years ago

@progfolio I am using doom-emacs and org-capture template I have taken from @tecosaur config. I hope he will be able to provide the definition of that function.

progfolio commented 3 years ago

OK. I see you've opened an issue on his repo. I don't think this has anything more to do with doct, so I'm going to close this issue. If you find any more information that points to it being a bug in doct, just comment here and I will reopen this issue.