1

Update: I debugged this by just running (org-entry-get (point) "header-args" 'inherit) on the source blocks. Turns out I was too tired and the subtrees I thought were buggy actually weren't children of the noweb tree. There was no bug at all. Sorry.


I am working on an Org-mode document where I want the :header-args: :noweb-ref property to apply to code blocks under subheadings, but I'm having trouble getting the property to inherit correctly.

I have the following structure in my document:

* Main Heading
  :PROPERTIES:
  :header-args: :noweb-ref IMPORTS
  :END:

** Subheading
   #+begin_src jupyter-python :exports both
   # Some code here...
   #+end_src

The :header-args: :noweb-ref IMPORTS property applies to code blocks directly under the main heading, but it doesn't seem to apply to code blocks under the subheadings. I want this property to be inherited by all subheadings and their code blocks without having to redefine it at each level.

I tried adding header-args to org-use-property-inheritance using this in my Emacs configuration:

(add-to-list 'org-use-property-inheritance "header-args")

But this doesn't seem to work, as the header-args property seemingly is still not inherited by the subheadings. (How do I check this for sure? I just tried running some noweb blocks manually and the code in the subheadings did not execute.)

How can I ensure that :header-args: :noweb-ref is inherited by all subheadings and their code blocks? Is there another way to configure property inheritance in Org-mode for this use case?

I vaguely remember that this used to work correctly before, and I might have changed sth in my config that broke it. But I have no idea what.

Any help would be appreciated!

7
  • 1
    Use C-c c-v I (bound to org-babel-view-src-block-info) to check the environment of each code block. FWIW, I get :noweb-ref IMPORTS on a code block in the main section, as well as in the code block in the subsection. If that is not the case with you, start with emacs -Q to make sure that you get the expected results in that case and, assuming that you do, bisect your init file to find what broke it - see emacs.stackexchange.com/questions/28429/…
    – NickD
    Commented Oct 21 at 13:00
  • And if C-c C-v I gives you the expected result but you still don't get what you expect when tangling, exporting or evaluating, then you are probably doing something wrong and we'd need to see more details of what you are doing.
    – NickD
    Commented Oct 21 at 13:04
  • If this question is not resolved yet, can you please update it with some details? If it has been resolved, can you provide an answer explaining the resolution? Thanks!
    – NickD
    Commented Oct 24 at 15:38
  • 1
    @NickD Thanks, I debugged this by just running (org-entry-get (point) "header-args" 'inherit) on the source blocks. Turns out I was too tired and the subtrees I thought were buggy actually weren't children of the noweb tree. There was no bug at all. Sorry.
    – HappyFace
    Commented Oct 27 at 13:18
  • 1
    No problem. I'm glad that you got it resolved.
    – NickD
    Commented Oct 27 at 16:38

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.