all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: George Mauer <gmauer@gmail.com>
To: org-mode mailing list <emacs-orgmode@gnu.org>
Subject: Re: Can you automatically noweb include?
Date: Fri, 7 Aug 2020 23:15:44 -0500	[thread overview]
Message-ID: <CA+pajWLe=fAgULKjbaVxbVcmG_N4JHtb+0EcWfAsP5+n5t_aHw@mail.gmail.com> (raw)
In-Reply-To: <f0af72ef-426d-426d-6fbf-71b3ad2fa4c4@gmail.com>

[-- 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 --]

  reply	other threads:[~2020-08-08  4:16 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 [this message]
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

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CA+pajWLe=fAgULKjbaVxbVcmG_N4JHtb+0EcWfAsP5+n5t_aHw@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 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.