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 +OE9EMilomQ9RAEASxT56A (envelope-from ) for ; Mon, 03 Jul 2023 12:41:12 +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 QNA+EMilomRV/QAA9RJhRA (envelope-from ) for ; Mon, 03 Jul 2023 12:41:12 +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 E01D937047 for ; Mon, 3 Jul 2023 12:41:11 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGGyu-0005Cf-SK; Mon, 03 Jul 2023 06:40:32 -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 1qGGyt-0005AN-ME for emacs-orgmode@gnu.org; Mon, 03 Jul 2023 06:40:31 -0400 Received: from mail-oi1-x22d.google.com ([2607:f8b0:4864:20::22d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGGyr-0006PB-Qu for emacs-orgmode@gnu.org; Mon, 03 Jul 2023 06:40:31 -0400 Received: by mail-oi1-x22d.google.com with SMTP id 5614622812f47-3942c6584f0so2779490b6e.3 for ; Mon, 03 Jul 2023 03:40:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688380828; x=1690972828; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=a6ImwUFdPaKSRXJ2OkoxQj14rHuR+9NisRaFp+lVgd8=; b=lQZ0lyNNfuCGcnBvZzl1YTs+R1jde/vuo+a8K3Z/odxr0+8zQIs82Pqf9KKS5ftr3u Gjv3mAdK8SxxQ/NSLBb1VJeFFW1Is0eMBVvt7mpgWQTEwXJha45SxvjHUnm2zBgAepPU ZsePijnqp8ThebIqiwu+rY4UTNbswOSuaDLFnKeJnGD0De0D5DeCOYAvJmM9fanDvzzG o9Sk8js8NRl4yusN4QRwj6+eWUgj5P5FivwJ0ZmrJJbT608RvGutnaNyAcYIhAg4H5iU 6GemEridfZwVXNZa0aBSwYVy7ROGJfUZqMh0Z6Uon+UVgdBAOZIfj63ddUPq5yzwRKm3 X2ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688380828; x=1690972828; 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=a6ImwUFdPaKSRXJ2OkoxQj14rHuR+9NisRaFp+lVgd8=; b=W+ZwmNDR3PPo/s7knWHA8GaBG50Ou9u+PqOP7qWOFqtRityTD1abvQxWdJoE7hEE90 5oC7/+CY72A6Bg6tz4PPUfT1fiYlTH9uU25ApGobUeVKayDpFDxe1L8tofyWvYTeCLPC m7Y82Th8iXlNDAiqTNSbIC/uDansqgQ6b2NGKPjlwMrlzXPqtlqDYwgr+8JeBIx74ITH +Y7rDSgcZSAV6I7PHZlHtCMLgGbJSsRiI537qEwXv4Q+ByqciYQiGbpSHZVxHJFT1i08 fxTFSgSS2z2rftRZ+4I+rTy1xWTOhmHrwXSJoDGz/0XZ91IsP0dLQ54w760kWGo319hG dH6A== X-Gm-Message-State: AC+VfDwLwZEpBxsc8+0XR03cnGrR4F4927/YBvK4+BmnMbrARHCjb3hE D+3SlXTbhxAyHxW5QPYCx+Ew+26AUlVu5cnxJ/c= X-Google-Smtp-Source: ACHHUZ7nY0rvo/f8dljNUyE5qd0Je08gXAfpcYoqJs5coQ3j3cfcsY9i9Dpr591WXc9IB3uUW+/JpEeTObSyavEKOh4= X-Received: by 2002:a05:6808:1895:b0:3a1:e796:d961 with SMTP id bi21-20020a056808189500b003a1e796d961mr10916088oib.2.1688380828621; Mon, 03 Jul 2023 03:40:28 -0700 (PDT) MIME-Version: 1.0 References: <877crh8htb.fsf@localhost> In-Reply-To: <877crh8htb.fsf@localhost> From: Liu Hui Date: Mon, 3 Jul 2023 18:40:16 +0800 Message-ID: Subject: Re: [PATCH] ob-python: support header argument `:results file graphics' To: Ihor Radchenko Cc: emacs-orgmode@gnu.org Content-Type: multipart/mixed; boundary="00000000000089349605ff92cbe7" Received-SPF: pass client-ip=2607:f8b0:4864:20::22d; envelope-from=liuhui1610@gmail.com; helo=mail-oi1-x22d.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-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1688380872; 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=a6ImwUFdPaKSRXJ2OkoxQj14rHuR+9NisRaFp+lVgd8=; b=mTiq2fv06C/yDMPOvnLVfCMEcEv1+38+EMAaUx9KuJGGKRrW7PIGvNRRx2lasFsEw/27Fe BMNRGZl8PahKDFlZoG4s8vq0QDAtGeAWc7eX1YZ7AJxPlf02WzZX9jaM3DDtU/hR0wc/CS b/g9MFEmkYSRiB/Z7tV7oMAEe4RM5dCMbhcNOyHwFGMNNo8/lwJNE9hw5XwVS2MIXR+0gf IhqX5+EOjDBasW4kdmyVlT0pyg83Y7ZTV4WBCRMOMrYgmH70mge9ls2+eZ1vLuOoAx9hDB s20vuC9XYxIjfAILdhGgXJ4ZMBGJ3FvwWsl3dZN7HrmWJdYUOeBwYhvPFWFsZA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=lQZ0lyNN; 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=1688380872; a=rsa-sha256; cv=none; b=ncRtmfyqjqfEaw3xpvK3qyBhUrBEYGL4xIaFAdKgBEA+K89NDkbfu25KWTUYn7GiIEApfb g+rbsvmCLcR+WCH+cKnLETRwhvKyILNoM2ZudLT0IRlr2i4ypZBnEPKdJTELtnRi/kSga1 SvLxxyjUJW9UgjfDFhzfJXb6YSfhQghR+H/s0/y8RA6WX8IZjrED1sPxNw651DHgxe223o WWi4NcQOkQviuonKPKdwoTkXfNJGHdvG92rqbd9Dk9E26UkVqikPDSqTXpq7uG5HTw3oqM WVSgTaQmzL3dB37BZehQApIFCKGGeW0NwlCav0/geWtm3TIVOyHf3SVADlT1Mg== X-Migadu-Scanner: scn1.migadu.com X-Migadu-Spam-Score: -5.33 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=lQZ0lyNN; 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: E01D937047 X-Spam-Score: -5.33 X-TUID: rJQqhuGHBOqQ --00000000000089349605ff92cbe7 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Ihor Radchenko =E4=BA=8E2023=E5=B9=B47=E6=9C=883=E6= =97=A5=E5=91=A8=E4=B8=80 17:28=E5=86=99=E9=81=93=EF=BC=9A > This might be a useful feature, but it will break the existing > conventions, if used as in the patch. Currently, the above combination > of :file and :results is treated as the following: > > =E2=80=98graphics=E2=80=99 > When used along with =E2=80=98file=E2=80=99 type, the result is a li= nk to the file > specified in =E2=80=98:file=E2=80=99 header argument. However, unli= ke plain =E2=80=98file=E2=80=99 > type, code block output is not written to the disk. The block is > expected to generate the file by its side-effects only, as in the > following example: > > #+begin_src shell :results file link :file "org-mode-unicorn.sv= g" > wget -c "https://orgmode.org/resources/img/org-mode-unicorn.s= vg" > #+end_src > > #+RESULTS: > [[file:org-mode-unicorn.svg]] > > If =E2=80=98:file=E2=80=99 header argument is omitted, interpret sou= rce block > result as the file path. I have updated the patch and =E2=80=98:file=E2=80=99 header argument can be= omitted now, e.g. #+begin_src python :results graphics file import matplotlib.pyplot as plt plt.plot([1,2,3,4,5]) plt.savefig('test.png') return 'test.png' #+end_src In this case, `graphics' can be removed too. > What if the user wants to use, for example, pyplot instead of > matplotlib? pyplot is a module of matplotlib. If you mean users want to use other graphics libraries, they may advise `org-babel-python-save-graphics' if they want to use `graphics' in the header argument. If necessary, ob-python may support such libraries too. --00000000000089349605ff92cbe7 Content-Type: text/x-patch; charset="US-ASCII"; name="0001-ob-python-support-header-argument-results-file-graph.patch" Content-Disposition: attachment; filename="0001-ob-python-support-header-argument-results-file-graph.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_ljmqbshu0 RnJvbSA4ZWE2OWQ2NjU1MmVlMDIxN2I3ZjVjODA4OWI5MTQyNGI5MmMzYjVhIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBMaXUgSHVpIDxsaXVodWkxNjEwQGdtYWlsLmNvbT4KRGF0ZTog TW9uLCAzIEp1bCAyMDIzIDExOjEzOjU4ICswODAwClN1YmplY3Q6IFtQQVRDSF0gb2ItcHl0aG9u OiBzdXBwb3J0IGhlYWRlciBhcmd1bWVudCBgOnJlc3VsdHMgZmlsZSBncmFwaGljcycKCiogbGlz cC9vYi1weXRob24uZWwgKG9yZy1iYWJlbC1leGVjdXRlOnB5dGhvbik6IFNhdmUgY3VycmVudCBm aWd1cmUgdG8KZmlsZSB3aGVuIHRoZSByZXN1bHQgdHlwZSBpcyBgZmlsZSBncmFwaGljcycuCihv cmctYmFiZWwtcHl0aG9uLXNhdmUtZ3JhcGhpY3MpOiBOZXcgaGVscGVyIGZ1bmN0aW9uIHRvIGdl bmVyYXRlIGNvZGUKdG8gc2F2ZSBncmFwaGljcy4KLS0tCiBsaXNwL29iLXB5dGhvbi5lbCB8IDIw ICsrKysrKysrKysrKysrKysrKysrCiAxIGZpbGUgY2hhbmdlZCwgMjAgaW5zZXJ0aW9ucygrKQoK ZGlmZiAtLWdpdCBhL2xpc3Avb2ItcHl0aG9uLmVsIGIvbGlzcC9vYi1weXRob24uZWwKaW5kZXgg MGUwNTM5ZDdhLi42ZWU1MjMxM2MgMTAwNjQ0Ci0tLSBhL2xpc3Avb2ItcHl0aG9uLmVsCisrKyBi L2xpc3Avb2ItcHl0aG9uLmVsCkBAIC03Miw2ICs3Miw5IEBAIChkZWZ1biBvcmctYmFiZWwtZXhl Y3V0ZTpweXRob24gKGJvZHkgcGFyYW1zKQogCQkgICAoY2RyIChhc3NxIDpzZXNzaW9uIHBhcmFt cykpKSkKICAgICAgICAgIChyZXN1bHQtcGFyYW1zIChjZHIgKGFzc3EgOnJlc3VsdC1wYXJhbXMg cGFyYW1zKSkpCiAgICAgICAgICAocmVzdWx0LXR5cGUgKGNkciAoYXNzcSA6cmVzdWx0LXR5cGUg cGFyYW1zKSkpCisgICAgICAgICAoZ3JhcGhpY3MtZmlsZSAoYW5kIChtZW1iZXIgImdyYXBoaWNz IiByZXN1bHQtcGFyYW1zKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoaWdub3JlLWVy cm9ycworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChvcmctYmFiZWwtZ3JhcGhpY2Fs LW91dHB1dC1maWxlIHBhcmFtcykpKSkKIAkgKHJldHVybi12YWwgKHdoZW4gKGVxIHJlc3VsdC10 eXBlICd2YWx1ZSkKIAkJICAgICAgIChjZHIgKGFzc3EgOnJldHVybiBwYXJhbXMpKSkpCiAJIChw cmVhbWJsZSAoY2RyIChhc3NxIDpwcmVhbWJsZSBwYXJhbXMpKSkKQEAgLTgxLDYgKzg0LDggQEAg KGRlZnVuIG9yZy1iYWJlbC1leGVjdXRlOnB5dGhvbiAoYm9keSBwYXJhbXMpCiAJICAgKG9yZy1i YWJlbC1leHBhbmQtYm9keTpnZW5lcmljCiAJICAgIGJvZHkgcGFyYW1zCiAJICAgIChvcmctYmFi ZWwtdmFyaWFibGUtYXNzaWdubWVudHM6cHl0aG9uIHBhcmFtcykpCisgICAgICAgICAgICh3aGVu IGdyYXBoaWNzLWZpbGUKKyAgICAgICAgICAgICAob3JnLWJhYmVsLXB5dGhvbi1zYXZlLWdyYXBo aWNzIGdyYXBoaWNzLWZpbGUgcGFyYW1zKSkKIAkgICAod2hlbiByZXR1cm4tdmFsCiAJICAgICAo Zm9ybWF0IChpZiBzZXNzaW9uICJcbiV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