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 UBueFMK0GGA9NAAA0tVLHw (envelope-from ) for ; Tue, 02 Feb 2021 02:11:14 +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 mXxeEMK0GGB/KgAAB5/wlQ (envelope-from ) for ; Tue, 02 Feb 2021 02:11:14 +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 0D2AA940481 for ; Tue, 2 Feb 2021 02:11:12 +0000 (UTC) Received: from localhost ([::1]:36834 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l6l9p-0005ep-OM for larch@yhetil.org; Mon, 01 Feb 2021 21:11:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57428) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l6l9S-0005eh-1l for emacs-orgmode@gnu.org; Mon, 01 Feb 2021 21:10:46 -0500 Received: from mail-qk1-x72f.google.com ([2607:f8b0:4864:20::72f]:37534) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l6l9P-0000Sm-JX for emacs-orgmode@gnu.org; Mon, 01 Feb 2021 21:10:45 -0500 Received: by mail-qk1-x72f.google.com with SMTP id s77so5065297qke.4 for ; Mon, 01 Feb 2021 18:10:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:references:user-agent:from:to:cc:subject:in-reply-to :message-id:date:mime-version; bh=GgxKaprI5929LXl2E4INNHdHA1K7aHw6lIvDfP1Muss=; b=g3wyOmcykJGCpJzSFb1JYQaEWWDKGBXqQdLxBsgmnlT8H2+viyJlT5tVLhv/FhuziI onWNKiOIXxAy6JvzHZWchLy4vG4R3Dbffwqs/T/upDtmv1RArMGt8Lj4rFvTNR4xd2qT jrdkMgUbjpwfZwiUDvoGEafNLrkmyxR8IJZUcbprImoxEJg/f7l8VEQ/jimLG7zUxkYa gh3q6KAf0Slq4Fgiypf7yy+zzpG4xyC/Qs783Lw6+GE28mEU4oqCF5NyXQQrnIv+5zbP 9izFkxhF4w1ass12Nzps8rFC6MljLE4x3zlofymoadOZYO2DkV02qeNUb6A5X7YckNUY tHig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:references:user-agent:from:to:cc:subject :in-reply-to:message-id:date:mime-version; bh=GgxKaprI5929LXl2E4INNHdHA1K7aHw6lIvDfP1Muss=; b=ging4+aYpHW/Ro63+GGgKHX0xwgmkeTbQpFzOwekM4F5aCqEG/YyJbjueNJ8lAROsM zCxVv6UYXuNibOPlVuuooZWtFhmyv4EzUh4/yXJ4FRPy/VYWjP0xvRAnhfPQ+aZYwp4q 47iRwS1DmJrk7jAvFTEStrzs2rogvIrRB7s4bm6hty92mndAp5jpYJ9kYBmINiIRQmGu Bj2Qw3OuJUyvCNdqsvqNnX0LxZNYNtqVRBxDxhdVR/sRUu8VzdY4WznYwVr7oihJ/lMy myRANgtM6jOlATs/74+Gymzy2hZ7AsJ72qfFjgy8S2d5Lw/JGexFf9UVYJwcwPQhW7eq vz5g== X-Gm-Message-State: AOAM5313qZd18mom1gdtm9kFvap7rZ24I1MU48hiVLvhbUsV8KGUlQiC kv/ihuTjqKTGMNoenMGDHesIEGps9zZPBw== X-Google-Smtp-Source: ABdhPJzvt7BZf30U2FdfD3c1WDetea0nBlSxv3v5pAva+PEGZxC2GDkAgnVnxrUlGSMRCfZuq63Y2w== X-Received: by 2002:a37:8485:: with SMTP id g127mr18581281qkd.233.1612231841109; Mon, 01 Feb 2021 18:10:41 -0800 (PST) Received: from Johns-iMac.local ([2601:547:901:1830:dcf4:27ac:d146:f8ea]) by smtp.gmail.com with ESMTPSA id l128sm2858208qkf.68.2021.02.01.18.10.40 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Feb 2021 18:10:40 -0800 (PST) References: <1342984.1611804377@apollo2.minshall.org> User-agent: mu4e 1.4.13; emacs 27.1.90 From: John Kitchin To: Greg Minshall Subject: Re: Get =#+RESULTS= without re-evaluating source code block? In-reply-to: <1342984.1611804377@apollo2.minshall.org> Message-ID: Date: Mon, 01 Feb 2021 21:10:39 -0500 MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::72f; envelope-from=johnrkitchin@gmail.com; helo=mail-qk1-x72f.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: -0.26 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20161025 header.b=g3wyOmcy; dmarc=fail reason="SPF not aligned (relaxed)" header.from=andrew.cmu.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: 0D2AA940481 X-Spam-Score: -0.26 X-Migadu-Scanner: scn1.migadu.com X-TUID: 8ApKBjCLeBIH I discovered that it matters a lot which block you cache. You have to cache the long running block. I had put cache on the block with noweb expansion, and then the long running block still runs every time. That was a surprise to me, since nothing was changing in that block, so I thought it would just use the cached result. Greg Minshall writes: > 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 -- 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