From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id eLfxKQWCMWS+GgEASxT56A (envelope-from ) for ; Sat, 08 Apr 2023 17:02:29 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id yBQJKQWCMWRx5AAAG6o9tA (envelope-from ) for ; Sat, 08 Apr 2023 17:02:29 +0200 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 497BF125A5 for ; Sat, 8 Apr 2023 17:02:29 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1plA4C-0001Dn-L5; Sat, 08 Apr 2023 11:01:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1plA4B-0001DW-Aa for emacs-orgmode@gnu.org; Sat, 08 Apr 2023 11:01:23 -0400 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1plA49-00039y-Mi for emacs-orgmode@gnu.org; Sat, 08 Apr 2023 11:01:23 -0400 Received: by mail-pj1-x102c.google.com with SMTP id c10-20020a17090abf0a00b0023d1bbd9f9eso3665633pjs.0 for ; Sat, 08 Apr 2023 08:01:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680966079; h=mime-version:message-id:date:in-reply-to:subject:cc:to:from :user-agent:references:from:to:cc:subject:date:message-id:reply-to; bh=76ces2tYhRn/W+4yIj4GgcIniH9gCMoer/VLU8xQjAA=; b=UmjAAuC0sBs/flJH5qLxMT9dClyx7D5lelYLXslOobmo1Ij8RHZKJ7/7xo10c5YdVn 23KymEqrtzuZztEKMazX5cQzvkY79s2S9K03b8QY3MxcBkAZfvZqX9i5Qt/xBAr5QeNr AltFv0eGOdkIeaEN+XX5pJXY5Q1mNB5RfE3DSVP5oyBbXgS4HDj+F2OmL3V+TfhIT0D/ DlcC2MVElXTXZAk33QB15bbr8A/v9COQxBsGWquue82VOPEeweE4yXQUCw/t0ZiJoNQ/ XzHT4S5OrHcwz7H8Le5iArPOtecFnBUT3X9S/Q3tGdeTf/HxcfwhAJoh4EVL9dPvaU8m YOlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680966079; h=mime-version:message-id:date:in-reply-to:subject:cc:to:from :user-agent:references:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=76ces2tYhRn/W+4yIj4GgcIniH9gCMoer/VLU8xQjAA=; b=MY11I++Lsn85avfv5PfMJDdUZI7LQiUxxaw14j924xFKF0GS724kOdHG8qfXQEG56a Mzh0uGXRPMQ/nc6IrqPA7xBtWac2YjVMxzmOw2M1FCennI+58Ce2o2QXs7/H+DostaXU 32kZUBY9njqQUmr2WhYqg4JvL4dQt6fVel8Flc31zX/rz09R25iixZiHEcXVg8r207Cg Co+Rr8PZWYguvQ9F0zFU8y3WJRoGaW4CdcqkXS9iHcRaEEr2GoMoOK7ZktFQrG3Gjg8/ MwG05B0wtYNRw4mFACEtF5qbUDQhiv7b1OEiiRt5Wv7rF2naN/TTlCbU4ZZj0C9ye/eF UXCQ== X-Gm-Message-State: AAQBX9d6BVL1bAlDL/O3gnsqzViMh9jNrETmCZWbR9buwXCqNcPPmecs Ieb8JevDUjJzeQkL0OQw87hFQtAqAsM= X-Google-Smtp-Source: AKy350blhdqNcme1EoEeoyfEXljcSfqUC3mkx/st4qhjdIlWOvsoDD0kerklZXN2atOLxCkajavdwg== X-Received: by 2002:a17:902:e547:b0:19e:416e:abf5 with SMTP id n7-20020a170902e54700b0019e416eabf5mr13986508plf.34.1680966079353; Sat, 08 Apr 2023 08:01:19 -0700 (PDT) Received: from t480 (97-113-138-203.tukw.qwest.net. [97.113.138.203]) by smtp.gmail.com with ESMTPSA id g23-20020a1709029f9700b001a24cded097sm4653692plq.236.2023.04.08.08.01.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Apr 2023 08:01:18 -0700 (PDT) References: <87ilfwpbfm.fsf@t480.home> <87h6tqk1hg.fsf@localhost> User-agent: mu4e 1.8.13; emacs 27.1 From: Ken Mankoff To: Ihor Radchenko Cc: Org-mode Subject: Re: [O] Injecting properties with noweb In-reply-to: <87h6tqk1hg.fsf@localhost> Date: Sat, 08 Apr 2023 08:01:17 -0700 Message-ID: <87355a2zb6.fsf@t480.home> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=mankoff@gmail.com; helo=mail-pj1-x102c.google.com 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, 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.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1680966149; a=rsa-sha256; cv=none; b=Z5yJLSn8TixzwDn3Ngbzcnszk4xzENj/O5UYgecVRupTh1vfnXtByiBGBxqDgjPnAQbHZN cqiHc4JFGt1eoYgC16fWO54XSVnahZIjiuJWriLcHQu9WPzx9zVzHXg8M2oJx/M6jev5g/ BOQ6RffW1R6UnfE1tJ2K9qjVHToPmQ8Kd+y7OWWvM6s6P+eNy7lxDDOeNAe8Vmr4DIFm55 GUcvItULGkDytqsTzn36eEwiFr6ZyL8i7+tLTeTTurM3epVCitfCEPVADrxYWFswhk4r02 4Q/Rok/PQFT4dynSNnf9b2s1lDVBgXmWNDlou82vy2JyqorwXoqsmh56+jYwnQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=UmjAAuC0; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1680966149; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=76ces2tYhRn/W+4yIj4GgcIniH9gCMoer/VLU8xQjAA=; b=NwvJELlCHSH9XP4fEPH0kl32GE04UKznEVZSV0eSIOaRRHv8EtjUHkXFYXGSm5qar4kK7h NfTxRM9IGJXtDyJIicrRMD0ZloOSFJCRglhX8BffUM7dvUUYQSPCmmoqSEVm18NOa9TXRc XJVmdjr3wF4r+1urL+NWxh8cJoilCeGt+VtazR/P9n/jLacbgwOtMYyCV83uPUwfCJ1ZWG F16FGF2y2J2Kwct1uf0ZUyhsHPu356jRKMOzxBgZ+2l7tif3RwOD3SGh1sKzWGDJxCrTV/ dAWDZNuebB2ucCmllGdnWEqDpe1Uoa8oysuSukRAoMDOvwQdp3EPp5mE4rIcbQ== X-Migadu-Spam-Score: -6.46 X-Migadu-Scanner: scn1.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=UmjAAuC0; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Spam-Score: -6.46 X-Migadu-Queue-Id: 497BF125A5 X-TUID: 5cEAElwU1cYI Hi Ihor, I had posted this in another thread, but repeat it here for anyone interested. I think it is a similar end result to what you posted, but skips the =identity= step. The examples below show (1) setting a bash environment variable in screen, or (2) printing from a Python prompt after sshing to a remote computer. It is language agnostic. Because it uses PROPERTIES and not :var, it also lets me work in Org Column View mode. * Header :PROPERTIES: :foo: 42 :END: #+NAME: ex1-screen-bash #+BEGIN_SRC screen export foo="<>" #+END_SRC #+NAME: ex2-ssh-python #+BEGIN_SRC bash ssh somewhere python print("<>") #+END_SRC #+CALL: ex2-ssh-python() #+RESULTS: : foo The relevant section from my library-of-babel is: * Properties into header args :PROPERTIES: :hellomessage: hello :END: https://emacs.stackexchange.com/questions/41922/ #+NAME: get_property #+BEGIN_SRC emacs-lisp :var prop_name="" :results silent (org-with-point-at org-babel-current-src-block-location (org-entry-get nil prop_name t)) #+END_SRC ** Example Usage *** Header arg #+HEADER: :var prop_message=(org-entry-get nil "hellomessage" t) #+BEGIN_SRC emacs-lisp (message prop_message) #+END_SRC #+RESULTS: : hello *** Noweb #+BEGIN_SRC emacs-lisp :noweb yes (message "<>") #+END_SRC #+RESULTS: : hello #+BEGIN_SRC bash :noweb yes :results verbatim echo "<>" #+END_SRC #+RESULTS: : hello If hope this helps someone if they need it. -k. On 2023-04-08 at 05:22 -07, Ihor Radchenko wrote... > Ken Mankoff writes: > >> Is it possible to set variables using Org Babel inside screen, which >> does not support ":var" header args? I'd actually lke a double-nested >> screen over ssh, and the ability to re-use Babel code blocks under >> different headings, using header args or PROPERTIES to change >> variables. That is, something like: > > Yes. > >> ... >> #+NAME: get-prop >> #+BEGIN_SRC emacs-lisp :var prop="FOO" :noweb yes >> (org-macro--get-property prop "") >> #+END_SRC >> >> #+NAME: inject_vars >> #+BEGIN_SRC shell :noweb yes >> # echo <> # testing >> echo export FOO=<> >> echo export BAR=<> >> echo export BAZ=<> >> #+END_SRC > > This did not work as you expected because noweb evaluates code block > with point at that code block. > > To get the property value at the code block where you expand noweb > reference, you need to compute the value in the arguments to the > reference. Something like > > #+name: identity > #+begin_src elisp :var x="" > > x > #+end_src > > ... > echo export FOO=< ...