From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id KGlRNnScLV/rDQAA0tVLHw (envelope-from ) for ; Fri, 07 Aug 2020 18:24:52 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id yMFIMnScLV8JdAAA1q6Kng (envelope-from ) for ; Fri, 07 Aug 2020 18:24:52 +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 4514D9403CB for ; Fri, 7 Aug 2020 18:24:52 +0000 (UTC) Received: from localhost ([::1]:49032 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k472w-0000HA-RU for larch@yhetil.org; Fri, 07 Aug 2020 14:24:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33248) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k472M-0000Fg-Uy for emacs-orgmode@gnu.org; Fri, 07 Aug 2020 14:24:14 -0400 Received: from mail-qv1-xf29.google.com ([2607:f8b0:4864:20::f29]:36946) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k472L-0006mN-6z for emacs-orgmode@gnu.org; Fri, 07 Aug 2020 14:24:14 -0400 Received: by mail-qv1-xf29.google.com with SMTP id y11so1183678qvl.4 for ; Fri, 07 Aug 2020 11:24:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=6DbTpd4VY4yuBWLQEzmY5wzzVaHk8wj/u13gXxe2EJg=; b=Lfd6DPAsdfNzIcGB6asX42yiiJgx+EyJEl6PzQS9tJxwM+xkGqV6K8CffkZoPE0/2O LpHrNo22Lt51iuBK6i9u3nYoBlfxzz+OhhlL9x0EGxjmD2pGjDgj04bT7isvrk9Z7565 VE2fzpwQkiKdKTEkTlNqQeeaefso+DlH64lPQXFNY3CmzukMTf05no2VO9DnSBqhEMoG EzQl84rmddKNFaFZd94LX9mg4v41M1TjQchOiMGTF6czs1b55mERU3LWaOROVP4nmAAM Onywk5bVzFIm8NXtTnMLomvb9f9qPuN9sRaTpTaZRRMFZsfNUAS46N9/ej0QZ1dlMHbt tqOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=6DbTpd4VY4yuBWLQEzmY5wzzVaHk8wj/u13gXxe2EJg=; b=aoTyR1hoCA3NIF+ZzrfPXRiTvSYA3agruIQ1XxTyTpfMGao3rJEDxjBdfITE/PdLe4 2CbUYpK1oo25Ck6pUeqxtiBKIOUM1gV2R09bHb0mmUO9mR+0CxwCik42uQMPLvCma1yQ 4ytfUOqZhFNbgmhuDXVmvUa8GrtvoqGjH7AlPXKrXGNz7WYqa73W7nSyomQp128uEpAk fA6yg4ZUVk1rlwze+s0duHI4QW1BQb43pXjvW+eo77LBppLVCMfcZWzh7UvCLHmFi4mU 2I1xa+EsD8TleEhKvHK4Pn6ttGtprKScbM3M54h6YkAvWyODFvSeY6C3wmJPODqHIUxa gpRQ== X-Gm-Message-State: AOAM531XX114m4kdKbSD4RtjoHz9phKUqecMHeWV8+t/XUOPM133Kg3Q 4mkie9CxgeSiBMKqLo+0+GV7BNbf X-Google-Smtp-Source: ABdhPJzQGQDTu41qEryy7pjZHYPcYpu4DG25PwDt5/3fFBd1EY39yiGYeiKEzDxsz+R2SkeMonWM0Q== X-Received: by 2002:ad4:40cb:: with SMTP id x11mr16391679qvp.176.1596824651189; Fri, 07 Aug 2020 11:24:11 -0700 (PDT) Received: from [192.168.1.12] (c-174-63-121-12.hsd1.ma.comcast.net. [174.63.121.12]) by smtp.googlemail.com with ESMTPSA id d203sm7254446qkc.10.2020.08.07.11.24.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 07 Aug 2020 11:24:10 -0700 (PDT) Subject: Re: Can you automatically noweb include? To: "Berry, Charles" References: <3D721ED9-B51F-47D2-B2D4-7017FCA5F95C@health.ucsd.edu> From: William McCoy Message-ID: Date: Fri, 7 Aug 2020 14:24:09 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <3D721ED9-B51F-47D2-B2D4-7017FCA5F95C@health.ucsd.edu> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Received-SPF: pass client-ip=2607:f8b0:4864:20::f29; envelope-from=wdm8588@gmail.com; helo=mail-qv1-xf29.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: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-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: , Cc: org-mode mailing list 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=Lfd6DPAs; 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.71 X-TUID: tPTGOBT3abJQ 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 "", line 1, in 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 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 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 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? >