The other day I wanted to put the contents of a source code block into a header argument of another block. I couldn't find any ready to use function to do that though, so I came up with this:
(defun extract-src-content (name)
(save-excursion
(org-babel-goto-named-src-block name)
(car (nthcdr 21 (cadr (org-element-at-point))))))
But that doesn't seem to be right. First my elisp experience is not that vast so I don't know how to extract the value for the :value
key out of (cadr (org-element-at-point))
so I just took the 21th element which can't be right and will probably break at the next org update. Second I still think there should be an org-function available to extract the contents of a named source code block, since it has to have a way to do that for export or editing.
Someone has an answer to either question?
- What's the right way to extract the value after
:value
out of(cadr (org-element-at-point))
? - Is there a ready to use org-function (or even org-syntax) to accomplish the same thing?
Bonus question
- I tried to ask this on the #org-mode irc channel, but even though there are a lot of joined users it seems to be dead. Why is it still linked on http://orgmode.org/community.html then?
(cadr (org-babel-lob--src-info NAME))
fromob-lob
instead.