From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 0CPQIl8AL1/IcQAA0tVLHw (envelope-from ) for ; Sat, 08 Aug 2020 19:43:27 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id uAiFHl8AL197YgAAbx9fmQ (envelope-from ) for ; Sat, 08 Aug 2020 19:43:27 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id A9365940704 for ; Sat, 8 Aug 2020 19:43:26 +0000 (UTC) Received: from localhost ([::1]:37090 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k4UkV-0006WL-UB for larch@yhetil.org; Sat, 08 Aug 2020 15:43:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34646) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k4Uk8-0006WD-59 for emacs-orgmode@gnu.org; Sat, 08 Aug 2020 15:43:00 -0400 Received: from mail-oi1-x22a.google.com ([2607:f8b0:4864:20::22a]:35970) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k4Uk5-00061Y-W2 for emacs-orgmode@gnu.org; Sat, 08 Aug 2020 15:42:59 -0400 Received: by mail-oi1-x22a.google.com with SMTP id l204so5267189oib.3 for ; Sat, 08 Aug 2020 12:42:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:reply-to:from:date:message-id :subject:to; bh=pMK7CxbvDbhxcvs/T+3smruu7teU/+FVj9QDyvqvNA4=; b=oDpzRI6NB1CA4hU+qqUkK//yRmmEL+0PK5Twy5fsCQQ/8d1XvcsJqEaa3oUc6KKH9O XKtdROZBnN1mA+LCtYIreiVQfAliU9G8PiLE9Oi4eZlvf6Psbgsfe22IsQDYXpdI0iib WfHVMp/LHnNj0jrxoMHAP6UFmAz/vXSkAi/g9wAqFBc2YU5AahzgNoayeigvPt3dMNqa A79PjMV3ARYxnhQqYpQ+ycdAFwCTVVECoznolNXhr/EKB5HoyC+RRtLOEkqJXo8TbTPX DPl/QYdsivng1Jjy2m6ukgZXmRSdJ21eMRgC9Dqs1L0MVbNaZV4iYyYdrtBKFykyxHTK AmIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:reply-to :from:date:message-id:subject:to; bh=pMK7CxbvDbhxcvs/T+3smruu7teU/+FVj9QDyvqvNA4=; b=OBn7q5OIOL3Wiiol3coeQImkekJIS7XsKTwCU0jYonSG6cwtw4o4Iv61J7a1afWj0C bCWQdk2wSDSpkSvfaz8WbbM2iGJfsWYRo/e06EzoMpGRFGuR6LwvDe23tQnrP4jhZvD5 y03VLGc9wyfa3XcxQt01mkOrzU3HRVGm3JQY++f1zqTG3px+Fy1Kp4R8BAoV+sp2thLz 51e2ZLvmXv7djJOxUXwI5H/p7bw4iIky1/HVenbC90MQHoB5Ju6kZeAbWj+ArTXK5eX8 V99hd2mzhJrDCvvQoDILl4PBbPxJKFTGhlNGi5GzPWINQ+ShRwAVbM2GJPW4N9rpX/po IZ/A== X-Gm-Message-State: AOAM533I/yYPY4DB6Avdq+KyDbq+iJzi4R0juRa17q7b+pXZKVXTL8rT VnZibzzJHqBWEF+fiEg/pLFye0s1XK2gE5jBNQS0iJLsWz0= X-Google-Smtp-Source: ABdhPJzrUFq26t9qWX6Oowr68P7f95lPngPqlu/wZWJtUQHO7TbyDVEtmJ+npnsXd6KKCPNFQxvbz3fTVbAad50LOrY= X-Received: by 2002:a05:6808:7c3:: with SMTP id f3mr15820644oij.153.1596915776202; Sat, 08 Aug 2020 12:42:56 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: George Mauer Date: Sat, 8 Aug 2020 14:42:45 -0500 Message-ID: Subject: Re: Can you automatically noweb include? To: emacs-orgmode Content-Type: multipart/alternative; boundary="00000000000093ae0005ac62ed8b" Received-SPF: pass client-ip=2607:f8b0:4864:20::22a; envelope-from=gmauer@gmail.com; helo=mail-oi1-x22a.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: gmauer@gmail.com Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=oDpzRI6N; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: 0.29 X-TUID: rINfANIxjtly --00000000000093ae0005ac62ed8b Content-Type: text/plain; charset="UTF-8" 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 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 "<>" > :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 wrote: > > > > Hah, this is what I get for not reading carefully enough. I wonder if > > it is possible to stick <> in the prologue and have it > > expand. > > > > On Fri, Aug 7, 2020 at 9:18 PM Tom Gillespie 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 > > > <> > > > (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 > --00000000000093ae0005ac62ed8b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
For what its worth, I maintain (well main= tain is a big word when I'm also probably the only person to use it) th= is fork of xchrishawk/ob-racket:=C2=A0https://github.com/togakangaroo/ob-racket

It seems to have more features than the wallyqs on= e supporting=C2=A0:var headers.
I can look at how prologue suppor= t works in others and add it, but I also am surprised that this is up to th= e 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 tha= t 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.g= mail.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 =3D 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<= br> > 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 t= hread, so
> > here is an example of how I do it taken from
> > = https://raw.githubusercontent.com/SciCrunch/sparc-curation/master/docs/deve= loper-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 p= attern 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)
> >=C2=A0 =C2=A0(string-append arg " hello world"))
> > #+end_src
--00000000000093ae0005ac62ed8b--