* Can you automatically noweb include?
@ 2020-08-05 21:21 George Mauer
2020-08-05 22:03 ` Ken Mankoff
2020-08-08 4:18 ` Tom Gillespie
0 siblings, 2 replies; 14+ messages in thread
From: George Mauer @ 2020-08-05 21:21 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 646 bytes --]
Use case:
I'm using ob-racket <https://github.com/togakangaroo/ob-racket> but this
would apply just as well to a few other workflows I have with python or js.
I would like to write a helper function in a src block and then
automatically have access to it in other src blocks further down the
document. I don't really want a stateful session (nor does ob-racket
support sessions) so I essentially want the equivalent of automatically
including it everywhere so I don't have to type it out all the time (and
have it screw up syntax coloring/indentation).
Is this currently possible? Does anyone have any ideas for how to extend
things so it is?
[-- Attachment #2: Type: text/html, Size: 765 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Can you automatically noweb include?
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-08 4:18 ` Tom Gillespie
1 sibling, 1 reply; 14+ messages in thread
From: Ken Mankoff @ 2020-08-05 22:03 UTC (permalink / raw)
To: gmauer; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 914 bytes --]
What about using :pre or :prologue and setting it at the header or document
level?
Please excuse brevity. Sent from tiny pocket computer with
non-haptic-feedback keyboard.
On Wed, Aug 5, 2020, 14:22 George Mauer <gmauer@gmail.com> wrote:
> Use case:
>
> I'm using ob-racket <https://github.com/togakangaroo/ob-racket> but this
> would apply just as well to a few other workflows I have with python or js.
>
> I would like to write a helper function in a src block and then
> automatically have access to it in other src blocks further down the
> document. I don't really want a stateful session (nor does ob-racket
> support sessions) so I essentially want the equivalent of automatically
> including it everywhere so I don't have to type it out all the time (and
> have it screw up syntax coloring/indentation).
>
> Is this currently possible? Does anyone have any ideas for how to extend
> things so it is?
>
[-- Attachment #2: Type: text/html, Size: 1348 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Can you automatically noweb include?
2020-08-05 22:03 ` Ken Mankoff
@ 2020-08-06 18:12 ` Ken Mankoff
2020-08-07 15:39 ` William McCoy
0 siblings, 1 reply; 14+ messages in thread
From: Ken Mankoff @ 2020-08-06 18:12 UTC (permalink / raw)
To: gmauer; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1225 bytes --]
Actual example:
* Prologue test
:PROPERTIES:
:header-args:python+: :prologue "import numpy as np; import os"
:END:
#+BEGIN_SRC python :results output
print(np.__version__)
#+END_SRC
#+RESULTS:
: 1.18.4
On Wed, Aug 5, 2020 at 3:03 PM Ken Mankoff <mankoff@gmail.com> wrote:
> What about using :pre or :prologue and setting it at the header or
> document level?
>
> Please excuse brevity. Sent from tiny pocket computer with
> non-haptic-feedback keyboard.
>
> On Wed, Aug 5, 2020, 14:22 George Mauer <gmauer@gmail.com> wrote:
>
>> Use case:
>>
>> I'm using ob-racket <https://github.com/togakangaroo/ob-racket> but this
>> would apply just as well to a few other workflows I have with python or js.
>>
>> I would like to write a helper function in a src block and then
>> automatically have access to it in other src blocks further down the
>> document. I don't really want a stateful session (nor does ob-racket
>> support sessions) so I essentially want the equivalent of automatically
>> including it everywhere so I don't have to type it out all the time (and
>> have it screw up syntax coloring/indentation).
>>
>> Is this currently possible? Does anyone have any ideas for how to extend
>> things so it is?
>>
>
[-- Attachment #2: Type: text/html, Size: 2021 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Can you automatically noweb include?
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.
0 siblings, 1 reply; 14+ messages in thread
From: William McCoy @ 2020-08-07 15:39 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1888 bytes --]
This use of :prologue appeared to me to be very useful. But for some
reason when I try it out it does not work for me. I just get a message
that the code block produced no output and that 'np' is not defined.
Just to check, when I put the import statements directly within my code
block it works fine.
I am running: Org mode version 9.3.7 (9.3.7-16-g521d7f-elpa
Any idea what I'm doing wrong?
On 8/6/20 2:12 PM, Ken Mankoff wrote:
> Actual example:
>
>
> * Prologue test
> :PROPERTIES:
> :header-args:python+: :prologue "import numpy as np; import os"
> :END:
>
> #+BEGIN_SRC python :results output
> print(np.__version__)
> #+END_SRC
>
> #+RESULTS:
> : 1.18.4
>
>
>
>
> On Wed, Aug 5, 2020 at 3:03 PM Ken Mankoff <mankoff@gmail.com
> <mailto:mankoff@gmail.com>> wrote:
>
> What about using :pre or :prologue and setting it at the header or
> document level?
>
> Please excuse brevity. Sent from tiny pocket computer with
> non-haptic-feedback keyboard.
>
> On Wed, Aug 5, 2020, 14:22 George Mauer <gmauer@gmail.com
> <mailto:gmauer@gmail.com>> wrote:
>
> Use case:
>
> I'm using ob-racket
> <https://github.com/togakangaroo/ob-racket> but this would
> apply just as well to a few other workflows I have with python
> or js.
>
> I would like to write a helper function in a src block and
> then automatically have access to it in other src blocks
> further down the document. I don't really want a stateful
> session (nor does ob-racket support sessions) so I essentially
> want the equivalent of automatically including it everywhere
> so I don't have to type it out all the time (and have it screw
> up syntax coloring/indentation).
>
> Is this currently possible? Does anyone have any ideas for how
> to extend things so it is?
>
[-- Attachment #2: Type: text/html, Size: 3938 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Can you automatically noweb include?
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
0 siblings, 1 reply; 14+ messages in thread
From: Berry, Charles via General discussions about Org-mode. @ 2020-08-07 16:51 UTC (permalink / raw)
To: William McCoy; +Cc: org-mode mailing list
> On Aug 7, 2020, at 8:39 AM, William McCoy <wdm8588@gmail.com> wrote:
>
> This use of :prologue appeared to me to be very useful. But for some reason when I try it out it does not work for me. I just get a message that the code block produced no output and that 'np' is not defined. Just to check, when I put the import statements directly within my code block it works fine.
>
> I am running: Org mode version 9.3.7 (9.3.7-16-g521d7f-elpa
>
> Any idea what I'm doing wrong?
>
>
It is sometimes useful to use C-c C-v C-i to see what header args org has detected for a source block. Misspelled words sometimes wreak havoc and invisible characters can cause real pain.
Also, it helps to use C-c C-v C-v to to see the expanded code block. When I do this with Kens' ECM, I get
import numpy as np; import os
print(np.__version__)
in the preview buffer.
HTH,
Chuck
> On 8/6/20 2:12 PM, Ken Mankoff wrote:
>> Actual example:
>>
>>
>> * Prologue test
>> :PROPERTIES:
>> :header-args:python+: :prologue "import numpy as np; import os"
>> :END:
>>
>> #+BEGIN_SRC python :results output
>> print(np.__version__)
>> #+END_SRC
>>
>> #+RESULTS:
>> : 1.18.4
>>
>>
>>
>>
>> On Wed, Aug 5, 2020 at 3:03 PM Ken Mankoff <mankoff@gmail.com> wrote:
>> What about using :pre or :prologue and setting it at the header or document level?
>>
>> Please excuse brevity. Sent from tiny pocket computer with non-haptic-feedback keyboard.
>>
>> On Wed, Aug 5, 2020, 14:22 George Mauer <gmauer@gmail.com> wrote:
>> Use case:
>>
>> I'm using ob-racket but this would apply just as well to a few other workflows I have with python or js.
>>
>> I would like to write a helper function in a src block and then automatically have access to it in other src blocks further down the document. I don't really want a stateful session (nor does ob-racket support sessions) so I essentially want the equivalent of automatically including it everywhere so I don't have to type it out all the time (and have it screw up syntax coloring/indentation).
>>
>> Is this currently possible? Does anyone have any ideas for how to extend things so it is?
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Can you automatically noweb include?
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
0 siblings, 1 reply; 14+ messages in thread
From: William McCoy @ 2020-08-07 18:24 UTC (permalink / raw)
To: Berry, Charles; +Cc: org-mode mailing list
Chuck,
Thanks very much for your response. I didn't know about those options.
When I use C-c C-v C-i, I get the following:
Lang: python
Properties:
:header-args nil
:header-args:python nil
Header Arguments:
:cache no
:exports code
:hlines no
:noweb no
:results output replace
:session none
:tangle no
And C-c C-v C-v, shows that the import statements in the header do not
get expanded into the code block.
So I am obviously doing something wrong. There appear to be no typos or
misspellings and the org file containing the coded is exactly this:
* Test of prologue header
:PROPERTIES:
:header-args:python+: :prologue "import numpy as np; import os"
:END:
#+BEGIN_SRC python :results output
print(np.__version__)
#+END_SRC
#+RESULTS:
My init file has no org babel header arguments defined.
I am using C-c C-v C-b or C-c C-v C-s to evaluate and I get
"Code block produced no output." in the mini-buffer.
If I use C-c C-c directly on the code block itself I get:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'np' is not defined
Is there something else I need to do to get babel to recognize the
header-args?
Thanks
On 8/7/20 12:51 PM, Berry, Charles wrote:
>
>> On Aug 7, 2020, at 8:39 AM, William McCoy <wdm8588@gmail.com> wrote:
>>
>> This use of :prologue appeared to me to be very useful. But for some reason when I try it out it does not work for me. I just get a message that the code block produced no output and that 'np' is not defined. Just to check, when I put the import statements directly within my code block it works fine.
>>
>> I am running: Org mode version 9.3.7 (9.3.7-16-g521d7f-elpa
>>
>> Any idea what I'm doing wrong?
>>
>>
> It is sometimes useful to use C-c C-v C-i to see what header args org has detected for a source block. Misspelled words sometimes wreak havoc and invisible characters can cause real pain.
>
>
> Also, it helps to use C-c C-v C-v to to see the expanded code block. When I do this with Kens' ECM, I get
>
> import numpy as np; import os
> print(np.__version__)
>
> in the preview buffer.
>
> HTH,
>
> Chuck
>
>
>> On 8/6/20 2:12 PM, Ken Mankoff wrote:
>>> Actual example:
>>>
>>>
>>> * Prologue test
>>> :PROPERTIES:
>>> :header-args:python+: :prologue "import numpy as np; import os"
>>> :END:
>>>
>>> #+BEGIN_SRC python :results output
>>> print(np.__version__)
>>> #+END_SRC
>>>
>>> #+RESULTS:
>>> : 1.18.4
>>>
>>>
>>>
>>>
>>> On Wed, Aug 5, 2020 at 3:03 PM Ken Mankoff <mankoff@gmail.com> wrote:
>>> What about using :pre or :prologue and setting it at the header or document level?
>>>
>>> Please excuse brevity. Sent from tiny pocket computer with non-haptic-feedback keyboard.
>>>
>>> On Wed, Aug 5, 2020, 14:22 George Mauer <gmauer@gmail.com> wrote:
>>> Use case:
>>>
>>> I'm using ob-racket but this would apply just as well to a few other workflows I have with python or js.
>>>
>>> I would like to write a helper function in a src block and then automatically have access to it in other src blocks further down the document. I don't really want a stateful session (nor does ob-racket support sessions) so I essentially want the equivalent of automatically including it everywhere so I don't have to type it out all the time (and have it screw up syntax coloring/indentation).
>>>
>>> Is this currently possible? Does anyone have any ideas for how to extend things so it is?
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Can you automatically noweb include?
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.
0 siblings, 1 reply; 14+ messages in thread
From: Thomas S. Dye @ 2020-08-07 21:18 UTC (permalink / raw)
To: emacs-orgmode; +Cc: Berry, Charles
It works here if you remove the blank line between the headline
and the PROPERTIES block.
William McCoy writes:
> Chuck,
>
> Thanks very much for your response. I didn't know about those
> options. When I
> use C-c C-v C-i, I get the following:
>
> Lang: python
> Properties:
> :header-args nil
> :header-args:python nil
> Header Arguments:
> :cache no
> :exports code
> :hlines no
> :noweb no
> :results output replace
> :session none
> :tangle no
>
> And C-c C-v C-v, shows that the import statements in the header
> do not get
> expanded into the code block.
>
> So I am obviously doing something wrong. There appear to be no
> typos or
> misspellings and the org file containing the coded is exactly
> this:
>
> * Test of prologue header
>
> :PROPERTIES:
> :header-args:python+: :prologue "import numpy as np; import os"
> :END:
>
> #+BEGIN_SRC python :results output
> print(np.__version__)
> #+END_SRC
>
> #+RESULTS:
>
>
> My init file has no org babel header arguments defined.
>
> I am using C-c C-v C-b or C-c C-v C-s to evaluate and I get
>
> "Code block produced no output." in the mini-buffer.
>
>
> If I use C-c C-c directly on the code block itself I get:
>
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> NameError: name 'np' is not defined
>
> Is there something else I need to do to get babel to recognize
> the header-args?
>
> Thanks
>
>
> On 8/7/20 12:51 PM, Berry, Charles wrote:
>>
>>> On Aug 7, 2020, at 8:39 AM, William McCoy <wdm8588@gmail.com>
>>> wrote:
>>>
>>> This use of :prologue appeared to me to be very useful. But
>>> for some reason when I try it out it does not work for me. I
>>> just get a message that the code block produced no output and
>>> that 'np' is not defined. Just to check, when I put the
>>> import statements directly within my code block it works fine.
>>>
>>> I am running: Org mode version 9.3.7 (9.3.7-16-g521d7f-elpa
>>>
>>> Any idea what I'm doing wrong?
>>>
>>>
>> It is sometimes useful to use C-c C-v C-i to see what header
>> args org has detected for a source block. Misspelled words
>> sometimes wreak havoc and invisible characters can cause real
>> pain.
>>
>>
>> Also, it helps to use C-c C-v C-v to to see the expanded code
>> block. When I do this with Kens' ECM, I get
>>
>> import numpy as np; import os
>> print(np.__version__)
>>
>> in the preview buffer.
>>
>> HTH,
>>
>> Chuck
>>
>>
>>> On 8/6/20 2:12 PM, Ken Mankoff wrote:
>>>> Actual example:
>>>>
>>>>
>>>> * Prologue test
>>>> :PROPERTIES:
>>>> :header-args:python+: :prologue "import numpy as np; import
>>>> os"
>>>> :END:
>>>>
>>>> #+BEGIN_SRC python :results output
>>>> print(np.__version__)
>>>> #+END_SRC
>>>>
>>>> #+RESULTS:
>>>> : 1.18.4
>>>>
>>>>
>>>>
>>>>
>>>> On Wed, Aug 5, 2020 at 3:03 PM Ken Mankoff
>>>> <mankoff@gmail.com> wrote:
>>>> What about using :pre or :prologue and setting it at the
>>>> header or document level?
>>>>
>>>> Please excuse brevity. Sent from tiny pocket computer with
>>>> non-haptic-feedback keyboard.
>>>>
>>>> On Wed, Aug 5, 2020, 14:22 George Mauer <gmauer@gmail.com>
>>>> wrote:
>>>> Use case:
>>>>
>>>> I'm using ob-racket but this would apply just as well to a
>>>> few other workflows I have with python or js.
>>>>
>>>> I would like to write a helper function in a src block and
>>>> then automatically have access to it in other src blocks
>>>> further down the document. I don't really want a stateful
>>>> session (nor does ob-racket support sessions) so I
>>>> essentially want the equivalent of automatically including it
>>>> everywhere so I don't have to type it out all the time (and
>>>> have it screw up syntax coloring/indentation).
>>>>
>>>> Is this currently possible? Does anyone have any ideas for
>>>> how to extend things so it is?
>>
--
Thomas S. Dye
https://tsdye.online/tsdye
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Can you automatically noweb include?
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
0 siblings, 1 reply; 14+ messages in thread
From: Berry, Charles via General discussions about Org-mode. @ 2020-08-07 21:25 UTC (permalink / raw)
To: Thomas S. Dye; +Cc: org-mode mailing list, William McCoy
Good catch. Also it works if you put the property block at the very beginning of the file.
This sometimes helps:
M-x org-lint RET
which in this case reports "Incorrect contents for PROPERTIES drawer"
which is a bit cryptic IMO, but does point to any issue with the property.
HTH,
Chuck
> On Aug 7, 2020, at 2:18 PM, Thomas S. Dye <tsd@tsdye.online> wrote:
>
> It works here if you remove the blank line between the headline and the PROPERTIES block.
>
> William McCoy writes:
>
>> Chuck,
>>
>> Thanks very much for your response. I didn't know about those options. When I
>> use C-c C-v C-i, I get the following:
>>
>> Lang: python
>> Properties:
>> :header-args nil
>> :header-args:python nil
>> Header Arguments:
>> :cache no
>> :exports code
>> :hlines no
>> :noweb no
>> :results output replace
>> :session none
>> :tangle no
>>
>> And C-c C-v C-v, shows that the import statements in the header do not get
>> expanded into the code block.
>>
>> So I am obviously doing something wrong. There appear to be no typos or
>> misspellings and the org file containing the coded is exactly this:
>>
>> * Test of prologue header
>>
>> :PROPERTIES:
>> :header-args:python+: :prologue "import numpy as np; import os"
>> :END:
>>
>> #+BEGIN_SRC python :results output
>> print(np.__version__)
>> #+END_SRC
>>
>> #+RESULTS:
>>
>>
>> My init file has no org babel header arguments defined.
>>
>> I am using C-c C-v C-b or C-c C-v C-s to evaluate and I get
>>
>> "Code block produced no output." in the mini-buffer.
>>
>>
>> If I use C-c C-c directly on the code block itself I get:
>>
>> Traceback (most recent call last):
>> File "<stdin>", line 1, in <module>
>> NameError: name 'np' is not defined
>>
>> Is there something else I need to do to get babel to recognize the header-args?
>>
>> Thanks
>>
>>
>> On 8/7/20 12:51 PM, Berry, Charles wrote:
>>>
>>>> On Aug 7, 2020, at 8:39 AM, William McCoy <wdm8588@gmail.com> wrote:
>>>>
>>>> This use of :prologue appeared to me to be very useful. But for some reason when I try it out it does not work for me. I just get a message that the code block produced no output and that 'np' is not defined. Just to check, when I put the import statements directly within my code block it works fine.
>>>>
>>>> I am running: Org mode version 9.3.7 (9.3.7-16-g521d7f-elpa
>>>>
>>>> Any idea what I'm doing wrong?
>>>>
>>>>
>>> It is sometimes useful to use C-c C-v C-i to see what header args org has detected for a source block. Misspelled words sometimes wreak havoc and invisible characters can cause real pain.
>>>
>>>
>>> Also, it helps to use C-c C-v C-v to to see the expanded code block. When I do this with Kens' ECM, I get
>>>
>>> import numpy as np; import os
>>> print(np.__version__)
>>>
>>> in the preview buffer.
>>>
>>> HTH,
>>>
>>> Chuck
>>>
>>>
>>>> On 8/6/20 2:12 PM, Ken Mankoff wrote:
>>>>> Actual example:
>>>>>
>>>>>
>>>>> * Prologue test
>>>>> :PROPERTIES:
>>>>> :header-args:python+: :prologue "import numpy as np; import os"
>>>>> :END:
>>>>>
>>>>> #+BEGIN_SRC python :results output
>>>>> print(np.__version__)
>>>>> #+END_SRC
>>>>>
>>>>> #+RESULTS:
>>>>> : 1.18.4
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Wed, Aug 5, 2020 at 3:03 PM Ken Mankoff <mankoff@gmail.com> wrote:
>>>>> What about using :pre or :prologue and setting it at the header or document level?
>>>>>
>>>>> Please excuse brevity. Sent from tiny pocket computer with non-haptic-feedback keyboard.
>>>>>
>>>>> On Wed, Aug 5, 2020, 14:22 George Mauer <gmauer@gmail.com> wrote:
>>>>> Use case:
>>>>>
>>>>> I'm using ob-racket but this would apply just as well to a few other workflows I have with python or js.
>>>>>
>>>>> I would like to write a helper function in a src block and then automatically have access to it in other src blocks further down the document. I don't really want a stateful session (nor does ob-racket support sessions) so I essentially want the equivalent of automatically including it everywhere so I don't have to type it out all the time (and have it screw up syntax coloring/indentation).
>>>>>
>>>>> Is this currently possible? Does anyone have any ideas for how to extend things so it is?
>>>
>
>
> --
> Thomas S. Dye
> https://tsdye.online/tsdye
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Can you automatically noweb include?
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
0 siblings, 1 reply; 14+ messages in thread
From: William McCoy @ 2020-08-07 22:01 UTC (permalink / raw)
To: Berry, Charles, Thomas S. Dye; +Cc: org-mode mailing list
Yes, of course, that was it! I ran into that issue a few months ago and
then I forgot about again!
Thanks both for your help!
Bill
On 8/7/20 5:25 PM, Berry, Charles wrote:
> Good catch. Also it works if you put the property block at the very beginning of the file.
>
> This sometimes helps:
>
> M-x org-lint RET
>
> which in this case reports "Incorrect contents for PROPERTIES drawer"
>
> which is a bit cryptic IMO, but does point to any issue with the property.
>
> HTH,
>
> Chuck
>
>> On Aug 7, 2020, at 2:18 PM, Thomas S. Dye <tsd@tsdye.online> wrote:
>>
>> It works here if you remove the blank line between the headline and the PROPERTIES block.
>>
>> William McCoy writes:
>>
>>> Chuck,
>>>
>>> Thanks very much for your response. I didn't know about those options. When I
>>> use C-c C-v C-i, I get the following:
>>>
>>> Lang: python
>>> Properties:
>>> :header-args nil
>>> :header-args:python nil
>>> Header Arguments:
>>> :cache no
>>> :exports code
>>> :hlines no
>>> :noweb no
>>> :results output replace
>>> :session none
>>> :tangle no
>>>
>>> And C-c C-v C-v, shows that the import statements in the header do not get
>>> expanded into the code block.
>>>
>>> So I am obviously doing something wrong. There appear to be no typos or
>>> misspellings and the org file containing the coded is exactly this:
>>>
>>> * Test of prologue header
>>>
>>> :PROPERTIES:
>>> :header-args:python+: :prologue "import numpy as np; import os"
>>> :END:
>>>
>>> #+BEGIN_SRC python :results output
>>> print(np.__version__)
>>> #+END_SRC
>>>
>>> #+RESULTS:
>>>
>>>
>>> My init file has no org babel header arguments defined.
>>>
>>> I am using C-c C-v C-b or C-c C-v C-s to evaluate and I get
>>>
>>> "Code block produced no output." in the mini-buffer.
>>>
>>>
>>> If I use C-c C-c directly on the code block itself I get:
>>>
>>> Traceback (most recent call last):
>>> File "<stdin>", line 1, in <module>
>>> NameError: name 'np' is not defined
>>>
>>> Is there something else I need to do to get babel to recognize the header-args?
>>>
>>> Thanks
>>>
>>>
>>> On 8/7/20 12:51 PM, Berry, Charles wrote:
>>>>> On Aug 7, 2020, at 8:39 AM, William McCoy <wdm8588@gmail.com> wrote:
>>>>>
>>>>> This use of :prologue appeared to me to be very useful. But for some reason when I try it out it does not work for me. I just get a message that the code block produced no output and that 'np' is not defined. Just to check, when I put the import statements directly within my code block it works fine.
>>>>>
>>>>> I am running: Org mode version 9.3.7 (9.3.7-16-g521d7f-elpa
>>>>>
>>>>> Any idea what I'm doing wrong?
>>>>>
>>>>>
>>>> It is sometimes useful to use C-c C-v C-i to see what header args org has detected for a source block. Misspelled words sometimes wreak havoc and invisible characters can cause real pain.
>>>>
>>>>
>>>> Also, it helps to use C-c C-v C-v to to see the expanded code block. When I do this with Kens' ECM, I get
>>>>
>>>> import numpy as np; import os
>>>> print(np.__version__)
>>>>
>>>> in the preview buffer.
>>>>
>>>> HTH,
>>>>
>>>> Chuck
>>>>
>>>>
>>>>> On 8/6/20 2:12 PM, Ken Mankoff wrote:
>>>>>> Actual example:
>>>>>>
>>>>>>
>>>>>> * Prologue test
>>>>>> :PROPERTIES:
>>>>>> :header-args:python+: :prologue "import numpy as np; import os"
>>>>>> :END:
>>>>>>
>>>>>> #+BEGIN_SRC python :results output
>>>>>> print(np.__version__)
>>>>>> #+END_SRC
>>>>>>
>>>>>> #+RESULTS:
>>>>>> : 1.18.4
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Wed, Aug 5, 2020 at 3:03 PM Ken Mankoff <mankoff@gmail.com> wrote:
>>>>>> What about using :pre or :prologue and setting it at the header or document level?
>>>>>>
>>>>>> Please excuse brevity. Sent from tiny pocket computer with non-haptic-feedback keyboard.
>>>>>>
>>>>>> On Wed, Aug 5, 2020, 14:22 George Mauer <gmauer@gmail.com> wrote:
>>>>>> Use case:
>>>>>>
>>>>>> I'm using ob-racket but this would apply just as well to a few other workflows I have with python or js.
>>>>>>
>>>>>> I would like to write a helper function in a src block and then automatically have access to it in other src blocks further down the document. I don't really want a stateful session (nor does ob-racket support sessions) so I essentially want the equivalent of automatically including it everywhere so I don't have to type it out all the time (and have it screw up syntax coloring/indentation).
>>>>>>
>>>>>> Is this currently possible? Does anyone have any ideas for how to extend things so it is?
>>
>> --
>> Thomas S. Dye
>> https://tsdye.online/tsdye
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Can you automatically noweb include?
2020-08-07 22:01 ` William McCoy
@ 2020-08-08 4:15 ` George Mauer
0 siblings, 0 replies; 14+ messages in thread
From: George Mauer @ 2020-08-08 4:15 UTC (permalink / raw)
To: org-mode mailing list
[-- Attachment #1: Type: text/plain, Size: 5140 bytes --]
Is there a straightforward way to have a multiline prologue? Or maybe use
the body of named block as prologue?
On Fri, Aug 7, 2020 at 5:02 PM William McCoy <wdm8588@gmail.com> wrote:
> Yes, of course, that was it! I ran into that issue a few months ago and
> then I forgot about again!
>
> Thanks both for your help!
>
> Bill
>
> On 8/7/20 5:25 PM, Berry, Charles wrote:
> > Good catch. Also it works if you put the property block at the very
> beginning of the file.
> >
> > This sometimes helps:
> >
> > M-x org-lint RET
> >
> > which in this case reports "Incorrect contents for PROPERTIES drawer"
> >
> > which is a bit cryptic IMO, but does point to any issue with the
> property.
> >
> > HTH,
> >
> > Chuck
> >
> >> On Aug 7, 2020, at 2:18 PM, Thomas S. Dye <tsd@tsdye.online> wrote:
> >>
> >> It works here if you remove the blank line between the headline and the
> PROPERTIES block.
> >>
> >> William McCoy writes:
> >>
> >>> Chuck,
> >>>
> >>> Thanks very much for your response. I didn't know about those
> options. When I
> >>> use C-c C-v C-i, I get the following:
> >>>
> >>> Lang: python
> >>> Properties:
> >>> :header-args nil
> >>> :header-args:python nil
> >>> Header Arguments:
> >>> :cache no
> >>> :exports code
> >>> :hlines no
> >>> :noweb no
> >>> :results output replace
> >>> :session none
> >>> :tangle no
> >>>
> >>> And C-c C-v C-v, shows that the import statements in the header do not
> get
> >>> expanded into the code block.
> >>>
> >>> So I am obviously doing something wrong. There appear to be no typos
> or
> >>> misspellings and the org file containing the coded is exactly this:
> >>>
> >>> * Test of prologue header
> >>>
> >>> :PROPERTIES:
> >>> :header-args:python+: :prologue "import numpy as np; import os"
> >>> :END:
> >>>
> >>> #+BEGIN_SRC python :results output
> >>> print(np.__version__)
> >>> #+END_SRC
> >>>
> >>> #+RESULTS:
> >>>
> >>>
> >>> My init file has no org babel header arguments defined.
> >>>
> >>> I am using C-c C-v C-b or C-c C-v C-s to evaluate and I get
> >>>
> >>> "Code block produced no output." in the mini-buffer.
> >>>
> >>>
> >>> If I use C-c C-c directly on the code block itself I get:
> >>>
> >>> Traceback (most recent call last):
> >>> File "<stdin>", line 1, in <module>
> >>> NameError: name 'np' is not defined
> >>>
> >>> Is there something else I need to do to get babel to recognize the
> header-args?
> >>>
> >>> Thanks
> >>>
> >>>
> >>> On 8/7/20 12:51 PM, Berry, Charles wrote:
> >>>>> On Aug 7, 2020, at 8:39 AM, William McCoy <wdm8588@gmail.com> wrote:
> >>>>>
> >>>>> This use of :prologue appeared to me to be very useful. But for
> some reason when I try it out it does not work for me. I just get a
> message that the code block produced no output and that 'np' is not
> defined. Just to check, when I put the import statements directly within
> my code block it works fine.
> >>>>>
> >>>>> I am running: Org mode version 9.3.7 (9.3.7-16-g521d7f-elpa
> >>>>>
> >>>>> Any idea what I'm doing wrong?
> >>>>>
> >>>>>
> >>>> It is sometimes useful to use C-c C-v C-i to see what header args org
> has detected for a source block. Misspelled words sometimes wreak havoc and
> invisible characters can cause real pain.
> >>>>
> >>>>
> >>>> Also, it helps to use C-c C-v C-v to to see the expanded code block.
> When I do this with Kens' ECM, I get
> >>>>
> >>>> import numpy as np; import os
> >>>> print(np.__version__)
> >>>>
> >>>> in the preview buffer.
> >>>>
> >>>> HTH,
> >>>>
> >>>> Chuck
> >>>>
> >>>>
> >>>>> On 8/6/20 2:12 PM, Ken Mankoff wrote:
> >>>>>> Actual example:
> >>>>>>
> >>>>>>
> >>>>>> * Prologue test
> >>>>>> :PROPERTIES:
> >>>>>> :header-args:python+: :prologue "import numpy as np; import os"
> >>>>>> :END:
> >>>>>>
> >>>>>> #+BEGIN_SRC python :results output
> >>>>>> print(np.__version__)
> >>>>>> #+END_SRC
> >>>>>>
> >>>>>> #+RESULTS:
> >>>>>> : 1.18.4
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>> On Wed, Aug 5, 2020 at 3:03 PM Ken Mankoff <mankoff@gmail.com>
> wrote:
> >>>>>> What about using :pre or :prologue and setting it at the header or
> document level?
> >>>>>>
> >>>>>> Please excuse brevity. Sent from tiny pocket computer with
> non-haptic-feedback keyboard.
> >>>>>>
> >>>>>> On Wed, Aug 5, 2020, 14:22 George Mauer <gmauer@gmail.com> wrote:
> >>>>>> Use case:
> >>>>>>
> >>>>>> I'm using ob-racket but this would apply just as well to a few
> other workflows I have with python or js.
> >>>>>>
> >>>>>> I would like to write a helper function in a src block and then
> automatically have access to it in other src blocks further down the
> document. I don't really want a stateful session (nor does ob-racket
> support sessions) so I essentially want the equivalent of automatically
> including it everywhere so I don't have to type it out all the time (and
> have it screw up syntax coloring/indentation).
> >>>>>>
> >>>>>> Is this currently possible? Does anyone have any ideas for how to
> extend things so it is?
> >>
> >> --
> >> Thomas S. Dye
> >> https://tsdye.online/tsdye
> >
>
>
>
[-- Attachment #2: Type: text/html, Size: 7807 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Can you automatically noweb include?
2020-08-05 21:21 Can you automatically noweb include? George Mauer
2020-08-05 22:03 ` Ken Mankoff
@ 2020-08-08 4:18 ` Tom Gillespie
2020-08-08 4:20 ` Tom Gillespie
1 sibling, 1 reply; 14+ messages in thread
From: Tom Gillespie @ 2020-08-08 4:18 UTC (permalink / raw)
To: gmauer; +Cc: emacs-orgmode
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
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Can you automatically noweb include?
2020-08-08 4:18 ` Tom Gillespie
@ 2020-08-08 4:20 ` Tom Gillespie
2020-08-08 4:47 ` Tom Gillespie
0 siblings, 1 reply; 14+ messages in thread
From: Tom Gillespie @ 2020-08-08 4:20 UTC (permalink / raw)
To: gmauer; +Cc: emacs-orgmode
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
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Can you automatically noweb include?
2020-08-08 4:20 ` Tom Gillespie
@ 2020-08-08 4:47 ` Tom Gillespie
2020-08-08 19:42 ` George Mauer
0 siblings, 1 reply; 14+ messages in thread
From: Tom Gillespie @ 2020-08-08 4:47 UTC (permalink / raw)
To: gmauer; +Cc: emacs-orgmode
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
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Can you automatically noweb include?
2020-08-08 4:47 ` Tom Gillespie
@ 2020-08-08 19:42 ` George Mauer
0 siblings, 0 replies; 14+ messages in thread
From: George Mauer @ 2020-08-08 19:42 UTC (permalink / raw)
To: emacs-orgmode
[-- 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 --]
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2020-08-08 19:43 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.