emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Export tangle filename with source block


From: Nicolas Goaziou
Subject: Re: [O] Export tangle filename with source block
Date: Tue, 11 Oct 2016 20:57:31 +0200

Hello,

Thibault Marin <address@hidden> writes:

> *Question 1*: Is the `org-element-src-block-parser' function supposed to 
> resolve
>  the tangle filename (including inheritance, i.e. to handle the 3 :tangle
>  sources listed above)?

No, it isn't.

> From the docstring, it would appear that it shouldn't return a :tangle keyword
> and that the tangling functions are responsible for choosing the output tangle
> file for each block.  Is this correct?

That's correct.

> ** Improvements (which I cannot get to work)
>
> - Add collected blocks to `info' in order to perform the collection only once
>   and re-use it for subsequent blocks: I couldn't get it to work, function
>   arguments seem to be passed by value (?)

They are not. You may want to see how cache is used with info in, e.g.,
`org-export-get-footnote-definition'.

> - Use `org-babel-tangle-single-block' to process only one block at a time, 
> this
>   sounds like the right method.  I believe I must first move point to the
>   src-block being processed, which I try to do with
>   (org-babel-goto-named-src-block src-block-name): this gives me the correct
>   tangle filename when run from a simple code snippet in the scratch buffer
>   (using (org-element-map (org-element-parse-buffer) ...)), but results in the
>   wrong tangle file when I do that within the `my-html-src-block' function 
> (the
>   :tangle options passed on the #+BEGIN_SRC line as in case 3. are ignored and
>   are always preempted by the inherited tangle value coming either from the
>   ,#+PROPERTY entry or the PROPERTY drawer value).  *Question 2*: How can I 
> use
>   `org-babel-tangle-single-block' within the custom src-block handling 
> function?
>   I notice the (point) value is different after the
>   (org-babel-goto-named-src-block src-block-name) call when used from the
>   `my-html-src-block' function (possibly due to some pre-processing performed 
> on
>   the buffer, I am not sure).

The buffer used during export is unlikely to be the same as the original
one. Macros are expanded, comments are removed and Babel code is
possibly evaluated. The only hook run in an exact copy of the original
buffer is `org-export-before-processing-hook'. You can collect anything
here, but INFO doesn't exist yet.

Regards,

-- 
Nicolas Goaziou



reply via email to

[Prev in Thread] Current Thread [Next in Thread]