From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id 6N3ZN+3LEmS8CQEASxT56A (envelope-from ) for ; Thu, 16 Mar 2023 08:57:34 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id YBD+Nu3LEmS9TgEAG6o9tA (envelope-from ) for ; Thu, 16 Mar 2023 08:57:33 +0100 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 498681B5B6 for ; Thu, 16 Mar 2023 08:57:33 +0100 (CET) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=icloud.com header.s=1a1hai header.b="0LXX/NC+"; dmarc=pass (policy=quarantine) header.from=icloud.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=1678953453; 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=TdZquISvHrYJkt08rSUXMkVIk2wW7fOrcSmYubGi5Yg=; b=AOiITRdG2sWVtbUOGXKW4wvBCEz6KDUxcPeE68g6wxV9gNTOU0We6wbzxG8dLEhktkgRbr Q2QgVG5lx//8130pdW6FKRgcZu/Flh3luJCLW1Ye0EYW6RCg1/O0pjAvPX3Ep+S4RWo0M0 9/Kx1zUxDBbuiSUmfdeoPTUB0wCk9s7F97chYMyPQwwOuPO+lakSYhDmGlGS02c+viycX5 Dnrv3bbdCn5uU9z7mV7zaVLWZ1T3gz96Cs3GPXsf+I5xtYS8An+cBb84f/qwoPXYuMuPvB 8+IB5H5vij4YvWkl8+CL5bgq4mxsu/P6/mcqdUVG14mK9cXuGx5cr1L3FdsmJw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=icloud.com header.s=1a1hai header.b="0LXX/NC+"; dmarc=pass (policy=quarantine) header.from=icloud.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-Seal: i=1; s=key1; d=yhetil.org; t=1678953453; a=rsa-sha256; cv=none; b=VwaSG6Z++bS/yTCTADZj7BtfpPtnq+CUeojLbCjWueKOMDvBnJcBf1FZngrEt+c0CEPD3v fyOUIP3MG3oieSVxwWPJOJdExPcnfdhZWmwhsFcOt1SpOJ9ns4XFttkGwQBrYJK+0sksks Ipp+/zIgXOHZjUe9TQDhutroodNmCTCIkD+ychtb+u9JwnhHdDhIzj23C5vQpf/vAL+DhP dN2U4aT+8Ibc+DnyhA7OSXJ4horacnCodXyXTo3QvY2W7iiJRiJ+vy2Z3McvSZhhbbn+23 DySPzYBnFxuu/mOFjHltZqm9Sa2LPCUfZ9DayopemIhQTUl3nBG8Newm61GtNA== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pciTg-0001Z4-9A; Thu, 16 Mar 2023 03:56:50 -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 1pciTX-0001Vd-Ni for emacs-orgmode@gnu.org; Thu, 16 Mar 2023 03:56:40 -0400 Received: from st43p00im-ztbu10073601.me.com ([17.58.63.184]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pciTV-0001IB-C9 for emacs-orgmode@gnu.org; Thu, 16 Mar 2023 03:56:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1678953395; bh=TdZquISvHrYJkt08rSUXMkVIk2wW7fOrcSmYubGi5Yg=; h=From:Message-Id:Content-Type:Mime-Version:Subject:Date:To; b=0LXX/NC++X9tdWOp7AxzH9WhVSESmnpSfxryqEm5rJ1Z/txn8L6xxOuWFrqDr1Dcs g+B3gQgR4XX1hlM7psuDR6fdPCsSejfc7bo6NfpRGXSoWN1IZUtnHjOBC/8hpegM2n K3y0SJEbRk0ahFPNYKTKypBfD1QRRpXOMgouR4io5Vn1CY3air/zxySlTzR7b+WzaR BWHpNr+iJCo/c6uPZqJToiyYO3MT4+XbkX0XKmiXUSb2bgS97KKay/BHl42SKhnBzX /g+Bj1LOh5piO/m8/ZQmzLqtsFRps1GPDHCPmcQUVW5dO1HyIcSNsaPClaa5IOEMHL mhuJ7ZX9JV73A== Received: from smtpclient.apple (st43p00im-dlb-asmtp-mailmevip.me.com [17.42.251.41]) by st43p00im-ztbu10073601.me.com (Postfix) with ESMTPSA id 319D818168F; Thu, 16 Mar 2023 07:56:35 +0000 (UTC) From: suarezmiguelc@icloud.com Message-Id: <53102F6A-7A5E-499B-B63F-64B96D23B359@icloud.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_EAC2DBFB-E6B1-4543-A4A5-28D19A01E321" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.400.51.1.1\)) Subject: Re: Noweb Function's body without evaluation Date: Thu, 16 Mar 2023 08:56:21 +0100 In-Reply-To: <87zg8dtjo8.fsf@t480.home> Cc: emacs-orgmode@gnu.org To: Ken Mankoff References: <87zg8dtjo8.fsf@t480.home> X-Mailer: Apple Mail (2.3731.400.51.1.1) X-Proofpoint-ORIG-GUID: ggmfJKuhg6WP-7Bqs-EHRHMww6DMzpNu X-Proofpoint-GUID: ggmfJKuhg6WP-7Bqs-EHRHMww6DMzpNu X-Proofpoint-Virus-Version: =?UTF-8?Q?vendor=3Dfsecure_engine=3D1.1.170-22c6f66c430a71ce266a39bfe25bc?= =?UTF-8?Q?2903e8d5c8f:6.0.517,18.0.883,17.11.64.514.0000000_definitions?= =?UTF-8?Q?=3D2022-06-21=5F08:2022-06-21=5F01,2022-06-21=5F08,2022-02-23?= =?UTF-8?Q?=5F01_signatures=3D0?= X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 spamscore=0 phishscore=0 clxscore=1011 malwarescore=0 adultscore=0 mlxlogscore=999 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2303160066 Received-SPF: pass client-ip=17.58.63.184; envelope-from=suarezmiguelc@icloud.com; helo=st43p00im-ztbu10073601.me.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.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_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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: X-Migadu-Queue-Id: 498681B5B6 X-Spam-Score: -7.47 X-Migadu-Spam-Score: -7.47 X-Migadu-Scanner: scn0.migadu.com 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 X-TUID: Yr23QnMm7HMM --Apple-Mail=_EAC2DBFB-E6B1-4543-A4A5-28D19A01E321 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Hello Ken, thank you for your message, After reading the very interesting get_property function, I found that = even though I will probably use it for some cases, it doesn=E2=80=99t = apply directly, to my case. For more examples, if I have 1 source code block: >> #+name: greeting >> #+begin_src sh :var name=3D"world" :results output :session testing >>=20 >> echo "hello, $name\!" >> #+end_src I have three options in noweb to use this: - Use its body into another begin_src source code block with = <> - Use its result =E2=80=9Chello, world!=E2=80=9D Into another code = block, which results in babel trying to execute the hello, command, = which doesn=E2=80=99t exist, this with <> - Use its result, the same as above, but with another parameter, results = in the same but the variable name is different, so = <> I=E2=80=99m trying to do the first, but with another parameter, so Use = its body into another begin_src source code block with, get the = resulting body after changing the variable without it being evaluated, = so that I get a valid command to get to bash, like with <>, = but I can specify a different name variable. I found the [:body] param but, even though it lets me change the = variable as I want, it then tries to evaluate it, so I get a different = value but the same hello, command doesn=E2=80=99t exist. Even though = what I would want is to get echo =E2=80=9Chello, $name\!=E2=80=9D but, = $name is different. Thank you for your response Ken, I hope I gave a clearer example with = the above. > 16/3/23 5:16=E3=80=81Ken Mankoff =E3=81=AE=E3=83=A1=E3= =83=BC=E3=83=AB: >=20 > Hi, >=20 > I'm not sure that I understand your issue or needs from the provided = examples, but I wonder if the example I provide here would be helpful. = It bypasses :var an lets you inject a PROPERTY value anywhere. It is = also language agnostic. You can use it to execute commands (that are set = as PROPERTY values) or set variables to values. >=20 > https://lists.gnu.org/archive/html/emacs-orgmode/2023-03/msg00251.html >=20 > -k. >=20 > On 2023-03-15 at 18:54 -04, suarezmiguelc@icloud.com wrote... >> Hello Org-mode community. I=E2=80=99m using Emacs Doom Framework, = specifically: >>=20 >> Emacs 28.2 (build 1, aarch64-apple-darwin22.3.0, Carbon Version 169 >> AppKit 2299.4) of 2023-02-23. >>=20 >> I use heavily org-mode for Literate DevOps, so I have a lot of shell >> commands that connect through SSH and do some things later, for >> example: >>=20 >> #+name: initSSH >> #+begin_src shell :var connection=3D=E2=80=9Cadmin@somehost" >>=20 >> ssh -t miguel@host "sudo -u someuser ssh -t $connection 'sudo su'" >> #+end_src >>=20 >> So then I can call: >>=20 >> #+call: initSSH(connection=3D=E2=80=9Cadmin@anotherhost=E2=80=9D) >>=20 >> With any other header parameters or session, the above works >> correctly. I cannot use tramp due to network latency issues, so this >> is the most performance way for me, since I also have to do some >> multi-hops which are indeed supported in tramp, but it is too slow = for >> me, so I rather only commands. >>=20 >> The thing is that, I then would like to call these not with a #+call >> function, but add them into a bigger script, let=E2=80=99s say that I = define >> another command: >>=20 >> #+name: getStorage >> #+begin_src shell >>=20 >> df >> #+end_src >>=20 >> Which has to be run in a remote server, could be any remote server as >> I have to connect to several. So I would like to be able to: >>=20 >> #+begin_src shell >> <> >> <> >> #+end_src >>=20 >>=20 >> The first doesn=E2=80=99t work as org-mode runs the code and passes = the >> resulting string to bash, which isn=E2=80=99t a command. The latter = works >> normally. So the issue here are the parameters. >>=20 >> So I made another simple example for this: >>=20 >> #+name: greeting >> #+begin_src sh :var name=3D"world" :results output :session testing >>=20 >> echo "hello, $name\!" >> #+end_src >>=20 >> #+results: greeting >> #+begin_src sh >>=20 >> hello, world\! >> #+end_src >>=20 >> #+begin_src shell >> <> >> #+end_src >>=20 >>=20 >> This results in sh: hello,: command not found, as it is executing the = function. I see in the documentation that I can: >> - Call a function=E2=80=99s body with <> >> - Execute a function and return its results with <> >> - Execute a function and return its results even with different = params with <> >>=20 >> So right now, the one that=E2=80=99s missing is, call a function=E2=80=99= s body with different parameters. So the >> function <> is not evaluated. >>=20 >> After searching a lot, I came across: >>=20 >> #+begin_src shell :session testing >> <> >> #+end_src >>=20 >> Which results in: >>=20 >> sh-3.2$ PS1=3D"org_babel_sh_prompt> " >> org_babel_sh_prompt> name=3D'Testingggg' >> org_babel_sh_prompt> echo "hello, $name\!" >> hello, Testingggg\! >> org_babel_sh_prompt> echo 'org_babel_sh_eoe' >> org_babel_sh_eoe >> org_babel_sh_prompt> hello, Testingggg\! >> sh: hello,: command not found >> org_babel_sh_prompt> echo 'org_babel_sh_eoe' >> org_babel_sh_eoe >> org_babel_sh_prompt>=20 >>=20 >> Which is somewhat what I need since at least the variable is changed, >> but the result of this execution is also passed to shell so, same >> error. >>=20 >> I can=E2=80=99t find much documentation about this, what is the = correct syntax >> here?, >>=20 >> Thank you! >=20 --Apple-Mail=_EAC2DBFB-E6B1-4543-A4A5-28D19A01E321 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 Hello Ken, = thank you for your message,

After reading the very = interesting get_property function, I found that even though I will = probably use it for some cases, it doesn=E2=80=99t apply directly, to my = case.

For more examples, if I have 1 source = code block:

#+name: greeting
#+begin_src sh :var name=3D"world" = :results output :session testing

echo "hello, = $name\!"
#+end_src

I = have three options in noweb to use this:
- Use its body into = another begin_src source code block with = <<greeting>>
- Use its = result =E2=80=9Chello, world!=E2=80=9D Into another code = block, which results in babel trying to execute the hello, = command, which doesn=E2=80=99t exist, this with = <<greeting()>>
- Use its result, the same = as above, but with another parameter, results in the same but the = variable name is different, so <<greeting(name=3D=E2=80=9Canother = name=E2=80=9D)>>

I=E2=80=99m trying to do = the first, but with another parameter, so Use its body into another = begin_src source code block with, get the resulting body after changing = the variable without it being evaluated, so that I get a valid command = to get to bash, like with <<greeting>>, but I can specify a = different name variable.

I found the [:body] = param but, even though it lets me change the variable as I want, it then = tries to evaluate it, so I get a different value but the same = hello, command = doesn=E2=80=99t exist. Even though what I would want is to get echo = =E2=80=9Chello, $name\!=E2=80=9D but, $name is = different.

Thank you for your response Ken, I = hope I gave a clearer example with the = above.


16/3/23= 5:16=E3=80=81Ken Mankoff = <mankoff@gmail.com>=E3=81=AE=E3=83=A1=E3=83=BC=E3=83=AB:

Hi,

I'm not sure = that I understand your issue or needs from the provided examples, but I = wonder if the example I provide here would be helpful. It bypasses :var = an lets you inject a PROPERTY value anywhere. It is also language = agnostic. You can use it to execute commands (that are set as PROPERTY = values) or set variables to = values.

https://lists.gnu.org/archive/html/emacs-orgmode/2023-03/ms= g00251.html

 -k.

On 2023-03-15 at 18:54 -04, = suarezmiguelc@icloud.com wrote...
Hello = Org-mode community. I=E2=80=99m using Emacs Doom Framework, = specifically:

Emacs 28.2 (build 1, aarch64-apple-darwin22.3.0, = Carbon Version 169
AppKit 2299.4) of 2023-02-23.

I use heavily = org-mode for Literate DevOps, so I have a lot of shell
commands that = connect through SSH and do some things later, = for
example:

#+name: initSSH
#+begin_src shell :var = connection=3D=E2=80=9Cadmin@somehost"

ssh -t miguel@host "sudo -u = someuser ssh -t $connection 'sudo su'"
#+end_src

So then I can = call:

#+call: = initSSH(connection=3D=E2=80=9Cadmin@anotherhost=E2=80=9D)

With = any other header parameters or session, the above works
correctly. I = cannot use tramp due to network latency issues, so this
is the most = performance way for me, since I also have to do some
multi-hops which = are indeed supported in tramp, but it is too slow for
me, so I rather = only commands.

The thing is that, I then would like to call these = not with a #+call
function, but add them into a bigger script, = let=E2=80=99s say that I define
another command:

#+name: = getStorage
#+begin_src shell

df
#+end_src

Which has = to be run in a remote server, could be any remote server as
I have to = connect to several. So I would like to be able to:

#+begin_src = shell
<<initSSH(connection=3D=E2=80=9Cadmin@anotherhost=E2=80=9D)= >>
<<getStorage>>
#+end_src


The first = doesn=E2=80=99t work as org-mode runs the code and passes = the
resulting string to bash, which isn=E2=80=99t a command. The = latter works
normally. So the issue here are the = parameters.

So I made another simple example for = this:

#+name: greeting
#+begin_src sh :var name=3D"world" = :results output :session testing

echo "hello, = $name\!"
#+end_src

#+results: greeting
#+begin_src = sh

hello, world\!
#+end_src

#+begin_src = shell
<<greeting(name=3D"ss")>>
#+end_src


Thi= s results in sh: hello,: command not found, as it is executing the = function. I see in the documentation that I can:
- Call a = function=E2=80=99s body with <<namedcodeblock>>
- Execute = a function and return its results with = <<namedcodeblock()>>
- Execute a function and return its = results even with different params with = <<namedcodeblock(param=3D=E2=80=9Csds=E2=80=9D)>>

So = right now, the one that=E2=80=99s missing is, call a function=E2=80=99s = body with different parameters. So the
function = <<namedcodeblock>> is not evaluated.

After searching = a lot, I came across:

#+begin_src shell :session = testing
<<greeting[:body](name=3D"Testingggg")>>
#+end_s= rc

Which results in:

sh-3.2$ PS1=3D"org_babel_sh_prompt> = "
org_babel_sh_prompt> = name=3D'Testingggg'
org_babel_sh_prompt> echo "hello, = $name\!"
hello, Testingggg\!
org_babel_sh_prompt> echo = 'org_babel_sh_eoe'
org_babel_sh_eoe
org_babel_sh_prompt> hello, = Testingggg\!
sh: hello,: command not found
org_babel_sh_prompt> = echo 'org_babel_sh_eoe'
org_babel_sh_eoe
org_babel_sh_prompt> =

Which is somewhat what I need since at least the variable is = changed,
but the result of this execution is also passed to shell so, = same
error.

I can=E2=80=99t find much documentation about = this, what is the correct syntax
here?,

Thank = you!


<= /html>= --Apple-Mail=_EAC2DBFB-E6B1-4543-A4A5-28D19A01E321--