From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id KAG+BPsrpmSKUAEASxT56A (envelope-from ) for ; Thu, 06 Jul 2023 04:50:35 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id mF/HBPsrpmS1fAEA9RJhRA (envelope-from ) for ; Thu, 06 Jul 2023 04:50:35 +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 7061514618 for ; Thu, 6 Jul 2023 04:50:34 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qHF41-0008Uw-78; Wed, 05 Jul 2023 22:49:49 -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 1qHF3z-0008UQ-Vv for emacs-orgmode@gnu.org; Wed, 05 Jul 2023 22:49:48 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qHF3y-00072f-7M for emacs-orgmode@gnu.org; Wed, 05 Jul 2023 22:49:47 -0400 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-666e64e97e2so203726b3a.1 for ; Wed, 05 Jul 2023 19:49:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688611785; x=1691203785; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=eoau8qsXt2fvEAPfNH7MKuTF+YQNBtX9ZVKiTkHTbng=; b=n3+JTtk7AeG/RhcOiupAjwSIC+h3b7DFm48QTHchnYj/16Uupt/QqnYTiqdAua+Eif tETtnqUT+4FDlwrwJgKa9Xfy71qEMLgjF1aqI1Mhh7Xdm/t6zzBw3/pwIl1mdQJoVbFY bLSNldVEGIb5H/x7aTYL+dGFj41IyBqk0H/HrsWdEzeCkK6J0YrT8ncE2Ioz1ywZsO2A OCpIeMjHQ5NXNAXPChcysioeKbO2+0tBV8rQKiGwi9dNO4duJuYR1eWFQ8JUqtr1NZdv 4x791oyKGuqxnSTJ5WrOO32OZhCgp92QRc5oQA7L2XZ87JIRQiV+v2TSRgRaEubA+cWx 2DnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688611785; x=1691203785; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=eoau8qsXt2fvEAPfNH7MKuTF+YQNBtX9ZVKiTkHTbng=; b=f0Rouq0WByvNRMykddRfKn2iBUD7aD3C5kJHVwzWgN9oqkZQ3x4rjft6/G3zakIts8 cnr/7ieSwepGci6J/qoczsCy0vhSVnT8dah61S+2wUVcOYPQt7Tdlj0/X4hpz38oqlZ2 LSqe/bJu3bJ689pJ6drPVcKzY/XFgStZ7q9vHqoOsv/7/KDZxsL9EGfkU2JhL4od2igP GV5P74Skaq2oSJtDGFvR1nai0zwlb44jIY6xae0Y7kZG6W+KS14ztln9NiV1jux3/Ip6 kFYjkLU7jGtfCDPA6zzUhP8o0piaBTzN3l6cRK/MBk3warmZnEcszESjnoCRXke0f2gv Ab0w== X-Gm-Message-State: ABy/qLaNcQW+4tXZHKN8Gy5uFqme3LgLVUaYevRqZ1nTfHeCaMBt1NaA fKASSf/sN3e4SgZBqZg0NiD6/DXvf+s= X-Google-Smtp-Source: APBJJlH+0uWOV9Gfu4/gW5u/GvaMGj+gk4YSIGRcwWVfgGD8eVnHDbb3yQo87s46mQ7REuKzDUOfoQ== X-Received: by 2002:a05:6a20:4ce:b0:12c:9518:7899 with SMTP id 14-20020a056a2004ce00b0012c95187899mr477120pzd.24.1688611784339; Wed, 05 Jul 2023 19:49:44 -0700 (PDT) Received: from localhost (157-131-78-143.fiber.dynamic.sonic.net. [157.131.78.143]) by smtp.gmail.com with ESMTPSA id c20-20020a170902c1d400b001b85bd8fb3csm180353plc.77.2023.07.05.19.49.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jul 2023 19:49:43 -0700 (PDT) From: Jack Kamm To: Ihor Radchenko Cc: Liu Hui , emacs-orgmode@gnu.org Subject: Re: [PATCH] ob-python: support header argument `:results file graphics' In-Reply-To: <87y1ju8vpp.fsf@localhost> References: <877crh8htb.fsf@localhost> <875y71fcic.fsf@localhost> <877crfvrsf.fsf@localhost> <87v8ez0w41.fsf@gmail.com> <87y1ju8vpp.fsf@localhost> Date: Wed, 05 Jul 2023 19:49:42 -0700 Message-ID: <87sfa121q1.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::42e; envelope-from=jackkamm@gmail.com; helo=mail-pf1-x42e.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, T_SCC_BODY_TEXT_LINE=-0.01 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=1688611834; 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=eoau8qsXt2fvEAPfNH7MKuTF+YQNBtX9ZVKiTkHTbng=; b=pvjKZRA0FRF/Bq4Mruykvjaif72IRksRp9lExrHVrNXzzm+AIH9gde3YFzmZ1caSx4LHAW xd0Fg3qY5b5r/EAMsOawidOIcHIs78XrttV62glnDZq/ghi0sP+xOkr9q0bMlNYFxvh9el d+K7ZdCKtXoRIsVFLbiYMGFUu762WSOcZnQkkAQSw8cy3trwPfpcZax39rHVCipa70NBQK o0RCfK8lPY92eCTF22joarsgi4bTgIsmVSYN3FMSfMqGWuItkFFpMYRvh+T4dQhwlfuOlf yuewOrEK1pB8Z7nhOzVJwouBFMtkXGAbWgCZHkazzh5sTA5EvJzgLWeQvQJ0cg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=n3+JTtk7; 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" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1688611834; a=rsa-sha256; cv=none; b=VZwX5UnfLs+njQPni31mBKGosCXp4YNx/VEMtJCORprbkIQevVcfhM7L53i6iwuXe2e4GF zFZmmB2R/EOeCgdRBzYff2kIuxqCM5EGsA2f7i2o3NtyXjJw1HzMqV6Q/YoOwHmvRowASX W0R7OrGlg4L9hYCIp3jbEWQVJD9pLnru8vb4O073OCacYoSDV+0pJKtB7SAmVit4uRNZXE Uogjihy+hEBJ7PKFcxN5DdWpwV3WyHiSL4dX7bZNzXioNziGCbRSV2vQZpMypwMro1NgIV aP29S3DLxGXFzJufhaY5MNKLBIFldqi/S1CIpxnqcmQy3K43NFUsJAzgrN+iWg== X-Migadu-Scanner: scn1.migadu.com X-Migadu-Spam-Score: -6.44 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=n3+JTtk7; 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: 7061514618 X-Spam-Score: -6.44 X-TUID: DAEysbE4+hCO --=-=-= Content-Type: text/plain Ihor Radchenko writes: > Jack Kamm writes: > >> I think the Worg documentation is accurately describing the behavior of >> ob-python -- it's just that ob-python uses ":results file" in a >> nonstandard way. > > May you please point me to the place in ob-python where :results file is > specially treated? ob-python doesn't treat :results file specially. So "nonstandard" may not be the right term. In fact, :results file also works this way for other Babel languages. And I used this behavior before for plotting with ob-reticulate blocks. I attach a patch to fix the documentation in the manual about this. As an aside: I would like ":results graphics" to partially revert its old behavior before Org 9.3. Prior to then, ob-R could generate a plot with :results graphics :file filename.png but since commit 26ed66b23, we require the more verbose :results graphics file :file filename.png which seems unnecessarily verbose (since ":results graphics" doesn't do anything without ":results file"), and also annoyingly broke many of my Org documents before 2020. I think it would be better if ":results graphics" was equivalent to ":results graphics file", and may propose a patch for this in future. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-doc-org-manual-Clarify-undocumented-uses-of-results-.patch >From 538c464ca88c8a1646a1b80352f0c8fb9f114f08 Mon Sep 17 00:00:00 2001 From: Jack Kamm Date: Wed, 5 Jul 2023 19:02:25 -0700 Subject: [PATCH] doc/org-manual: Clarify undocumented uses of :results file (Type): (Format): Document that :results file is using the source block result as file path when :file header argument is not present. Document that some Babel languages require :results graphics for plotting. --- doc/org-manual.org | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/doc/org-manual.org b/doc/org-manual.org index 71ad4d9e8..3bf1c7d7f 100644 --- a/doc/org-manual.org +++ b/doc/org-manual.org @@ -18558,11 +18558,7 @@ described in the documentation for individual languages. See #+cindex: @samp{file-ext}, header argument If =file= 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 =file-ext= header argument. In that case, both the name - and the extension are mandatory. - - Result can also be interpreted as path to file. See =:results - link=. + from the =file-ext= header argument. #+begin_example ,#+name: circle @@ -18572,6 +18568,30 @@ described in the documentation for individual languages. See ,#+END_SRC #+end_example + If both =file= and =file-ext= header arguments are missing, then + result is interpreted as path to file. + + #+begin_example + ,#+BEGIN_SRC python :results file + import matplotlib.pyplot as plt + import numpy as np + + fname = "path/to/file.png" + + plt.plot(np.arange(5)) + plt.savefig(fname) + + return fname # return filename to org-mode + ,#+END_SRC + #+end_example + + When =file= or =file-ext= header arguments are present, you can + prevent Org from directly writing to that file by using =:results + link= or =:results graphics=. This might be desirable if you write + to the file within the code block itself. Some Babel languages also + require these extra header arguments for plotting. See =:results + link= for more details. + #+cindex: @samp{file-desc}, header argument The =file-desc= header argument defines the description (see [[*Link Format]]) for the link. If =file-desc= is present but has no value, @@ -18644,8 +18664,11 @@ follows from the type specified above. [[file:org-mode-unicorn.svg]] #+end_example - If =:file= header argument is omitted, interpret source block result - as the file path. + =:results file graphics= is also needed by some languages for + plotting, such as ob-R, ob-julia, and ob-octave, because they save + plots to file via wrapper code in their respective languages rather + than via elisp. Consult the documentation for the respective Babel + languages for more details. - =org= :: -- 2.41.0 --=-=-=--