emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: Thibault Marin <thibault.marin@gmx.com>
Cc: Org Mode <emacs-orgmode@gnu.org>
Subject: Re: Export tangle filename with source block
Date: Tue, 11 Oct 2016 20:57:31 +0200	[thread overview]
Message-ID: <87pon6pvc4.fsf@nicolasgoaziou.fr> (raw)
In-Reply-To: <87r37qzl8c.fsf@dell-desktop.WORKGROUP> (Thibault Marin's message of "Sat, 08 Oct 2016 14:36:35 -0500")

Hello,

Thibault Marin <thibault.marin@gmx.com> 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	other threads:[~2016-10-11 18:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-31  3:45 Export tangle filename with source block Thibault Marin
2016-10-08 19:36 ` Thibault Marin
2016-10-11 18:57   ` Nicolas Goaziou [this message]
2016-10-12  4:39     ` Thibault Marin
2016-10-12 23:48       ` Thibault Marin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pon6pvc4.fsf@nicolasgoaziou.fr \
    --to=mail@nicolasgoaziou.fr \
    --cc=emacs-orgmode@gnu.org \
    --cc=thibault.marin@gmx.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).