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 6KjDDz2gql8dAwAA0tVLHw (envelope-from ) for ; Tue, 10 Nov 2020 14:14:21 +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 INe2Cz2gql97JAAAB5/wlQ (envelope-from ) for ; Tue, 10 Nov 2020 14:14:21 +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 89E58940415 for ; Tue, 10 Nov 2020 14:14:20 +0000 (UTC) Received: from localhost ([::1]:43158 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kcUPZ-0006xh-OK for larch@yhetil.org; Tue, 10 Nov 2020 09:14:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59142) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kcUOw-0006xY-Ve for emacs-orgmode@gnu.org; Tue, 10 Nov 2020 09:13:39 -0500 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]:46042) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kcUOs-0007oa-S7 for emacs-orgmode@gnu.org; Tue, 10 Nov 2020 09:13:38 -0500 Received: by mail-ej1-x62b.google.com with SMTP id dk16so17727621ejb.12 for ; Tue, 10 Nov 2020 06:13:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zzamboni-org.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=misQuULHaFAHxFBqUawR6AwgpxXRSkObTB+7qJrof/s=; b=Afi+oljrjPLbWRTfEdMQmB+cjPoxD9xFMDjrCCKK0Gbp4SyreOqIC+xLa1cW+9/xSP 7ZSErVOmLywLikUaFpbMc1vhAfOS2UCZiMAUW+Nz5H6+oVHVxafoeoz9iQVgc6TdcY6x UmhWoKoGpaOlvgVDVCxRTLsxXY476BmPJ0Ar2vj4dwy86oS4A06CpIKNqXg5QY/b8QiX W2jh5fQ11RXUqIAkpprGa+xzKRO1H2xCXAM5rEFyUuMUicRG/NQjSH3s5QMlMm68ElIP TqXdcl+zSrhAUTruMKFeDuBR/XUiXyKPKce74VPYlN6lS4CCYSLCcVfjtWzSFlBZ9nPR f3FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=misQuULHaFAHxFBqUawR6AwgpxXRSkObTB+7qJrof/s=; b=gqTkXKMSGoTxUAlD84Be42RrLNmj98bdI2XnOzcHTvzFm788n1lWP8vfrbDvqLOtM5 vsBFdYErXiZ1ZGvDcoQd0qh1T6Es5t2NqgAEmj+oxSh9MvvzGuj1X/6AGyrUWZt3CMte emvDvR8zZUKHxVzd85TNJkPKaPbTfdcunsi6plRXwPYpgeomyUXsqkBh2Pnt8+LSkdCl +2ke21Z2Mgz85IF+TOWL4EfilWBVF2XGrsN+F12dkDeUhInndqhUn8klObnXFAfcpGMs Xa2OnjxaI7p0g6GSpbvRUQgPjSloJqlinzmenkbjQRyaWxj/dRF8g9oCbBc0YmQDbeOW nt1w== X-Gm-Message-State: AOAM531yftD0CAViJrdfdJ3tca5/IgMmG3njwCqSWA96werHJTFF55WX QT7ynC2miU7ZQ1VaGf//wjUDFgtREyVx/c3hv2/BN3GalTv6AZns X-Google-Smtp-Source: ABdhPJw21xWFslp4L0EKe0PYbDbR/2dhyfRVUPYR4EiIqib+btfMRPPII5sm84eHryj/trWALC+98abo13QNVh4i37Y= X-Received: by 2002:a17:906:3782:: with SMTP id n2mr20625340ejc.493.1605017612888; Tue, 10 Nov 2020 06:13:32 -0800 (PST) MIME-Version: 1.0 From: Diego Zamboni Date: Tue, 10 Nov 2020 15:13:21 +0100 Message-ID: Subject: How to wrap Org code generated by a source block? To: Org-mode Content-Type: multipart/alternative; boundary="000000000000acc55305b3c148be" Received-SPF: none client-ip=2a00:1450:4864:20::62b; envelope-from=diego@zzamboni.org; helo=mail-ej1-x62b.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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-Scanner: ns3122888.ip-94-23-21.eu Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=zzamboni-org.20150623.gappssmtp.com header.s=20150623 header.b=Afi+oljr; dmarc=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-Spam-Score: -0.21 X-TUID: Aj23ncg994q+ --000000000000acc55305b3c148be Content-Type: text/plain; charset="UTF-8" Hi everyone, I want to generate some parts of my document programmatically from an emacs-lisp src block - i.e. the code produces Org markup which I want to then export. Is there a way to wrap the #+RESULTS block in an environment that still gets evaluated as Org text (e.g. when exporting)? More details: Here's a sample src block which shows the kind of thing I need to do: #+begin_src emacs-lisp :results value raw :exports results (mapconcat (lambda (b) (format "#+begin_%s Generated %s block at %s ,#+end_%s" b b (current-time-string) b)) '("example" "quote") "\n") #+end_src Using =:results value raw= in the header produces the result from the block without wrapping it in any blocks, which is exactly what I need. E.g.: #+RESULTS: #+begin_example Generated example block at Tue Nov 10 15:07:45 2020 #+end_example #+begin_quote Generated quote block at Tue Nov 10 15:07:45 2020 #+end_quote HOWEVER, this has the problem that when I re-evaluate the code block, only the first block below #+RESULTS gets replaced, pushing the others downward, so I end up with something like this after a couple of times: #+RESULTS: #+begin_example Generated example block at Tue Nov 10 15:08:42 2020 #+end_example #+begin_quote Generated quote block at Tue Nov 10 15:08:42 2020 #+end_quote #+begin_quote Generated quote block at Tue Nov 10 15:08:39 2020 #+end_quote #+begin_quote Generated quote block at Tue Nov 10 15:07:45 2020 #+end_quote If I remove the "raw" then the results get wrapped in an example block (or any other that I specify with =:wrap=), which means they get correctly replaced every time, but not evaluated as Org text: #+RESULTS: : #+begin_example : Generated example block at Tue Nov 10 15:09:46 2020 : #+end_example : #+begin_quote : Generated quote block at Tue Nov 10 15:09:46 2020 : #+end_quote So again, my question is: is there a way to wrap the #+RESULTS block in an environment that still gets evaluated as Org text (e.g. when exporting), so that I can rerun the code block without having to manually trim the results block afterwards? Thanks! --Diego --000000000000acc55305b3c148be Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi everyone,

I want to generate som= e parts of my document programmatically from an emacs-lisp src block - i.e.= the code produces Org markup which I want to then export. Is there a way t= o wrap the #+RESULTS block in an environment that still gets evaluated as O= rg text (e.g. when exporting)?

More det= ails:

Here's a sample src block which shows th= e kind of thing I need to do:

#+begin_src emacs-li= sp :results value raw :exports results
(mapconcat
=C2=A0(lambda (b) (= format "#+begin_%s
Generated %s block at %s
,#+end_%s" b b = (current-time-string) b))
=C2=A0'("example" "quote&qu= ot;) "\n")
#+end_src

Using =3D:re= sults value raw=3D in the header produces the result from the block without= wrapping it in any blocks, which is exactly what I need. E.g.:
<= br>
#+RESULTS:
#+begin_example
Generated example block at T= ue Nov 10 15:07:45 2020
#+end_example
#+begin_quote
Generated quot= e block at Tue Nov 10 15:07:45 2020
#+end_quote

=
HOWEVER, this has the problem that when I re-evaluate the code block, = only the first block below #+RESULTS gets replaced, pushing the others down= ward, so I end up with something like this after a couple of times:

#+RESULTS:
#+begin_example
Generated example block = at Tue Nov 10 15:08:42 2020
#+end_example
#+begin_quote
Generated = quote block at Tue Nov 10 15:08:42 2020
#+end_quote
#+begin_quote
= Generated quote block at Tue Nov 10 15:08:39 2020
#+end_quote
#+begin= _quote
Generated quote block at Tue Nov 10 15:07:45 2020
#+end_quote<= br>

If I remove the "raw" then the resul= ts get wrapped in an example block (or any other that I specify with =3D:wr= ap=3D), which means they get correctly replaced every time, but not evaluat= ed as Org text:

#+RESULTS:
: #+begin_example: Generated example block at Tue Nov 10 15:09:46 2020
: #+end_example: #+begin_quote
: Generated quote block at Tue Nov 10 15:09:46 2020: #+end_quote

So again, my question is: is th= ere a way to wrap the #+RESULTS block in an environment that still gets eva= luated as Org text (e.g. when exporting), so that I can rerun the code bloc= k without having to manually trim the results block afterwards?
<= br>
Thanks!
--Diego

--000000000000acc55305b3c148be--