emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: George Mauer <gmauer@gmail.com>
To: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: Can you automatically noweb include?
Date: Sat, 8 Aug 2020 14:42:45 -0500	[thread overview]
Message-ID: <CA+pajWJFYxdd6yu9QuX=c+46n9zO-efc4XBwehmrNsMi2kXqwg@mail.gmail.com> (raw)
In-Reply-To: <CA+G3_PMJZkkO5TVt6oqQ-qVaQnBsOpzwEX6iaoDL9LPQ39h-9w@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3337 bytes --]

For what its worth, I maintain (well maintain is a big word when I'm also
probably the only person to use it) this fork of xchrishawk/ob-racket:
https://github.com/togakangaroo/ob-racket

It seems to have more features than the wallyqs one supporting :var headers.
I can look at how prologue support works in others and add it, but I also
am surprised that this is up to the plugin authors *at all*. As you pointed
out, that means that it can't possibly support noweb expansion

On Fri, Aug 7, 2020 at 11:47 PM Tom Gillespie <tgbugs@gmail.com> wrote:

> After a bit of investigation, it seems that wallyqs implementation of
> ob-racket does not treat/manage :prologue arguments correctly, which
> is worrying because I would assume that the semantics for how prologue
> works should not be something that could be accidentally broken by
> ob-* implementations (but that is a separate issue). More relevant to
> this thread is that python the prologue works as others have reported,
> but if you include a noweb reference in the prologue it does not get
> expanded. It is quite possible that this should be considered a bug
> since it means that prologues are added only after the main block is
> expanded. This seems incorrect, and I suspect that it is another bug
> related to the one fixed in df5a83637518ad9aa586d49884a6271f11afc592
> (discussion here
>
> https://orgmode.org/list/CA+G3_PNi3uMvBiWgBdKuC3C6VJt1T1j-RKH43LRqYbr+4NS8ZA@mail.gmail.com/
> ).
> The fact that prologue is not expanded means that you can modify what
> code is run by putting it in a prologue and org mode will be none-the
> wiser. The sha1 changes if you set :cache yes, which means that
> something in the execution code is doing something different than in
> the block hashing code. Further investigation required.
>
> * Use the code
> :PROPERTIES:
> :header-args:python: :prologue "<<python-helper>>"
> :END:
>
> #+name: python-helper
> #+begin_src python
> asdf = lambda : 'result'
> #+end_src
>
> #+begin_src python :noweb yes
> return asdf()
> #+end_src
>
> On Fri, Aug 7, 2020 at 9:20 PM Tom Gillespie <tgbugs@gmail.com> wrote:
> >
> > Hah, this is what I get for not reading carefully enough. I wonder if
> > it is possible to stick <<racket-helper>> in the prologue and have it
> > expand.
> >
> > On Fri, Aug 7, 2020 at 9:18 PM Tom Gillespie <tgbugs@gmail.com> wrote:
> > >
> > > I don't see a direct answer to the original question in the thread, so
> > > here is an example of how I do it taken from
> > >
> https://raw.githubusercontent.com/SciCrunch/sparc-curation/master/docs/developer-guide.org
> .
> > > You can ctrl-f for racket-graph-helper to see the relevant blocks. A
> > > reduced version is below. Recall that I use
> > > https://github.com/wallyqs/ob-racket. I use this pattern all over the
> > > place in my org blocks. Best,
> > > Tom
> > >
> > > * Use the code
> > > :cache yes"
> > > #+begin_src racket :lang racket/base :noweb yes
> > > <<racket-helper>>
> > > (helper-function "this should work")
> > > #+end_src
> > >
> > > #+RESULTS:
> > > : this should work hello world
> > >
> > >
> > > * Define the helpers
> > > #+name: racket-helper
> > > #+header: :prologue "#lang racket/base"
> > > #+begin_src racket :lang racket/base
> > > (define (helper-function arg)
> > >   (string-append arg " hello world"))
> > > #+end_src
>

[-- Attachment #2: Type: text/html, Size: 4745 bytes --]

      reply	other threads:[~2020-08-08 19:43 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-05 21:21 Can you automatically noweb include? George Mauer
2020-08-05 22:03 ` Ken Mankoff
2020-08-06 18:12   ` Ken Mankoff
2020-08-07 15:39     ` William McCoy
2020-08-07 16:51       ` Berry, Charles via General discussions about Org-mode.
2020-08-07 18:24         ` William McCoy
2020-08-07 21:18           ` Thomas S. Dye
2020-08-07 21:25             ` Berry, Charles via General discussions about Org-mode.
2020-08-07 22:01               ` William McCoy
2020-08-08  4:15                 ` George Mauer
2020-08-08  4:18 ` Tom Gillespie
2020-08-08  4:20   ` Tom Gillespie
2020-08-08  4:47     ` Tom Gillespie
2020-08-08 19:42       ` George Mauer [this message]

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='CA+pajWJFYxdd6yu9QuX=c+46n9zO-efc4XBwehmrNsMi2kXqwg@mail.gmail.com' \
    --to=gmauer@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /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).