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 ms5.migadu.com with LMTPS id uFXrOH/9omOBYgAAbAwnHQ (envelope-from ) for ; Wed, 21 Dec 2022 13:35:11 +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 0LzuOH/9omPI6wAA9RJhRA (envelope-from ) for ; Wed, 21 Dec 2022 13:35:11 +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 7CA881DE60 for ; Wed, 21 Dec 2022 13:35:11 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p7yIr-0008GO-6i; Wed, 21 Dec 2022 07:34:33 -0500 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 1p7yIp-0008Fu-IO for emacs-orgmode@gnu.org; Wed, 21 Dec 2022 07:34:31 -0500 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p7yIn-00071l-9X for emacs-orgmode@gnu.org; Wed, 21 Dec 2022 07:34:31 -0500 Received: by mail-wm1-x336.google.com with SMTP id z8-20020a05600c220800b003d33b0bda11so2500189wml.0 for ; Wed, 21 Dec 2022 04:34:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=l8XZ2iz3H5Zz14M4kvETLSUvpa48W3uJMeaSt2MdE/E=; b=ij3pLG8hX51HkV18pad17BLD3U1D0239ZF1Lwg6TGLGcoEwlj6KZZyA/9qRhLJDL0S Cx2qXCO8xR7Bm8az/nXYajEMgo58kvM/wbDV7FpgJU4KfwSZ0XgBtgvBUFqGojcnlxbd BTg2LD+I6aDrzO8h6BJjfW3KsMQlzASxUNQTrq5loOnN/EF7e5WNRnVvfLWUO3VtAWiW tB1RfYFKLHzzbao5+eyWoOehxePQy7d6tnkMoSNXhIJF8g1pI0PMdtxq92+OoWegGgdV oCwsbci4aB3wvbdYwNs6PSJx+a1uIZLwCGAlOyRyE7B+yf9XpMwhu/BdBu4TeIgbQhpg fIuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=l8XZ2iz3H5Zz14M4kvETLSUvpa48W3uJMeaSt2MdE/E=; b=l9mog+QRHkjcSun2uQZpu/fsGLzlLLTQT9Fif81IrSfXHl+i7GKHX6qEZEoeEQR9PK weFIxvkUVw2Qnd/LzP87BXyXacAZkR/Ly3dIWEdIO1zwg6uZ9sPwfzkI0UwpzwncvQR4 fKYSZmncuizuIFWL+29mQhlvHDSXs07YrSpgxNSKkdEjIe7gOyEkGS6hQnteuBoxBq75 RdR75K6v/AituqQ9hjYo4il5RYnUS9nm0VKkNa4yTSxdZAFxYIZHYE8/ixzy9qXjONNl hDcJx+R09VQEpoMlDk8wXNXZ+imYNHalTn9JX3MwRw4bJcsPBI+RSLvmlvU3GHnaouGQ Sglw== X-Gm-Message-State: AFqh2kr66Ckqi2jjkCR/WPn9Evcxdsfoygk+hJsM/NHHEOvAzM4kzvur 098E1XDi9QwMknXUjtb6QN7/G6xhZAPaOXC5ZGQ= X-Google-Smtp-Source: AMrXdXtOSTSgxG02m3aKVL/QuDuphs5vblbuCoCs7OYmR6/SZa7RLzXEpkjtqGjhjtYjK/Xf8RwUYDcOKzhQdCDMCa0= X-Received: by 2002:a05:600c:4256:b0:3d0:8ae4:2eb8 with SMTP id r22-20020a05600c425600b003d08ae42eb8mr87766wmm.56.1671626067041; Wed, 21 Dec 2022 04:34:27 -0800 (PST) MIME-Version: 1.0 References: <87mt7k7uph.fsf@localhost> In-Reply-To: <87mt7k7uph.fsf@localhost> From: dalanicolai Date: Wed, 21 Dec 2022 13:34:15 +0100 Message-ID: Subject: Re: [FR] Add support for racket images in org-babel To: Ihor Radchenko Cc: emacs-orgmode@gnu.org Content-Type: multipart/alternative; boundary="000000000000ec612505f055c586" Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=dalanicolai@gmail.com; helo=mail-wm1-x336.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, HTML_MESSAGE=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: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1671626111; 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=l8XZ2iz3H5Zz14M4kvETLSUvpa48W3uJMeaSt2MdE/E=; b=vDt7e6nVHNj9IylybGG6r15OpOQ7265FCV25224USz86sXYcHHu72AwkeB+sNrhvwjma4e IgkV1Vd2cmzO+JkkRFegeOWV7tbPnX9i83qL0qd+s0dXsGvY4FwknzES6dRkvjDmPVR5G/ 34Jtw188XQwHIhi6JpwFXZmsZrkzEWoBkg10vmybPnQ+VrIDteGTHbfQi4J2dkChiN2QGC PfbjYHN+MAoYIyE6jdfDSRgn3D0tt9QfNEOG4a4O2cfo9JIw+1DIwYbA8MlQ8pWx+z3zXF oB8+0Vh821fsmy60qlGzsBrgVPvrnf9PAz3IJ6ImucU0uoMzn9/fK/G76+jFyg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=ij3pLG8h; 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"; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=key1; d=yhetil.org; t=1671626111; a=rsa-sha256; cv=none; b=ma/VMe5iC4YPtqmxxzqMaiDU7thwg6D2yEwwaV08BJsN879877AWC2ZctbN/mjap/iI/US H+fCn4fQLkpMMhmhHZ8SoEtoDdXA0zjUJXV+n33Lhk4RZTwd8LSHYlJvbXIGLE4xZBr2gI gyCnX30hh3kQK39CLzABnAzD2yx4fK1+mOD6ijccSNerCw0TONJ+tIk7iVxLJ9YAZGcd9y vOp5STiP80qRA4zgOqVFlE2GVtyGPmq0SZhSMd7ttJsAVwZ75TI7sZtaftYPzbs/tGXxZR ng40HAp3OWD8kS9BSk8tES8YfqTVr39F2rDLhmQDm17u9lA1ElAX5rlq4/CBXQ== X-Spam-Score: -6.03 X-Migadu-Queue-Id: 7CA881DE60 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=ij3pLG8h; 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"; dmarc=pass (policy=none) header.from=gmail.com X-Migadu-Scanner: scn1.migadu.com X-Migadu-Spam-Score: -6.03 X-TUID: 4paHoE86W+8I --000000000000ec612505f055c586 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thanks for your answer! > You likely need to extend `org-babel-scheme--table-or-string' to > understand Image: type. > It looks to me that when `org-babel-execute:scheme` gets executed, then the result will not get inserted as a link, as that would require the results type 'file', right? >From the manual , it seems to me that using the 'file' type is required to get the result inserted as a link. However, I can not see how the code does the following as explained in the manual. The manual states (under Type/file): > If =E2=80=98file=E2=80=99 header argument is missing, Org generates the b= ase name of the > output file from the name of the code block, and its extension from the = =E2=80=98 > file-ext=E2=80=99 header argument. In that case, both the name and the ex= tension > are mandatory. > suggesting that a file gets written also when there is no :file header argument. But from the `and` condition here in `org-babel-execute-src-block`, it looks to me that a file is only written when a :file argument is provided (via the `with-temp-file` that follows within the 'when file ...'). Anyway, this I only found when trying to find out how the result gets formatted as a link. I guess to get the racket `Image` file-path to formatted correctly, it would be preferable to only touch ob-scheme for that. In which case, I think the 'result' under 'org-babel-result-cond' at the end of 'org-babel-execute:scheme' should get (re)formatted conditionally (when the results is a racket image (link)). So in the end, I conclude that maybe the advice as mentioned in my 'original' mail, might be already the 'cleanest' solution (and that it does not cause any problem concerning a file getting written to disk, as luckily, org does not seem to write files when no :file header argument is given). Anyway, I am struggling to find out how to come up with an alternative clean(er) solution. On Sun, 18 Dec 2022 at 13:38, Ihor Radchenko wrote: > dalanicolai writes: > > > I have not asked anywhere yet, but I do not know a 'standard org-mode' > way > > to make org-mode show the plot images. Racket creates a temp image file > and > > returns a string that includes the path to the file. The actual format = of > > the string is: > > > > "\"#\"" > > > > I could create a patch for it, but I am not sure how to best implement = it > > (in a clean way). > > You likely need to extend `org-babel-scheme--table-or-string' to > understand Image: type. > > > however, it would be great if support could be added to ob-scheme itsel= f. > > I would be happy to do it, but as mentioned before I don't think I know > how > > to do it in the proper way. I would probably just add a condition aroun= d > the > > 'result' in 'org-babel-execute:scheme' as follows: > > I do not know much about scheme. > > Generally, ob-* libraries try their best to convert native language > types to Elisp. If # is something that is unambiguously > identified as image file, I do not see why we cannot support it, > converting the # representation to file link. Especially, > when users request :results file. > > -- > Ihor Radchenko // yantar92, > Org mode contributor, > Learn more about Org mode at . > Support Org development at , > or support my work at > --000000000000ec612505f055c586 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thanks for your answer!
=C2=A0
You likely need to extend `o= rg-babel-scheme--table-or-string' to
understand Image: type.

It looks to me that when `org-babel-execute:scheme` gets e= xecuted, then the result will not get inserted as a link, as that would req= uire the results type 'file', right?
From the manual, it seems= to me that using the 'file' type is required to get the result ins= erted as a link.

However, I can not see how the co= de does the following as explained in the manual.

= The manua= l states (under Type/file):
If =E2=80=98file=E2=80=99 header argument is = missing, Org generates the base name of the output file from the name of the code block, and its extension from the =E2=80=98file-ext=E2=80=99 header argument. In that = case, both the name and the extension are mandatory.
suggesting that a f= ile gets written also when there is no :file header argument.
But from the `and` condition
dalanicolai@gmail.com> writes:

> I have not asked anywhere yet, but I do not know a 'standard org-m= ode' way
> to make org-mode show the plot images. Racket creates a temp image fil= e and
> returns a string that includes the path to the file. The actual format= of
> the string is:
>
> "\"#<Image: /var/tmp/geiser-img-16711484841671148484684.p= ng>\""
>
> I could create a patch for it, but I am not sure how to best implement= it
> (in a clean way).

You likely need to extend `org-babel-scheme--table-or-string' to
understand Image: type.

> however, it would be great if support could be added to ob-scheme itse= lf.
> I would be happy to do it, but as mentioned before I don't think I= know how
> to do it in the proper way. I would probably just add a condition arou= nd the
> 'result' in 'org-babel-execute:scheme' as follows:

I do not know much about scheme.

Generally, ob-* libraries try their best to convert native language
types to Elisp. If #<Image: ...> is something that is unambiguously identified as image file, I do not see why we cannot support it,
converting the #<Image: ...> representation to file link. Especially,=
when users request :results file.

--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,=
or support my work at <https://liberapay.com/yantar92>
--000000000000ec612505f055c586--