From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.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 8N7aBYElpWQcTAEASxT56A (envelope-from ) for ; Wed, 05 Jul 2023 10:10:41 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id 8FT3BIElpWSogQAAG6o9tA (envelope-from ) for ; Wed, 05 Jul 2023 10:10:41 +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 713FDB633 for ; Wed, 5 Jul 2023 10:10:40 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGxa7-00013X-5q; Wed, 05 Jul 2023 04:09:47 -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 1qGxa2-00013K-Qq for emacs-orgmode@gnu.org; Wed, 05 Jul 2023 04:09:43 -0400 Received: from mail-oi1-x22c.google.com ([2607:f8b0:4864:20::22c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGxa0-00061L-Ok for emacs-orgmode@gnu.org; Wed, 05 Jul 2023 04:09:42 -0400 Received: by mail-oi1-x22c.google.com with SMTP id 5614622812f47-3909756b8b1so3353895b6e.1 for ; Wed, 05 Jul 2023 01:09:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688544578; x=1691136578; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=15a+uFw76NPh3Dm2FzYOgoFWJ6cCozEG3hbTn9EypIU=; b=diLtpYIG81p9EuRlU+gx0Di0DScNkanT0L3+OWQMzJ4vBDABuM4kFPEoxbgj6LPeEI vrJlp6YTTCG6M7GDR/NC+c1rhRGsJTsZcHwdp+J8zVN74xMh5v/GE5I0CNEjYXrLq2mr ErEyYTxYdf8Hy16iiUK5ZveKV/ZQqOpmdStMz74xY/AdHdEHo+DSemGXt6cns3uC0d2d VlTDmJM+RSGH4W60LBh7Qz8RupgYdwiVcgreSMmNvGhOQUn9LOb7ITzXGjH1sHo7eOYQ XKi7gnJiYU2CNKGh6zjeCroXTx2p5OnB9kV7AAZgmMpUuKz+Qop1+rGKh+goep31wTSL +BaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688544578; x=1691136578; 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=15a+uFw76NPh3Dm2FzYOgoFWJ6cCozEG3hbTn9EypIU=; b=E05rGYQvw1uUP2kStI4M3W4XogCrMkZ69bDS0COvhnzirCz+ArSKn46JMOZlcvOQfw KnmQTazAeOxZfQHAWaOZeI2rf5DG4Y4te356H0Zqswj51Vqxlnrk/5CTJjcM8K8gPCgc iaPSxI6WY6t1wkQHfY0FNu6QZC5Tx0CjZdc/a2dYKJlXxlkCO4WBeKtuxQUih97ee5UH AnMUH26TONxcgsY2qHHYP7jM/Lmv+RH4x3JsxRRg326ukUqG77mF4TehN+roYYYTf6jA /mNfpfSkPtOGND7Vi2ZULIT3HtIqWmHQPpUQzG/TOIENSF5mkSdN5L3PS4z1k/EAOhLD I1Lw== X-Gm-Message-State: AC+VfDy3m8c24cS3vpp8NIhLEWXUMCXEwyh6jb6iSMXuoNyuaJG0qSaG uADnrleXMGqn8GHHu9mDIVAbvLHQYQUM+h7HT3Y= X-Google-Smtp-Source: ACHHUZ56E/YRuSSYYLAL6T9SB1Ay4YniJ0IxuDGj3WDJJMaYwyCas8/Uh1bLQvnG51sS5E3jEXYWwIE77OUreZEjEHU= X-Received: by 2002:a05:6808:19a6:b0:3a1:d3a2:5cd4 with SMTP id bj38-20020a05680819a600b003a1d3a25cd4mr13348414oib.18.1688544577836; Wed, 05 Jul 2023 01:09:37 -0700 (PDT) MIME-Version: 1.0 References: <877crh8htb.fsf@localhost> <875y71fcic.fsf@localhost> <877crfvrsf.fsf@localhost> In-Reply-To: <877crfvrsf.fsf@localhost> From: Liu Hui Date: Wed, 5 Jul 2023 16:09:26 +0800 Message-ID: Subject: Re: [PATCH] ob-python: support header argument `:results file graphics' To: Ihor Radchenko Cc: Jack Kamm , emacs-orgmode@gnu.org Content-Type: multipart/mixed; boundary="000000000000bfef4905ffb8eb38" Received-SPF: pass client-ip=2607:f8b0:4864:20::22c; envelope-from=liuhui1610@gmail.com; helo=mail-oi1-x22c.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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_ENVFROM_END_DIGIT=0.25, 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-Seal: i=1; s=key1; d=yhetil.org; t=1688544640; a=rsa-sha256; cv=none; b=bOva61aoO0+YSA5TdqConqGdKMs0cDlNBiF32Bkt4JOJ3kse+AXsPkNSiyQ0O0rHt8iu4x UYTfBnnI5Je1giLLzLu0KDKIPlnFJcbpH3zxTHsecRi3Vg69DPxSupdwAMm3RLKWAgaawY /aHsT/VLZarh4gyXKQPIgD9jPvwNWPhbXVmByAf7U06vYLTLBfXx0la5JGyGWBsn2x1GO5 KT+GkLsYI4W9K/grWrG4tsKa9jm7xnH3SJhRoxgQBalFAaCQtIPMWuPQa/klItBvDHQZRy nwY8DCvVVdnvYVdBzn2X0+mumv/ph4Ro3ZMGMvvqRZUFeiav3ED272zNvUOCnw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=diLtpYIG; 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-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1688544640; 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=15a+uFw76NPh3Dm2FzYOgoFWJ6cCozEG3hbTn9EypIU=; b=fM826zQkuGKAV1Om5y8q3iwaS2j5E2aypFAExZAUBoMoTxAIe1HuZVp0S+6YLchVDFFfmM 6DZTPgsCJq2RgVGlmCgXi+qK0r3ayftIq+CSTp9pOWz5YQoCQlwrkTN1YEpLiEcouBLX9R tZDQK1JmwAoaI0FZgceyE/t58eVLLh3w6Mp+1hsr15ROl7fmF9z0gnPkl9ynXoD2wtuP7u Ax+VzjvUFmj/n6J5XK55aQWWzLt0ekdZmHnn1UCm2RpzXTaDuCkEdYeuX4BueZIAvwm09/ k5lbV0pA3jXPz/yHTwfED/Imhcdc5q82iRSj5wLpUeyTcf3uDYe0+ck0yprzrg== Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=diLtpYIG; 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-Scanner: scn0.migadu.com X-Migadu-Spam-Score: -5.33 X-Spam-Score: -5.33 X-Migadu-Queue-Id: 713FDB633 X-TUID: /AoYwhV83iTk --000000000000bfef4905ffb8eb38 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Ihor Radchenko =E4=BA=8E2023=E5=B9=B47=E6=9C=884=E6= =97=A5=E5=91=A8=E4=BA=8C 19:29=E5=86=99=E9=81=93=EF=BC=9A > That said, your patch should still work fine even with these > considerations. But we may need to sort out this undocumented behaviour. > Probably, an error like in `org-babel-graphical-output-file' should be > thrown by `org-babel-generate-file-param'. Yes. The main concern is that some users may rely on the undocumented behavior. > What about > > #+begin_src python :file "test.png" :results graphics file > import matplotlib.pyplot as plt > plt.plot([1,2,3,4,5]) > plt.savefig('test.png') > plt.plot([5,4,3,2,1]) > plt.show() > #+end_src OK, I think that it is better to turn off the feature by default and I have updated the patch. Inspired by ob-R, some extra header arguments are supported. Thanks. --000000000000bfef4905ffb8eb38 Content-Type: text/x-patch; charset="US-ASCII"; name="0001-ob-python-Graphics-output-enhancement.patch" Content-Disposition: attachment; filename="0001-ob-python-Graphics-output-enhancement.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_ljpftyda0 RnJvbSA1ZjNmYzg2MDJjMGViMWY2ZDBjMDcyYmQwYzFhNmJiODgzYjhjOWY5IE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBMaXUgSHV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