* processing of babel blocks and select_tags
@ 2022-02-18 11:57 Eric S Fraga
2022-02-18 15:33 ` John Kitchin
2022-02-19 7:54 ` Jeremie Juste
0 siblings, 2 replies; 6+ messages in thread
From: Eric S Fraga @ 2022-02-18 11:57 UTC (permalink / raw)
To: Emacs Org mode mailing list
[-- Attachment #1: Type: text/plain, Size: 1171 bytes --]
Hello all,
TL;DR: can I have org completely ignore src blocks in non-selected
sections during export without using COMMENT?
Longer version: I am in the process of writing a book. I prefer to have
all the content in one file and use SELECT_TAGS to limit the export (for
formatting) to the current section I am working on.
I have noticed that all org babel src blocks are processed in some way
even if (a) they are not in a selected section and (b) have, for
instance, ":eval no-export" set. For some of these blocks, the
processing time appears to be quite significant, e.g. if they have a
":var x=somebigtable", but I could be wrong about this, of course.
I do not understand why these src blocks are processed at all. Is there
some way to stop them being processed? I know I could "comment" out all
other sections but that's a lot more work and messy than simply tagging
the current section to be selected.
Attached is a minimal example. When I export, I see these messages:
org-babel-exp process julia at position 162...
org-babel-exp process julia at position 384...
Thank you,
eric
--
: Eric S Fraga, with org release_9.5.2-385-g37d8bc in Emacs 29.0.50
[-- Attachment #2: tag.org --]
[-- Type: application/vnd.lotus-organizer, Size: 461 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: processing of babel blocks and select_tags
2022-02-18 11:57 processing of babel blocks and select_tags Eric S Fraga
@ 2022-02-18 15:33 ` John Kitchin
2022-02-18 15:45 ` Eric S Fraga
2022-02-19 7:54 ` Jeremie Juste
1 sibling, 1 reply; 6+ messages in thread
From: John Kitchin @ 2022-02-18 15:33 UTC (permalink / raw)
To: Org Mode List
[-- Attachment #1: Type: text/plain, Size: 1848 bytes --]
I guess that is just expanding the src blocks, not actually running them. I
couldn't find where that happens though, it is early in the export process
I think.
Maybe you can just use a preprocessing hook to export to org, which should
only include the selected sections, then export that to what you want.
John
-----------------------------------
Professor John Kitchin (he/him/his)
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu
On Fri, Feb 18, 2022 at 7:07 AM Eric S Fraga <e.fraga@ucl.ac.uk> wrote:
> Hello all,
>
> TL;DR: can I have org completely ignore src blocks in non-selected
> sections during export without using COMMENT?
>
> Longer version: I am in the process of writing a book. I prefer to have
> all the content in one file and use SELECT_TAGS to limit the export (for
> formatting) to the current section I am working on.
>
> I have noticed that all org babel src blocks are processed in some way
> even if (a) they are not in a selected section and (b) have, for
> instance, ":eval no-export" set. For some of these blocks, the
> processing time appears to be quite significant, e.g. if they have a
> ":var x=somebigtable", but I could be wrong about this, of course.
>
> I do not understand why these src blocks are processed at all. Is there
> some way to stop them being processed? I know I could "comment" out all
> other sections but that's a lot more work and messy than simply tagging
> the current section to be selected.
>
> Attached is a minimal example. When I export, I see these messages:
>
> org-babel-exp process julia at position 162...
> org-babel-exp process julia at position 384...
>
> Thank you,
> eric
>
> --
> : Eric S Fraga, with org release_9.5.2-385-g37d8bc in Emacs 29.0.50
>
[-- Attachment #2: Type: text/html, Size: 2581 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: processing of babel blocks and select_tags
2022-02-18 15:33 ` John Kitchin
@ 2022-02-18 15:45 ` Eric S Fraga
0 siblings, 0 replies; 6+ messages in thread
From: Eric S Fraga @ 2022-02-18 15:45 UTC (permalink / raw)
To: John Kitchin; +Cc: Org Mode List
Hi John,
On Friday, 18 Feb 2022 at 10:33, John Kitchin wrote:
> I guess that is just expanding the src blocks, not actually running
> them. I couldn't find where that happens though, it is early in the
> export process I think.
There are two types of lines that appear often in *Messages*:
: org-babel-exp process julia at position 65992...
: Wrote /tmp/babel-B5awWV/ob-input-0gUtuB
The first is quite straightforward although why any processing is being
done is unclear unless this just means checking the header arguments,
which would make sense. For the second, although I am not entirely sure
what they refer to (as the tmp files disappear), I have a feeling that
this is where the problem is. I think this refers to where data tables
are being incorporated into or processed for a src block even when not
necessary.
It's reassuring that it doesn't sound like I am doing anything silly so
I will look into the babel code to see if I can figure out how to get it
to short-circuit sooner...
> Maybe you can just use a preprocessing hook to export to org, which
> should only include the selected sections, then export that to what
> you want.
I guess that is what I was hoping #+SELECT_TAGS would do for me. ;-)
Thank you,
eric
--
: Eric S Fraga, with org release_9.5.2-385-g37d8bc in Emacs 29.0.50
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: processing of babel blocks and select_tags
2022-02-18 11:57 processing of babel blocks and select_tags Eric S Fraga
2022-02-18 15:33 ` John Kitchin
@ 2022-02-19 7:54 ` Jeremie Juste
2022-02-19 16:47 ` Eric S Fraga
1 sibling, 1 reply; 6+ messages in thread
From: Jeremie Juste @ 2022-02-19 7:54 UTC (permalink / raw)
To: Org Mode List
Hello Eric,
On Friday, 18 Feb 2022 at 11:57, Eric S Fraga wrote:
> TL;DR: can I have org completely ignore src blocks in non-selected
> sections during export without using COMMENT?
If I change eval: no_export to :eval no, Only the =Description= section
is evaluated and exported. That said, I have often search in vain of a way of
using tags to prevent evaualtion of code chuck. I have resorted to use
either property at the heading or file level to control the execution
of code chunks.
** Subheading
:PROPERTIES:
:header-args:julia: :eval no
:END:
Another option would be to store what is needed in as a variable in a
session and use =:eval no= before exporting, but it might not be very
practical for a book.
I have a small helper function that toggle eval yes or no at the file
level, if it is of any help.
HTH,
Jeremie
* toggle eval yes.
(defun toggle-global-eval ()
"toggle :eval yes :evalno "
(interactive)
(save-excursion
(beginning-of-buffer)
(search-forward-regexp ":eval ")
(kill-word 1)
(setq wd (car kill-ring))
(if (equal "yes" wd)
(insert "no")
(insert "yes"))
(org-ctrl-c-ctrl-c))
(save-buffer)
(message "global :eval was %s" wd)
)
* file tag.org
#+title: org babel and select tags
#+select_tags: current
* Introduction
This section has some code that should not be evaluated on export.
#+name: introblock
#+begin_src julia :eval no
a = [1, 2, 3]
#+end_src
* Description :current:
I am writing this section right now.
* Conclusions
This will be worked on later.
#+name: conclusionblock
#+begin_src julia :eval no
a = [4, 5, 6]
#+end_src
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: processing of babel blocks and select_tags
2022-02-19 7:54 ` Jeremie Juste
@ 2022-02-19 16:47 ` Eric S Fraga
2022-10-23 5:35 ` Ihor Radchenko
0 siblings, 1 reply; 6+ messages in thread
From: Eric S Fraga @ 2022-02-19 16:47 UTC (permalink / raw)
To: Jeremie Juste; +Cc: Org Mode List
Dear Jeremie,
On Saturday, 19 Feb 2022 at 08:54, Jeremie Juste wrote:
> If I change eval: no_export to :eval no, Only the =Description= section
> is evaluated and exported.
Interesting. I hadn't considered trying just "no". What a difference
this makes! The book compiles in seconds instead of minutes. Thank
you.
It does beg the question: why do "no" and "no-export" behave differently
on export? Something to explore in due course but I'm happy for now.
> I have a small helper function that toggle eval yes or no at the file
> level, if it is of any help.
Very useful; always good to have little snippets like this.
Thanks again,
eric
--
: Eric S Fraga, with org release_9.5.2-385-g37d8bc in Emacs 29.0.50
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: processing of babel blocks and select_tags
2022-02-19 16:47 ` Eric S Fraga
@ 2022-10-23 5:35 ` Ihor Radchenko
0 siblings, 0 replies; 6+ messages in thread
From: Ihor Radchenko @ 2022-10-23 5:35 UTC (permalink / raw)
To: Eric S Fraga; +Cc: Jeremie Juste, Org Mode List
Eric S Fraga <e.fraga@ucl.ac.uk> writes:
> On Saturday, 19 Feb 2022 at 08:54, Jeremie Juste wrote:
>> If I change eval: no_export to :eval no, Only the =Description= section
>> is evaluated and exported.
>
> Interesting. I hadn't considered trying just "no". What a difference
> this makes! The book compiles in seconds instead of minutes. Thank
> you.
>
> It does beg the question: why do "no" and "no-export" behave differently
> on export? Something to explore in due course but I'm happy for now.
"no" and "no-export" should not behave differently.
Could you please check if this is still happening and possibly provide
an example file?
I tried to export with :eval no-export on my side and the code block is
correctly not being executed during export.
--
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>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-10-24 6:00 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-18 11:57 processing of babel blocks and select_tags Eric S Fraga
2022-02-18 15:33 ` John Kitchin
2022-02-18 15:45 ` Eric S Fraga
2022-02-19 7:54 ` Jeremie Juste
2022-02-19 16:47 ` Eric S Fraga
2022-10-23 5:35 ` Ihor Radchenko
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).