Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

9
  • There is nothing odd about that if you call the function from your init file: it will only work if the current buffer is an Org mode file where each code block has a :tangle header arg of the appropriate form (either individually or set with a property). You can define the function in your init file, but you can not call it there. In addition, as I mentioned, you'll have to implement your own loop: org-babel-get-src-block assumes that it is called with point in the source block: if you call it from elsewhere, it will return nil, so you cannot call org-babel-tangle... Commented Sep 16, 2023 at 12:46
  • You'll have to use a mapping function (like org-babel-map-src-blocks) and evaluate a function that tangles the current source block only (using org-babel-get-src-block-info on the current block to glean the info you need). Commented Sep 16, 2023 at 12:50
  • Sorry if I wasn't clear in my explanation. I always call the function from an org file containing latex or lilypond source blocks and #+PROPERTY: header-args :LANG :comments org :tangle PATH/FILE_NAME.EXT in the first line. When the function is compiled inside the tangled buffer it works, but when it is not (when it is only present in the init) it doesn't. Commented Sep 16, 2023 at 12:52
  • So it's the second comment that is applicable: you'll have to implement your own loop using the mapping function - you cannot call org-babel-tangle to tangle them all first. Commented Sep 16, 2023 at 12:58
  • You cannot use a single #+PROPERTY line for every block: LANG and PATH and FILENAME are different for each block - no? Commented Sep 16, 2023 at 13:03