From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id IHMsCbiWXWPl8wAAbAwnHQ (envelope-from ) for ; Sat, 29 Oct 2022 23:10:16 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id OLEnCLiWXWMwTQAAG6o9tA (envelope-from ) for ; Sat, 29 Oct 2022 23:10:16 +0200 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 D89BF2AF73 for ; Sat, 29 Oct 2022 23:10:15 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oot59-0000ds-8Q; Sat, 29 Oct 2022 17:09:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oot58-0000dl-2e for emacs-orgmode@gnu.org; Sat, 29 Oct 2022 17:09:30 -0400 Received: from mail-qv1-xf2d.google.com ([2607:f8b0:4864:20::f2d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oot56-00070i-F6 for emacs-orgmode@gnu.org; Sat, 29 Oct 2022 17:09:29 -0400 Received: by mail-qv1-xf2d.google.com with SMTP id n18so6226341qvt.11 for ; Sat, 29 Oct 2022 14:09:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:user-agent:message-id:date:subject:to:from:from:to:cc :subject:date:message-id:reply-to; bh=dGh5/VamDpY99RDhESwt1LBrEUkCcXaZtvCnBGtf2B8=; b=Ba/OoM5ZtKa8X6bD9x7WjgTqTYkDYBxUFv4SpJVkced9gOF9zJomdhhEaB6O4/6tq2 QVAdrkPvVymn97q6igUZlREvyO5BhBDecb1bTUNrFQWTRD8pKj2TbJhmJxhw9xJvSO2A bqJIm9itxifw4nbceuGd5F3TBu3a7UZ9++SDaeJLT4ZsZZfl0RnmTFUyu08Nn/gFBEw7 OQJb8LwaWrTXh51xEBkIpHcD/oO0kCIm9STrLmBak2TlLvAetFTvUSrTSB/niPkT+Nvb 8m9RjU/TWzhVLXqlSn85w5Td7ca41MvdYngzCE3gK9lvRRuoXrXR7ZZZGYQgOB02DPSD yynw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:date:subject:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=dGh5/VamDpY99RDhESwt1LBrEUkCcXaZtvCnBGtf2B8=; b=zb7orn3sbmU4ILQZC788ihGjq/xHGxbc0GaGeXyF7rScYHYL7jg0xkdLFoVAEOmuGI QpnMzIgGH0L5K9txLG+vqFNLDJ5nB3LwPIYHO2Hb6SNwSls75XK72HidtgqLWrQH56LJ TSEV0T3VDRMRcYDQ6wNa7nTCHzk0ne+1YLRTzm9H4CNXm61rmd2Rsfr4qPcvorgDUCky 0drQs/e0+OtLb0xlP/rJ+MUP+hIRWjwFDeGhNAUfOcKlOMrXJXuuqLGGrQDLq+87mWxu Pam9oKPsIKsJzNqwyiLCTSHnRgwD4w2xSp8oRSKB2uT5U2Slh/Qa3q50L60Auq5clcMS cr3w== X-Gm-Message-State: ACrzQf0xoJO264Nx9w+8Zbdj3By278fuh3IMn6VMdwLHqB63vhFMQAQR BZslyYRRcifq4tiLOZZKQDi1a0xqivk= X-Google-Smtp-Source: AMsMyM7iWki1ZKGzTdwyj7gFv2BcbRelT0wEpI5CxrBsBG13ppUDy9PddlCTSxbtBE5P2yH25vZeDA== X-Received: by 2002:a05:6214:2484:b0:4bb:de5d:b6e4 with SMTP id gi4-20020a056214248400b004bbde5db6e4mr1371276qvb.126.1667077766884; Sat, 29 Oct 2022 14:09:26 -0700 (PDT) Received: from penguin (2603-7080-0903-9eea-0216-3eff-fec3-97a0.res6.spectrum.com. [2603:7080:903:9eea:216:3eff:fec3:97a0]) by smtp.gmail.com with ESMTPSA id bp11-20020a05620a458b00b006ce3f1af120sm1722401qkb.44.2022.10.29.14.09.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Oct 2022 14:09:26 -0700 (PDT) From: Kierin Bell To: emacs-orgmode@gnu.org Subject: Inserting arbitrary lines before tables with Babel Date: Sat, 29 Oct 2022 17:09:23 -0400 Message-ID: <87wn8ibam4.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::f2d; envelope-from=bellkierin@gmail.com; helo=mail-qv1-xf2d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_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.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Emacs-orgmode" Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1667077815; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=dGh5/VamDpY99RDhESwt1LBrEUkCcXaZtvCnBGtf2B8=; b=VWwU6M4KEcZ661uuenuaVUGHj6H68lhbJv79bSaONPyqWUL9eWo/lghUyyZgQ/rw4UrSnO Dy6b5enLd/gPHR17ygoTgSNNCV6GoAAVidZg8SFyLZmPD1E9r0VhtZuv4FIk21uZwMDJ/D qLS3MIwewkImWYmORIb+oHYhjLWQMzl1Ypwnoy0iqvbfE4xuY3UK8jp2JII9y4ryfBnUI9 yKKc+Sgwz9d1Y3TdsEYOHD88LCJOHLiqaFj7JJRH7sE5qE75TRJ03UsQOJdc2jMPm/rFdo Rhv5Sru9Gk8CHe4k8adh+0WRGVvBBxqjNdV6I9DEVMvYfmGwSxa5VC+hF3YxQQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1667077815; a=rsa-sha256; cv=none; b=rRdEimZOMoJT1xdQsUTcfhQKAmCaCU6StqKmVAyPt4tVKeYFMrT4wLT3FtbHxEW6WCDvFa V1ZY0p4wnS+EsFhr+ddZLeSmJuvnF2nBCtjhoqonK69r3ch0GD/9eJRts3/2Z8CArhnwIK jPHsNKjaRfxlp/M8Mks2QB58UyepQJNI0+yCm8H1cBlhnDUhJwKtKQB7zDQMOQHqeNtfp/ 8Xm2YOfJ8Tf04Jq/DsRDwdg0JwpJec0mSZ4304r/Eo2/Bh5E1wFD0I7vqxS5Gv4kduo0z2 5wHjxI1pgKfcz9upcMjCRarHf2YngIhA+az/pBHG1r/asDuFdLSPmU+feLgHnw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="Ba/OoM5Z"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -9.53 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="Ba/OoM5Z"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: D89BF2AF73 X-Spam-Score: -9.53 X-Migadu-Scanner: scn0.migadu.com X-TUID: Y92yIAqhmlRk Hello, When evaluating Babel code blocks with a ':results table' header argument, what is the best way to automatically insert text _outside_ of the table? For example, if I have a source block: #+NAME: get-random-table #+begin_src R :var length=12 :results table runif(length) #+end_src ... Then 'org-babel-execute-maybe' (C-c C-v e) will output a nicely formatted Org table: #+RESULTS: get-random-table | 0.645291731692851 | | 0.0425670417025685 | | 0.220107783330604 | | 0.413881630403921 | | 0.817712268792093 | | 0.972381719155237 | ... But if I want to insert a line, for example containing a 'NAME' keyword, before and _outside of_ that table, there seems to be no easy way to do this automatically. Trying to insert lines using subsequent code blocks (arguments, noweb, etc.) will either strip Org table formatting or add additional lines within the table instead of outside of it (depending on the ':results' arguments). There is the same problem with using a ':post' header argument, and ':wrap' does not allow arbitrary insertion of individual lines. What I have in mind is to be able to do things like: #+CALL: get-named-table(name="random-table-1", source-block="get-random-table", length=7) #+RESULTS: #+NAME: random-table-1 | 0.310966729884967 | | 0.700660327449441 | | 0.668548531830311 | | 0.497187710367143 | | 0.245545281097293 | | 0.597585438517854 | | 0.639235997572541 | The only "solution" I can think of -- using Elisp to reformat list objects as Org tables -- feels like an overly complicated hack: #+NAME: get-named-table #+begin_src emacs-lisp :results raw :var name="default-name" length=12 (when (and (boundp 'source-block) (stringp source-block)) (let ((data (ensure-list (read (eval `(org-sbe ,source-block (length ,length))))))) (concat (format "#+NAME: %s" name) "\n" (orgtbl-to-orgtbl (or (and (seq-every-p (lambda (e) (or (eq e 'hline) (listp e))) data) data) (list data)) nil)))) #+end_src Is there a better way? (I'm learning that there usually is with Org.) The ability to dynamically prepend and append (e.g., #+TBLFM:) lines to results tables seems like it would be useful. Thanks, Kierin