Théo Maxime Tyburn <theo.tyb...@gmail.com> writes: > What I would like to have, when I expand `<<bar>>` is to get all the blocks > under A, and when I expand `<<foo>>` I get all the blocks under B. For > now when I expand `<<foo>>` I only get the blocks under A that are not under > B. > > Is there a way to do this with the current features of org-babel?
No, AFAIK. Not easily at least. > Anyway I tried to hack my way trough it. It seems there are two things > to do : > 1) Enable noweb-ref to contain multiple references. > 2) Accumulate references when using header-args+ or use tags to set the > value of noweb-ref > > I came up with a quick patch for 1): > modified lisp/ob-core.el > @@ -2910,8 +2910,11 @@ block but are passed literally to the > \"example-block\"." > (if (org-in-commented-heading-p) > (org-forward-heading-same-level nil t) > (let* ((info (org-babel-get-src-block-info t)) > - (ref (cdr (assq :noweb-ref (nth 2 info))))) > - (push info (gethash ref cache)))))) > + (refs (cdr (assq :noweb-ref (nth 2 info))))) > + (if refs > + (dolist (ref (s-split "+" refs)) > + (push info (gethash ref cache))) > + (push info (gethash refs cache))))))) + is a bit awkward. Space would be more logical as separator. Though I am wondering if people are using noweb reference names with spaces in the wild. > Feedback on the code is of course very welcome. Not sure if using a plus > sign as a delimiter is clever. Also not sure if using `s-split` is a > good idea, what would be the builtin alternative? There is built-in `split-string'. > For 2) I didn't check in detail how one could achieve this. I have the > impression it would be easier to use tags. One could define a > new variable `org-babel-set-noweb-refs-from-tags` that would be used in > `org-babel-get-src-block-info` to generate the value of noweb-ref we > would like to have depending on the tags of the headline of the > block. I'll try this soonish. I do not like the idea of using tags. What we might do is: 1. Leave :noweb-ref's current behavior of overwriting the parent parameter values. 2. Add a new :noweb-ref+ parameter to accumulate multiple noweb reference names. The relevant function to modify is `org-babel-merge-params' -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92>