From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id qFBSGT6/L2DWFwAA0tVLHw (envelope-from ) for ; Fri, 19 Feb 2021 13:38:06 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id aDUWFT6/L2ASaQAAbx9fmQ (envelope-from ) for ; Fri, 19 Feb 2021 13:38:06 +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 9EB0C9C72 for ; Fri, 19 Feb 2021 14:38:05 +0100 (CET) Received: from localhost ([::1]:48830 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lD5yu-0000wf-Fq for larch@yhetil.org; Fri, 19 Feb 2021 08:38:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45938) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lD5yB-0000uA-4B for emacs-orgmode@gnu.org; Fri, 19 Feb 2021 08:37:19 -0500 Received: from mail-io1-xd2e.google.com ([2607:f8b0:4864:20::d2e]:41719) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lD5y8-0007b2-PC for emacs-orgmode@gnu.org; Fri, 19 Feb 2021 08:37:18 -0500 Received: by mail-io1-xd2e.google.com with SMTP id e133so5609708iof.8 for ; Fri, 19 Feb 2021 05:37:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=VgmWJdf3lgEu9Ipx6w+HryagzMRNNbBeImjp55qUUW4=; b=jE1zUx4AGzMu7w7Y76uQfkqRBeRME/gaV73gqokGwVhni2+kgo489LYCcaiiXGBTOd meD9m+A7c9FRrAQrtojSfNdow2dbUbvAnbrUzp7vw6UKM1gcXSwLpu+3b5yQpU/ql/+v d8LybmLfa/dywKJmK4WwNQlo9Y1ssofQ79KOCdeLQiVtgZosRw6SlYcX7GDNe0EisHL/ 8PeEEoOvQbEeRqPpbuw8QcDl4bWCOswHn2Jiolnva9tfcrSimZFyGvwb3EDqlDZ36Tfr 2OMsjeoA6dEdhT3ANHmwCB2JFBNwntNaNJHcaGdrA8DFJYt3z9KXRC5uBXo4wG2u8vXH Sxkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=VgmWJdf3lgEu9Ipx6w+HryagzMRNNbBeImjp55qUUW4=; b=draduQrL0hx4KvMV7Qwj9xEu+EHbGzEonePX0PiYbN7Ier6NZ+PWajEnwz/F7RBnmn J6KndA0EYhebb1fQzeG+3wwYZh4EfZkpQpp5KMwc/TXsGSk1ms9eYZNljd8/LX6O5e3T mvQgfeP1oVZVwKMFEr0q4EiCBNt9EnbZZKRUHuCxD11VqVwCuaooWaTMoV+fJFnv0h02 hFWUvBTs/Qk/ujvqxPoB/4Fdk4KK089/IcuU0fCZWF5hy5ku+Hk08YSSO0eiGaCEGWZR URPYJUl2xHhdNrCsAReBqGy/dMQdvAivhNxbCkel9PMH8JgG6UvS6voZdUgRZ1TyaAIW Qozg== X-Gm-Message-State: AOAM5308mveVv4vy5g8mA0LYpqL13ITQ2nyb+8Y0pusdxCvqVX/SeKgR 825JrvlfTQiv0MIFtDv+zX2Usfuus7dmQd6zI6Qb3c+8pB4= X-Google-Smtp-Source: ABdhPJzYr7XRCjVAMZsloPTK/SQ4TE5e1dJJAUSks/2KeRG/rch+DWGJOxvr9DC4GzVNPaE0+S+KLCN+TxnD1g9qnaw= X-Received: by 2002:a05:6602:1608:: with SMTP id x8mr3952103iow.109.1613741835285; Fri, 19 Feb 2021 05:37:15 -0800 (PST) MIME-Version: 1.0 References: <878s7ljbd7.fsf@gmail.com> In-Reply-To: <878s7ljbd7.fsf@gmail.com> From: Rodrigo Morales Date: Fri, 19 Feb 2021 08:33:28 -0500 Message-ID: Subject: Re: [feature request] The :pre header argument To: org-mode-email Content-Type: multipart/alternative; boundary="000000000000d9f8d905bbb08c1c" Received-SPF: pass client-ip=2607:f8b0:4864:20::d2e; envelope-from=moralesrodrigo1100@gmail.com; helo=mail-io1-xd2e.google.com 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, HTML_MESSAGE=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: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -3.07 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=jE1zUx4A; 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-Migadu-Queue-Id: 9EB0C9C72 X-Spam-Score: -3.07 X-Migadu-Scanner: scn0.migadu.com X-TUID: eEGP54uSSYt6 --000000000000d9f8d905bbb08c1c Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable You can read this message with proper formatting here ( https://codeberg.org/rdrg109/gists/src/branch/main/the-pre-header-argument.= org ). On Thu, 18 Feb 2021 at 16:52, Rodrigo Morales wrote: > > This message contains my thoughts on a feature request which I think > would be useful: The =3D:pre=3D header argument, it would be used to > execute a code block before the code block at point is executed. It > would be similar to the behavior of the =3D:post=3D header argument. > > Here's a simple example that shows how =3D:pre=3D could be used > > #+NAME: clean-path-experiments > #+begin_src dash > if [ ! -z "$my__experiments" ] && [ -d "$my__experiments" ]; then > find ~/e -mindepth 1 -maxdepth 1 -exec rm -rf {} + > fi > #+end_src > > #+NAME: tree-command > #+begin_src dash > tree -a --noreport > #+end_src > > #+NAME: create-dir-for-minimal-reproducible-example > #+HEADER: :pre clean-path-experiments() > #+HEADER: :post tree-command() > #+begin_src python > import os > > [os.makedirs(_) for _ in ["a/foo", "a/bar", "b"]] > [os.mknod(_) for _ in ["a/1.txt", "a/2.txt", "a/foo/b.txt", "a/bar/b.txt"= , > "b/b.txt"]] > #+end_src > > #+RESULTS: create-dir-for-minimal-reproducible-example > #+begin_example > . > =E2=94=9C=E2=94=80=E2=94=80 a > =E2=94=82 =E2=94=9C=E2=94=80=E2=94=80 1.txt > =E2=94=82 =E2=94=9C=E2=94=80=E2=94=80 2.txt > =E2=94=82 =E2=94=9C=E2=94=80=E2=94=80 bar > =E2=94=82 =E2=94=82 =E2=94=94=E2=94=80=E2=94=80 b.txt > =E2=94=82 =E2=94=94=E2=94=80=E2=94=80 foo > =E2=94=82 =E2=94=94=E2=94=80=E2=94=80 b.txt > =E2=94=94=E2=94=80=E2=94=80 b > =E2=94=94=E2=94=80=E2=94=80 b.txt > #+end_example > > I think that such header argument would be useful because of two > main reasons: > > * It would improve readability of code blocks by explicitly expressing > dependency > > By having a header argument for the sole purpose of expressing > dependencies between code blocks, the readability of header arguments > would be improved. Recall that it is currently possible to express > such dependency by calling a code block through a =3D:var <>=3D > header argument but I think that =3D:var=3D header argument must only be > used for defining variables (be it from results obtained from > different code blocks or literals). > > The first code block shown below show the differences between using > =3D:var=3D and =3D:pre=3D for the same scenario. =3Dfirst-code-block=3D u= ses the > =3D:var=3D header argument while the =3Dsecond-code-block=3D uses the =3D= :pre=3D > header argument. > > #+NAME: first-code-block > #+begin_src org > For our experimentation, let's start with an empty directory and let's > execute the first step. > > ,#+NAME: first-step > ,#+HEADER: :results silent > ,#+HEADER: :var e=3Dclean-path-experiments > ,#+begin_src dash > touch first-step.txt > ,#+end_src > > We know execute the second step. > > ,#+NAME: second-step > ,#+HEADER: :results silent > ,#+HEADER: :var e=3Dfirst-step > ,#+begin_src dash > touch second-step.txt > ,#+end_src > > Finally, we execute the third step. > > ,#+NAME: third-step > ,#+HEADER: :results silent > ,#+HEADER: :var e=3Dsecond-step > ,#+begin_src dash > touch third-step.txt > ,#+end_src > #+end_src > > #+NAME: second-code-block > #+begin_src org > For our experimentation, let's start with an empty directory and let's > execute the first step. > > ,#+NAME: first-step > ,#+HEADER: :results silent > ,#+HEADER: :pre clean-path-experiments() > ,#+begin_src dash > touch first-step.txt > ,#+end_src > > We know execute the second step. > > ,#+NAME: second-step > ,#+HEADER: :results silent > ,#+HEADER: :pre first-step() > ,#+begin_src dash > touch second-step.txt > ,#+end_src > > Finally, we execute the third step. > > ,#+NAME: third-step > ,#+HEADER: :results silent > ,#+HEADER: :pre second-step() > ,#+begin_src dash > touch third-step.txt > ,#+end_src > #+end_src > > In my opinion, the second code block looks more readable than the > first one. > > * it would add importance to the =3D:post=3D header argument > > The =3D:post=3D header argument can be used in Org Mode 9.3 to execute a > given code block after the code block at point is executed; having a > header argument that does the opposite of the =3D:post=3D header argument > would give relevance to the =3D:post=3D header argument. > > -- > Greetings, > Rodrigo Morales. > > IRC: rdrg109 (freenode) > --000000000000d9f8d905bbb08c1c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
You can read this message with proper formatting here ( https://codeberg.org/rdrg109/gists/src/branch/main/the-pre-he= ader-argument.org ).

On Thu, 18 Feb 2021 at 16:52, Rodrigo Morales <<= a href=3D"mailto:moralesrodrigo1100@gmail.com">moralesrodrigo1100@gmail.com= > wrote:
=
This message contains my thoughts on a feature request which I think
would be useful: The =3D:pre=3D header argument, it would be used to
execute a code block before the code block at point is executed. It
would be similar to the behavior of the =3D:post=3D header argument.

Here's a simple example that shows how =3D:pre=3D could be used

#+NAME: clean-path-experiments
#+begin_src dash
if [ ! -z "$my__experiments" ] && [ -d "$my__experim= ents" ]; then
=C2=A0 find ~/e -mindepth 1 -maxdepth 1 -exec rm -rf {} +
fi
#+end_src

#+NAME: tree-command
#+begin_src dash
tree -a --noreport
#+end_src

#+NAME: create-dir-for-minimal-reproducible-example
#+HEADER: :pre clean-path-experiments()
#+HEADER: :post tree-command()
#+begin_src python
import os

[os.makedirs(_) for _ in ["a/foo", "a/bar", "b&quo= t;]]
[os.mknod(_) for _ in ["a/1.txt", "a/2.txt", "a/fo= o/b.txt", "a/bar/b.txt", "b/b.txt"]]
#+end_src

#+RESULTS: create-dir-for-minimal-reproducible-example
#+begin_example
.
=E2=94=9C=E2=94=80=E2=94=80 a
=E2=94=82=C2=A0=C2=A0 =E2=94=9C=E2=94=80=E2=94=80 1.txt
=E2=94=82=C2=A0=C2=A0 =E2=94=9C=E2=94=80=E2=94=80 2.txt
=E2=94=82=C2=A0=C2=A0 =E2=94=9C=E2=94=80=E2=94=80 bar
=E2=94=82=C2=A0=C2=A0 =E2=94=82=C2=A0=C2=A0 =E2=94=94=E2=94=80=E2=94=80 b.t= xt
=E2=94=82=C2=A0=C2=A0 =E2=94=94=E2=94=80=E2=94=80 foo
=E2=94=82=C2=A0=C2=A0=C2=A0 =C2=A0 =C2=A0=E2=94=94=E2=94=80=E2=94=80 b.txt<= br> =E2=94=94=E2=94=80=E2=94=80 b
=C2=A0 =C2=A0 =E2=94=94=E2=94=80=E2=94=80 b.txt
#+end_example

I think that such header argument would be useful because of two
main reasons:

* It would improve readability of code blocks by explicitly expressing depe= ndency

By having a header argument for the sole purpose of expressing
dependencies between code blocks, the readability of header arguments
would be improved. Recall that it is currently possible to express
such dependency by calling a code block through a =3D:var <<name>&= gt;=3D
header argument but I think that =3D:var=3D header argument must only be used for defining variables (be it from results obtained from
different code blocks or literals).

The first code block shown below show the differences between using
=3D:var=3D and =3D:pre=3D for the same scenario. =3Dfirst-code-block=3D use= s the
=3D:var=3D header argument while the =3Dsecond-code-block=3D uses the =3D:p= re=3D
header argument.

#+NAME: first-code-block
#+begin_src org
For our experimentation, let's start with an empty directory and let= 9;s
execute the first step.

,#+NAME: first-step
,#+HEADER: :results silent
,#+HEADER: :var e=3Dclean-path-experiments
,#+begin_src dash
touch first-step.txt
,#+end_src

We know execute the second step.

,#+NAME: second-step
,#+HEADER: :results silent
,#+HEADER: :var e=3Dfirst-step
,#+begin_src dash
touch second-step.txt
,#+end_src

Finally, we execute the third step.

,#+NAME: third-step
,#+HEADER: :results silent
,#+HEADER: :var e=3Dsecond-step
,#+begin_src dash
touch third-step.txt
,#+end_src
#+end_src

#+NAME: second-code-block
#+begin_src org
For our experimentation, let's start with an empty directory and let= 9;s
execute the first step.

,#+NAME: first-step
,#+HEADER: :results silent
,#+HEADER: :pre clean-path-experiments()
,#+begin_src dash
touch first-step.txt
,#+end_src

We know execute the second step.

,#+NAME: second-step
,#+HEADER: :results silent
,#+HEADER: :pre first-step()
,#+begin_src dash
touch second-step.txt
,#+end_src

Finally, we execute the third step.

,#+NAME: third-step
,#+HEADER: :results silent
,#+HEADER: :pre second-step()
,#+begin_src dash
touch third-step.txt
,#+end_src
#+end_src

In my opinion, the second code block looks more readable than the
first one.

* it would add importance to the =3D:post=3D header argument

The =3D:post=3D header argument can be used in Org Mode 9.3 to execute a given code block after the code block at point is executed; having a
header argument that does the opposite of the =3D:post=3D header argument would give relevance to the =3D:post=3D header argument.

--
Greetings,
Rodrigo Morales.

IRC: rdrg109 (freenode)
--000000000000d9f8d905bbb08c1c--