From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id OKhUIJghCWL27AAAgWs5BA (envelope-from ) for ; Sun, 13 Feb 2022 16:19:52 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id aLWnHJghCWKmQAEAauVa8A (envelope-from ) for ; Sun, 13 Feb 2022 16:19:52 +0100 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 543A5EAD0 for ; Sun, 13 Feb 2022 16:19:51 +0100 (CET) Received: from localhost ([::1]:44744 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nJGfG-00068f-EH for larch@yhetil.org; Sun, 13 Feb 2022 10:19:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60380) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nJGek-00067k-MT for emacs-orgmode@gnu.org; Sun, 13 Feb 2022 10:19:19 -0500 Received: from [2607:f8b0:4864:20::734] (port=34380 helo=mail-qk1-x734.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nJGei-0000tw-F1 for emacs-orgmode@gnu.org; Sun, 13 Feb 2022 10:19:18 -0500 Received: by mail-qk1-x734.google.com with SMTP id bs32so12520796qkb.1 for ; Sun, 13 Feb 2022 07:19:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:references:user-agent:from:to:cc:subject:date:in-reply-to :message-id:mime-version; bh=GbW8Hjx15ERhaS/lJ3To1w1HVj+vzejvlbEQZPG02Y0=; b=b+JPcrHPMsZecx3FJrIlLz/RoqhddjuMEH5oHzhh4sFo83G1YiSDuFnTAOmDauUQsH 3mnPHqDCJ/IWNhAiYQQVe/dcCi8o35atpTyJV7M/2AxfDR2acSyTLDEPloJlbdTf+k61 NzrqWnRYTsxoMv3c4sMNanpYW6JXxYqRoR59fI6NOPlGKoioJbm4gs13HAYNtrQWECvh 6zY5598SYu/YcqLDj31yHZh9aK4mqUIrmQ3GoBdSqtpRk2/SrmC7O6VZg525dkJ5pQ+W 3ei+jddSGP7A9iWqLLZPDApDlzqz5DsV1da1UIbhiOO177IKoGXpVt/9b4MAHSwgIc3W kUOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:references:user-agent:from:to:cc:subject :date:in-reply-to:message-id:mime-version; bh=GbW8Hjx15ERhaS/lJ3To1w1HVj+vzejvlbEQZPG02Y0=; b=cEln9nSN58WehSlOkjFHcx8e/C2kb/aIlX7ME7ZiLpyKep100BnrTSW5fHl1/GoYE5 XcU7ktyYeXv+Hj8YFR3BFFIVfGXr1TMjn38WeSgOx+OSsHOvV5U2MkUWJcXphTsUS12f L2SQv0VEpuErB97GFVMseKSB9NxzmgD0uePvcBZfcbUgYH+pexU/KVC0vLPpY0qL1fpE FzTwLCO67Tv+scmF9yL4UuOfT2suzaF6fsP45AKJOmKesv8co7a3NenmFJD6hYuMUCip eOh8FVBeU158fLB4bP0u64Kg2vA0ej+wLesuRg1Lf5p6q8RJG3Agmoet8Ifo0Er++nUF k4iQ== X-Gm-Message-State: AOAM533Xhvq9tdQyRvk87kr9WNoHc4hmNmax1a6U+qNhA9oMsNmhfKuJ NFv2WdAdBPCh8OfgZhyOkR24yOgNEwuFzQ== X-Google-Smtp-Source: ABdhPJzacVMOmNEAMDQgqEptZKka6ZHZ5BSESM+nqvKFIKW+mwCHYCO0REsrunnLedS/dJEJlCPbKQ== X-Received: by 2002:a37:bc7:: with SMTP id 190mr5075497qkl.134.1644765553514; Sun, 13 Feb 2022 07:19:13 -0800 (PST) Received: from Johns-iMac.local (full-vpn-1.nat.cmu.net. [128.2.149.108]) by smtp.gmail.com with ESMTPSA id s1sm15545694qkp.40.2022.02.13.07.19.12 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 13 Feb 2022 07:19:13 -0800 (PST) References: <87pmnsjr0i.fsf@vagabond.tim-landscheidt.de> User-agent: mu4e 1.6.10; emacs 28.0.90 From: John Kitchin To: Tim Landscheidt Subject: Re: Possible to robustly embed elisp links in source block table results? Date: Sun, 13 Feb 2022 10:17:29 -0500 In-reply-to: <87pmnsjr0i.fsf@vagabond.tim-landscheidt.de> Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::734 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::734; envelope-from=johnrkitchin@gmail.com; helo=mail-qk1-x734.google.com X-Spam_score_int: 1 X-Spam_score: 0.1 X-Spam_bar: / X-Spam_report: (0.1 / 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.249, PDS_HP_HELO_NORDNS=0.785, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" 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=1644765592; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=GbW8Hjx15ERhaS/lJ3To1w1HVj+vzejvlbEQZPG02Y0=; b=uKaXTSm7mpyWiIL2/GIo9QpYPYpwDcmpQyjJJoc/ClhN7XHkFCjY+KuqubxQfIcdHgncmA AlUm+XI5kHi0bdcHFOFjY59tuwKmyjMquGSNk2lwqBlnBvajNTNHKW4ulf538bu1Rlk+BD S4NebbO0Rc64mIRMAMpBfxlz/kcKytaWC7Mu6Nryyg7QZx11+VcaatO3193h67eU5//fBj nmSuaFmDXCW5ciwTGPd53qGe/GS9hBtmwNWZ60yFmmKxf6zPxPJwHoZSZg+FfZTeaHJiZP 1vghywPA2cM9pmneJ8xhQIF3FV6OtVbqUaocl5P7gxmlMR3HsWp5tupTtCQq8g== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1644765592; a=rsa-sha256; cv=none; b=q8tuf1vfYXanzTLA9hDr2KPdqLeqjXjmi9GDsEmHalO3Ur5ZIvlY7IwAkV+fR2zqh1YEga obnjra7sTghopbicDnD/Dg1EA4QrppUVP7f0o0N7NnQuUG0FsT2cq9DVGORmA39T7zwtWS LSC4Mjx97nA1Dm8DBrHGS2/KLNfaJOzSISPN5CPnRYbjGVzFOprfEa0VlbephbxFEbF33u izC6K+M2anc+XaOpCsHu42nju4u8wXDcuzQLjn6HEa7BAxGYqPQ857HPIgRGAra19OJFJP CXRhQP3cFImdIl9NsDMHJjm8WO7GnYNRkBsbIo/DXrYstPCubsbyQUm3SM1YMw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=b+JPcrHP; dmarc=fail reason="SPF not aligned (relaxed)" header.from=andrew.cmu.edu (policy=none); 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: -1.03 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=b+JPcrHP; dmarc=fail reason="SPF not aligned (relaxed)" header.from=andrew.cmu.edu (policy=none); 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: 543A5EAD0 X-Spam-Score: -1.03 X-Migadu-Scanner: scn1.migadu.com X-TUID: rWLbQw4cxAsJ This is not a complete answer to why this happens, but a practical one that I think is what you want. In the code below I just added | in your jq call to construct the table. I also have to use :results raw to get it to work. The :colnames did not work for me here, so I added the echo line to get column names. It is not beautiful, but it works. #+BEGIN_SRC sh :results raw echo "| column a | column b | column c|\n|-" jq --null-input -r 'range(1; 4) | tostring | [ "| A" + ., "| B" + ., " | [[elisp:(ignore \"" + . + "\")][Do it]] |"] | @tsv' #+END_SRC #+RESULTS: | column a | column b | column c | |----------+----------+----------| | A1 | B1 | [[elisp:(ignore "1")][Do it]] | | A2 | B2 | [[elisp:(ignore "2")][Do it]] | | A3 | B3 | [[elisp:(ignore "3")][Do it]] | Tim Landscheidt writes: > Hi, > > I want org-mode to display a tab-separated values table ge- > nerated by jq that includes elisp links that do something > (differently) for each row, especially containing data that > is not displayed in other columns. > > The source block: > > | #+BEGIN_SRC sh :colnames '(Column\ A Column\ B Column\ C) > | jq --null-input -r 'range(1; 4) | tostring | [ "A" + ., "B" + ., "[[elisp:(ignore)][Do it]]"] | @tsv' > | #+END_SRC > > evaluates to: > > | #+RESULTS: > | | Column A | Column B | Column C | > | |----------+----------+----------| > | | A1 | B1 | [[elisp:(ignore)][Do it]] | > | | A2 | B2 | [[elisp:(ignore)][Do it]] | > | | A3 | B3 | [[elisp:(ignore)][Do it]] | > > which org-mode displays as: > > | #+RESULTS: > | | Column A | Column B | Column C | > | |----------+----------+----------| > | | A1 | B1 | Do it | > | | A2 | B2 | Do it | > | | A3 | B3 | Do it | > > with each "Do it" being a button that, when pressed and con- > firmed, executes ignore. Great! > > Executing Emacs Lisp: > > | (org-insert-link nil "elisp:(ignore \"1\")" "Do it") > > results in the org-mode source code: > > | [[elisp:(ignore "1")][Do it]] > > so let's try jq generating that with: > > | #+BEGIN_SRC sh :colnames '(Column\ A Column\ B Column\ C) > | jq --null-input -r 'range(1; 4) | tostring | [ "A" + ., "B" + ., "[[elisp:(ignore \"" + . + "\")][Do it]]"] | @tsv' > | #+END_SRC > > This jq call, executed in a shell, evaluates to the output > (tab-separated): > > | A1 B1 [[elisp:(ignore "1")][Do it]] > | A2 B2 [[elisp:(ignore "2")][Do it]] > | A3 B3 [[elisp:(ignore "3")][Do it]] > > When org-mode evaluates the source block, it strips it down > to: > > | #+RESULTS: > | | Column A | Column B | Column C | > | |----------+----------+----------| > | | A1 | B1 | 1 | > | | A2 | B2 | 2 | > | | A3 | B3 | 3 | > > where "1", "2" and "3" are not buttons or anything else but > plain text, and any other input has been permanently dis- > carded (i. e., is not just not displayed). > > If however I set ":results raw" in the source block: > > | #+BEGIN_SRC sh :colnames '(Column\ A Column\ B Column\ C) :results raw > | jq --null-input -r 'range(1; 4) | tostring | [ "A" + ., "B" + ., "[[elisp:(ignore \"" + . + "\")][Do it]]"] | @tsv' > | #+END_SRC > > org-mode evaluates that to: > > | #+RESULTS: > | A1 B1 Do it > | A2 B2 Do it > | A3 B3 Do it > > with each "Do it" being a button that, when pressed and con- > firmed, will execute (ignore "1"), (ignore "2") and (ignore > "3"), respectively. > > So in the first and third source block, org-mode teases me > that I can embed elisp links in that very nice table format > (first source block) with "complex" Lisp code (third source > block), but when I try to combine the two (second source > block), it slaps me in the face. > > Surely I must be missing some obvious solution? Is there > another syntax I need to use? Do I need to have jq output > the raw columns A, B, D and E and then define a :post source > block that converts that to A, B and C = f(D, E)? > > My alternative and thus benchmark for such "dashboards" that > show "stuff" and offer things to do with it are derivatives > of tabulated-list-mode, but their programming requires de- > finitions of functions & Co. that need to be updated syn- > chronously; an org-mode source block on the other hand just > does what it says on the tin. > > TIA, > Tim -- 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 Pronouns: he/him/his