From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id GO4YGLHhLmAoNQAA0tVLHw (envelope-from ) for ; Thu, 18 Feb 2021 21:52:49 +0000 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id IPnrE7HhLmBHQQAAB5/wlQ (envelope-from ) for ; Thu, 18 Feb 2021 21:52:49 +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 C879D147F3 for ; Thu, 18 Feb 2021 22:52:48 +0100 (CET) Received: from localhost ([::1]:57446 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lCrE7-00030y-0s for larch@yhetil.org; Thu, 18 Feb 2021 16:52:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38936) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lCrDg-00030r-C2 for emacs-orgmode@gnu.org; Thu, 18 Feb 2021 16:52:21 -0500 Received: from mail-qk1-x733.google.com ([2607:f8b0:4864:20::733]:39670) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lCrDd-0004h4-DL for emacs-orgmode@gnu.org; Thu, 18 Feb 2021 16:52:20 -0500 Received: by mail-qk1-x733.google.com with SMTP id h8so3721053qkk.6 for ; Thu, 18 Feb 2021 13:52:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=user-agent:from:to:subject:message-id:date:mime-version :content-transfer-encoding; bh=pxguKcuAchMV1kBoPNtSfhRQPTz/Hhp1AhNKcPtgIUM=; b=FqaU7QvnTruEqkKtVVD9iEr7teeYYznkBMFTl3vOQill8m6pK9ZtpeYmYiN44BnXrR loqN7gQkj8QDXL5pKchaJRTZHmEm+eq/XWdEgTQWr/7FUTrd23EamUXmw7hVhYV8R8Dg zknzXKtBwE8RZbrFQldIduf0Osr6FpvayomKg3G19IGbde2u4I/7vj3MRHosDF7JUu+K Ijp8G/2bTZnMiYOGzVmQYmBdjQ3CTxoyhM0Dgoghp6Bbf/fRO7IpktJz3eVSjQUlewCl e0YjMPog5TrqOiRXdesThNpN0WYZDNDBIi21i1uUaUUTHmHRw1RJhEArUaek87Tk4Ae5 islQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:user-agent:from:to:subject:message-id:date :mime-version:content-transfer-encoding; bh=pxguKcuAchMV1kBoPNtSfhRQPTz/Hhp1AhNKcPtgIUM=; b=S+5vHElV3K+eP5rPQL6Cv9rJjm1IqVqOCsRGDV6n5mYiPG1teSyrSAc/Pcs486KDkE Pz7Np1zq6vj0BtOM9+wwy+DDm09zX5OOgGqQII3Q1ugIHZZ2T/McC2zw5ZINXc+Y1nv8 f2acVL2w7KYVwSyYg1pUn50OCbn8cdTyze512lai/N30QwvjUcJTlf4c+A2Q45aK3Deu IQCpUcAPyy9vNYajbcxWKUVrmDEp6+tWYhCZKKRaj9av2wUJcabA+6vXW4qEplXFzDaz 1FIu0MYEx/drbHZ7f8Nlx4bjhnQQo6e6WAiJLwEgFttcH9ZW6PNULAdaz6Xgu/Rc0y1E B/VQ== X-Gm-Message-State: AOAM533LPKix7465cmsLM5PANd+3pyPYGXx2yhQDg2PEqXenalfXpkp1 zzGnxAsp1M8lnYLumjhnVDZnCjYWAQ0= X-Google-Smtp-Source: ABdhPJzhIFtZqcSXlGrhoVZ3rGDZH9+94v1LTWF77995pCvrH4lv5MjkfPdFEs+BTPiG+YdvnBTp6g== X-Received: by 2002:a37:59c1:: with SMTP id n184mr6714501qkb.67.1613685134514; Thu, 18 Feb 2021 13:52:14 -0800 (PST) Received: from localhost ([190.239.232.181]) by smtp.gmail.com with ESMTPSA id d193sm5016953qkg.126.2021.02.18.13.52.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Feb 2021 13:52:14 -0800 (PST) User-agent: mu4e 1.4.14; emacs 27.1 From: Rodrigo Morales To: emacs-orgmode@gnu.org Subject: [feature request] The :pre header argument Message-ID: <878s7ljbd7.fsf@gmail.com> Date: Thu, 18 Feb 2021 16:48:36 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2607:f8b0:4864:20::733; envelope-from=moralesrodrigo1100@gmail.com; helo=mail-qk1-x733.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, 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=FqaU7Qvn; 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: C879D147F3 X-Spam-Score: -3.07 X-Migadu-Scanner: scn1.migadu.com X-TUID: Fnqd2XOmrVc0 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=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 =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 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 <>=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'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. --=20 Greetings, Rodrigo Morales. IRC: rdrg109 (freenode)