emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: ian martins <ianxm@jhu.edu>
To: Nathan Neff <nathan.neff@gmail.com>
Cc: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: Babel: Programmatically evaluate a heading and subtrees?
Date: Sat, 27 Feb 2021 08:18:45 -0500	[thread overview]
Message-ID: <CAC=rjb4iJPkXjOVAi83jjBrc=4TjEZhr_KrEnYvF_K0GSapHOw@mail.gmail.com> (raw)
In-Reply-To: <CAC=HedDHDT7Gp7d2F=XAE03H5tKmbkYSQghNJ+qwHthrZDoUxA@mail.gmail.com>

Can you use noweb? In the example below, if you run the top code block
babel will run the two that follow.

A drawback is that you have to redefine variables, but it might be a
benefit, since the individual blocks could be set with test data and
the "main driver" could point to real data.

#+begin_src elisp :results output :noweb yes :var data=data1

: called fun1: some data
: called fun2

#+name: data1
some data

#+name: fun1
#+begin_src elisp :var data=data1
(princ (format "called fun1: %s" data))

#+name: fun2
#+begin_src elisp
(princ "called fun2")

On Sat, Feb 20, 2021 at 2:11 PM Nathan Neff <nathan.neff@gmail.com> wrote:
> Hello all,
> I have some code like this:
> * Heading 1
> # code block name:FOO
> ** Subheading 1
> # code block
> ** Subheading 2
> # code block
> I find that I often want to evaluate the code in Heading 1 and its subheadings.
> Currently, I navigate to Heading 1 and then use org-babel-execute-subtree
> I see that there's a function called org-babel-goto-named-src-block, so I think
> I could write a small function to jump to FOO in Heading 1 and then run execute subtree
> and then jump back to my previous location in Emacs.
> Is there a more programmatic or built-in way?  For example:
> org-babel-execute-block-and-subheadings FOO
> Thanks,
> --Nate

  reply	other threads:[~2021-02-27 13:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-20 19:10 Nathan Neff
2021-02-27 13:18 ` ian martins [this message]
2021-03-01  2:12   ` Nathan Neff
2021-03-01 23:26 ` Ken Mankoff

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:

  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='CAC=rjb4iJPkXjOVAi83jjBrc=4TjEZhr_KrEnYvF_K0GSapHOw@mail.gmail.com' \
    --to=ianxm@jhu.edu \
    --cc=emacs-orgmode@gnu.org \
    --cc=nathan.neff@gmail.com \


* 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


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).