From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 0j5oDAovEmAhcAAA0tVLHw (envelope-from ) for ; Thu, 28 Jan 2021 03:27: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 mp2 with LMTPS id EKL6BwovEmCFGgAAB5/wlQ (envelope-from ) for ; Thu, 28 Jan 2021 03:27: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 6785C940341 for ; Thu, 28 Jan 2021 03:27:05 +0000 (UTC) Received: from localhost ([::1]:45588 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l4xxX-000599-Tm for larch@yhetil.org; Wed, 27 Jan 2021 22:27:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40414) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l4xwy-000590-Mm for emacs-orgmode@gnu.org; Wed, 27 Jan 2021 22:26:28 -0500 Received: from hiwela.pair.com ([209.68.5.201]:55298) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l4xww-00084w-Kr for emacs-orgmode@gnu.org; Wed, 27 Jan 2021 22:26:28 -0500 Received: from hiwela.pair.com (localhost [127.0.0.1]) by hiwela.pair.com (Postfix) with ESMTP id EE19A98056B; Wed, 27 Jan 2021 22:26:22 -0500 (EST) Received: from minshall-entroware-apollo.cliq.com (unknown [78.179.89.156]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by hiwela.pair.com (Postfix) with ESMTPSA id BAEF68F0956; Wed, 27 Jan 2021 22:26:22 -0500 (EST) Received: from apollo2.minshall.org (localhost [IPv6:::1]) by minshall-entroware-apollo.cliq.com (Postfix) with ESMTP id EEF41630C5; Thu, 28 Jan 2021 06:26:17 +0300 (+03) From: Greg Minshall To: John Kitchin Subject: Re: Get =#+RESULTS= without re-evaluating source code block? In-reply-to: Your message of "Wed, 27 Jan 2021 18:31:03 -0500." X-Mailer: MH-E 8.6+git; nmh 1.7.1; GNU Emacs 27.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1342983.1611804377.1@apollo2.minshall.org> Date: Thu, 28 Jan 2021 06:26:17 +0300 Message-ID: <1342984.1611804377@apollo2.minshall.org> Received-SPF: softfail client-ip=209.68.5.201; envelope-from=minshall@umich.edu; helo=hiwela.pair.com X-Spam_score_int: -11 X-Spam_score: -1.2 X-Spam_bar: - X-Spam_report: (-1.2 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=no 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: tomas@tuxteam.de, emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -1.25 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=umich.edu (policy=none); 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: 6785C940341 X-Spam-Score: -1.25 X-Migadu-Scanner: scn1.migadu.com X-TUID: 9XliPT2XQpT3 John, > I tried this but it did not work for me. to be clear, caching means that the *first* time you execute, your reference will have to wait for the long-running computation to complete, but not during subsequent executions (unless the source block that performs the execution changes, in which case the reference will again have to wait). also, caching means that, after the first execution (ditto caveat) the source block *will no longer run*. so, if there were any (other) side effects of running that source block, they will not happen. (you could possibly split the side effect-producing code out of that block.) i'm not sure if this explains what did not work for you. cheers, Greg > > > On Wed, Jan 27, 2021 at 5:38 PM wrote: > > > On Wed, Jan 27, 2021 at 05:14:43PM -0500, doltes wrote: > > > Get =#+RESULTS= without re-evaluating source code block? > > > > > > Let's suppose I have a code block which requires a long time to finish > > > > > > #+NAME: big-computation > > > #+begin_src bash > > > sleep 5 # Some computation which requires a long time to complete. > > > echo a > > > #+end_src > > > > > > #+RESULTS: big-computation > > > #+begin_example > > > a > > > #+end_example > > > > > > I want to use the results of that code block in other code blocks so I > > > use a =noweb= reference (see below.) > > > > > > #+begin_src bash :noweb yes > > > printf "%s\n" <> > > > #+end_src > > > > > > #+RESULTS: > > > #+begin_example > > > a > > > > > > #+end_example > > > > > > However, doing this (i.e. using a =noweb= reference) would make the > > > command to be evaluated whenever getting its results. I don't want > > > this, I want the =:noweb= reference to actually use the already > > > computed results. > > > > > > So, my question is: Is it possible to use the actual =#+RESULTS= code > > > block instead of always evaluating it when referencing the results > > > through a =:noweb= reference? > > > > Perhaps "Cache results of evaluation" (15.5 Evaluating Code Blocks, > > in the Interwebs here [1] is for you. > > > > In short, add a header argument :cache yes to your code block. > > > > Cheers > > > > [1] https://orgmode.org/org.html#Evaluating-Code-Blocks > > > > - t > > > -- > John > > ----------------------------------- > Professor John Kitchin > Doherty Hall A207F > Department of Chemical Engineering > Carnegie Mellon University > Pittsburgh, PA 15213 > 412-268-7803 > @johnkitchin > http://kitchingroup.cheme.cmu.edu