From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id IJBGMe6RB2KllgAAgWs5BA (envelope-from ) for ; Sat, 12 Feb 2022 11:54:38 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id yDd3Lu6RB2L2XwAA9RJhRA (envelope-from ) for ; Sat, 12 Feb 2022 11:54:38 +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 6CD1D2014E for ; Sat, 12 Feb 2022 11:54:38 +0100 (CET) Received: from localhost ([::1]:49162 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nIq33-00082p-2j for larch@yhetil.org; Sat, 12 Feb 2022 05:54:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54628) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIq1Y-00082f-M2 for emacs-orgmode@gnu.org; Sat, 12 Feb 2022 05:53:04 -0500 Received: from ciao.gmane.io ([116.202.254.214]:51564) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIq1T-0001cx-P0 for emacs-orgmode@gnu.org; Sat, 12 Feb 2022 05:53:01 -0500 Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1nIq1P-00012q-Ql for emacs-orgmode@gnu.org; Sat, 12 Feb 2022 11:52:55 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: emacs-orgmode@gnu.org From: Tim Landscheidt Subject: Possible to robustly embed elisp links in source block table results? Date: Sat, 12 Feb 2022 10:52:45 +0000 Organization: http://www.tim-landscheidt.de/ Message-ID: <87pmnsjr0i.fsf@vagabond.tim-landscheidt.de> Mime-Version: 1.0 Content-Type: text/plain User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) Cancel-Lock: sha1:rjW7uORjvWVpzcRk0PYSoe9Ln/M= Received-SPF: pass client-ip=116.202.254.214; envelope-from=geo-emacs-orgmode@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.249, 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: , 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=1644663278; 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; bh=9rPHlKlGKoa/g7bj0tmRO/YoMqVVQ5EWx3z6/tJMB6E=; b=BBjh2BpQb4LYEHVDp/N7qyZgyPR763Po8zuj7ytNt8ti4uweAGrQwwnjT89E94S7l5IFXO 8ULDWRXSxB0KaULS3CP7IZeKOl2uxBFTNDGIEUT6gg2AAFonnMLam1AccUxxaNFvNNfh/i xqMRw3o6JE68uPB7VeK/hIZztd8QU+ppzVjej+CbbwsVvZ0E7W3mN8UV9uO9qETo5HhlVq ILY5Xz0F1OfH0YkVXtXwOr808kEtbcdmoU5eVXGhIG1drhRRF3MOXNzQpr7S19rxwELx8x X/3hN+wOrM9k5bOmMkRIH0NI79b+74aEVSM5KZ67qG4SmX7X6lAEC/nqEocpow== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1644663278; a=rsa-sha256; cv=none; b=O8vtBVVVm6gpH+aTm4DBfc8cuDYJ4MxsEB4lYqAgRtMFacAEVs2eU6eJvu3VZEVONqfMEF BRfa+Qf8GnXxcR533rQa+jTcwQVlzKi8cqb3HO2P9N9xIklZKxVYsXBFCLmRf89D1XeLSU 4JDzlqAfhs8NdB/13WAuH4Ze7Kvru7NKFXd82WjyBjjtv7dycF8Gi/Q18JXeOzWF3DVXVq naB/cXs6A5lfmDCdqWK08171GsRuaTHVx2jk+Tg1f9VtzjI3UbqPGduYAqzj+PlIpUSUwC 5x6DdYNs1cUJCY47FC6yY9djS0NlkenBhln10CevF312/qOwbpW26XrG79rH5w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=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.63 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=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: 6CD1D2014E X-Spam-Score: -1.63 X-Migadu-Scanner: scn1.migadu.com X-TUID: NyI0UN5B2g/4 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