dominic meiser <[email protected]> writes:

>> > * lisp/ob-lob.el (org-babel-lob-ingest): Pass :eval context when
>> > ingesting named blocks into the Library of Babel.
>>
>> We should probably drop calling noweb expansion altogether here.
>> But we need to make sure that
>> https://lists.gnu.org/archive/html/emacs-orgmode/2017-09/msg00361.html
>> does not re-appear.
>
> Is there any additional due diligence I need to do regarding the issue
> reference here?

Sorry, I do not understand the question. Could you please elaborate?

> In other news, I've submitted the assignment form to fsf and my
> understanding is that the process is almost complete.

Great! Remember that you can always ask me to push them, if the process
is stuck for any reason.

> Subject: [PATCH] ob-core: Fix noweb tangle recursive expansion
>
> * lisp/ob-tangle.el (org-babel-tangle-single-block): Pass :tangle as
> CONTEXT to org-babel-expand-noweb-references.

Please quote Elisp symbols like `org-babel-expand-noweb-references'. See
https://orgmode.org/worg/org-contribute.html#org76b803f

> * lisp/ob-lob.el (org-babel-lob-ingest): Remove premature noweb
> expansion.  Both org-babel-execute-src-block and
> org-babel-exp-do-export handle noweb expansion with appropriate
> context when the block is actually used, making expansion during
> ingest redundant and preventing context-specific behavior.

Please document this breaking change in etc/ORG-NEWS.
This is actually not very breaking as we give no promises about what
exactly is inside library of babel, but still a good idea to warn users
just in case if some code is using `org-babel-library-of-babel' directly.

> -(defun org-babel-expand-noweb-references (&optional info parent-buffer)
> +(defun org-babel-expand-noweb-references (&optional info parent-buffer 
> context)
>    "Expand Noweb references in the body of the current source code block.
>  
>  When optional argument INFO is non-nil, use the block defined by INFO
> @@ -3146,6 +3154,20 @@ instead.
>  The block is assumed to be located in PARENT-BUFFER or current buffer
>  \(when PARENT-BUFFER is nil).
>  
> +CONTEXT specifies the context of expansion and can be one of :tangle,
> +:export, or :eval.  When CONTEXT is nil, it defaults to :eval.
> +
> +The context determines which noweb header arguments are honored when
> +recursively expanding nested references:
> +- :tangle context: expands blocks with :noweb tangle, :noweb yes, etc.
> +- :export context: expands blocks with :noweb export, :noweb yes, etc.
> +- :eval context: expands blocks with :noweb eval, :noweb yes, etc.
> +
> +This is important for recursive expansion: when a block with :noweb tangle
> +references another block that also contains noweb references, those nested
> +references should only be expanded if the referenced block's :noweb setting
> +permits expansion in the tangle context.

One potentially confusing thing here is that CONTEXT does not apply to
top-level expansion. We may need to highlight this fact in the docstring.

-- 
Ihor Radchenko // yantar92,
Org mode maintainer,
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>

Reply via email to