Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parent's :custom plist overrides children properties #28

Closed
prashantnag93 opened this issue Sep 23, 2021 · 7 comments
Closed

Parent's :custom plist overrides children properties #28

prashantnag93 opened this issue Sep 23, 2021 · 7 comments
Assignees
Labels
support question regarding use, installation, etc.

Comments

@prashantnag93
Copy link

prashantnag93 commented Sep 23, 2021

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

@prashantnag93 prashantnag93 added the support question regarding use, installation, etc. label Sep 23, 2021
@progfolio
Copy link
Owner

progfolio commented Sep 23, 2021

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.

@progfolio progfolio changed the title Org-capture not using defined templates Parent's :custom plist overrides children properties Sep 23, 2021
progfolio added a commit that referenced this issue Sep 23, 2021
If a parent had a :custom plist, the plist's properties would override the
child's properties unless they were also declared in a :custom plist. e.g.

("parent" :custom (:property t)
          :children ("child" :property nil))

Would incorrectly return t when filling the "child" template. This is because we
were appending to the :doct-custom plist in the case of inheritance, which would
allow for the same key to appear multiple times. `plist-get' will return the
first found key's value (in this case the "parent" declaration's).

See: #28
@prashantnag93
Copy link
Author

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
Copy link
Owner

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:
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 straight-ref-origin/master bf8ba74 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:
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 development c38f657 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
Copy link
Author

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
Copy link
Owner

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
Copy link
Author

@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
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support question regarding use, installation, etc.
Projects
None yet
Development

No branches or pull requests

2 participants