From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 6AQUDrYyK2A/GQAA0tVLHw (envelope-from ) for ; Tue, 16 Feb 2021 02:49:26 +0000 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id YCTlCbYyK2BYEwAA1q6Kng (envelope-from ) for ; Tue, 16 Feb 2021 02:49:26 +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 78CBD254C1 for ; Tue, 16 Feb 2021 03:49:25 +0100 (CET) Received: from localhost ([::1]:48960 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lBqQV-0007vC-Ux for larch@yhetil.org; Mon, 15 Feb 2021 21:49:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52178) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lBqKx-0003dn-N5 for emacs-orgmode@gnu.org; Mon, 15 Feb 2021 21:43:39 -0500 Received: from mail-qk1-x72a.google.com ([2607:f8b0:4864:20::72a]:36175) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lBqKv-0005Fb-Uh for emacs-orgmode@gnu.org; Mon, 15 Feb 2021 21:43:39 -0500 Received: by mail-qk1-x72a.google.com with SMTP id v206so8279341qkb.3 for ; Mon, 15 Feb 2021 18:43:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:cc:subject:in-reply-to:date :message-id:mime-version; bh=Hlvcef4T3hIzLpSjs6992HRyF975S+pMk0O+/ZQfuI0=; b=AMs+bwK25T7aUnD1PNyo9pxG00bdYksMobvPXlHcZ6lWPontUnwsA8DZNFK45KtcY1 41IIONLHCOp0LroruoU3AeNJA/Tsz89xEKbnvLJePR9UE9qHdsVPRIowgh+1xUSFFlcx /99bgAUN50MJCSOd0KHWq8R3uFG23mfbEKVy7syqC/PpjbQrv8p/yMprQ2KKGBdYqEEz UnSDiXBWSDfte7k8gyZSK4da6rjTrFGtPV2s38NNKZuDdlI1gMGH1huRV2qvtVejfUlH J1xC1swyVwZjaXh7gsjnih4kcGay4oWdtUN3ipvj6y1U9pFlwZ/bTO5xj98DnJDe/Cac q87Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:date:message-id:mime-version; bh=Hlvcef4T3hIzLpSjs6992HRyF975S+pMk0O+/ZQfuI0=; b=ZDsRet1wCUJL8eDYpNaMNTr0WObnR5nA5LiUZQOrPtqPRgtqSBgBxOsOnhSiIEJNrB D0L56Yc4QvrhIiawgIsAvaHso6ymEKkM7TeySteQjM04T/U+XCebS7dBRpr1N/rG39Vx EQin6PPujDPPdCEZXmwlOKCgUKQzyqYp/DtajwA3Ogg6TIpRgkhHVfA+4Jk36dy1zVY4 agF093fkwZUQBqLsu+fG/IT/SKiBKzUjM53PKZxmfkTQ7EfApTkKFdEp+ESxyF00QJ7+ QwAgaxZzdmJF7RMVjyJtLJAFThhZQw9bXaPJEEhRBtIdxRfw/h5ic2Zlf56eZh4wXfww 1/Tg== X-Gm-Message-State: AOAM530IOQM5aB+ExdzbFk6JRZDNWzp8I8421Aag7eSHMMSOD1DXQJ4U DxH9mTpTdTidz0PpHptsSSE= X-Google-Smtp-Source: ABdhPJzFK8afclqyfagDJSToAfUoY48mlerxoyZOOtLOhkgXozt7uUUs4ZSpJAtcX95WRvUwYsEMSA== X-Received: by 2002:a37:6c1:: with SMTP id 184mr10528811qkg.65.1613443416925; Mon, 15 Feb 2021 18:43:36 -0800 (PST) Received: from localhost ([190.239.232.181]) by smtp.gmail.com with ESMTPSA id o3sm12957739qke.132.2021.02.15.18.43.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Feb 2021 18:43:35 -0800 (PST) References: <87r1lhaw7d.fsf@gmail.com> User-agent: mu4e 1.4.14; emacs 27.1 From: Rodrigo Morales To: John Kitchin Subject: Re: How to associate a code block to another one so that it is executed beforehand? In-reply-to: Date: Mon, 15 Feb 2021 21:39:59 -0500 Message-ID: <87tuqcka68.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::72a; envelope-from=moralesrodrigo1100@gmail.com; helo=mail-qk1-x72a.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: , Cc: org-mode-email Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -2.06 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=AMs+bwK2; 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: 78CBD254C1 X-Spam-Score: -2.06 X-Migadu-Scanner: scn0.migadu.com X-TUID: 70tDJAHkY66P John Kitchin writes: > Here is one way to do it. You use a :var to "run" the other block. Thank you very much for the suggestion. It indeed works but I think that I don't need what I was requesting now that I've found out about the =:post= header argument.e After reading your answer, I remembered that there exists the =:post= header argument and that fully changed the way I was taking notes. This is how my notes looked like #+begin_src org ,#+NAME: create-file-foo ,#+begin_src dash :results silent cat << EOF > main.txt foo first foo second EOF ,#+end_src ,#+NAME: create-file-bar ,#+begin_src dash :results silent cat << EOF > main.txt bar first bar second EOF ,#+end_src The following code block prints each line the corresponding index and the length of the specified file. # ==================================================================== # Here I wanted to call one of the code blocks presented above so that # before the Python code block is executed, the file is created. # ==================================================================== ,#+begin_src python with open('main.txt') as f: for line in f: print(line, end='') ,#+end_src #+end_src Now using the =:post= header argument my notes look like #+begin_src org We can print each line together with its index by executing ,#+NAME: read-file-with-index ,#+begin_src python with open('main.txt') as file: for idx,line in enumerate(file): print(idx, line, end='') ,#+end_src ,#+begin_src dash :post read-file-with-index() cat << EOF > main.txt foo first foo second EOF ,#+end_src ,#+RESULTS: ,#+begin_example 0 foo first 1 foo second ,#+end_example ,#+begin_src dash :post read-file-with-index() cat << EOF > main.txt bar first bar second EOF ,#+end_src ,#+RESULTS: ,#+begin_example 0 bar first 1 bar second ,#+end_example #+end_src Note that, in this scenario, when using the =:post= header argument it is only necessary to name the Python code block instead of naming all the code blocks that are meant to be processed by the Python script. -- Rodrigo Morales. IRC: rdrg109 (freenode)