From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 8OWqM3xhhWKguwAAbAwnHQ (envelope-from ) for ; Wed, 18 May 2022 23:13:32 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id QJ+DM3xhhWLZbwEAauVa8A (envelope-from ) for ; Wed, 18 May 2022 23:13:32 +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 32BF4E4EA for ; Wed, 18 May 2022 23:13:32 +0200 (CEST) Received: from localhost ([::1]:51766 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nrQz4-0005bN-RQ for larch@yhetil.org; Wed, 18 May 2022 17:13:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46616) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nrQy2-0005b9-FS for emacs-orgmode@gnu.org; Wed, 18 May 2022 17:12:26 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]:34325) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nrQxz-0006Df-9N for emacs-orgmode@gnu.org; Wed, 18 May 2022 17:12:25 -0400 Received: by mail-pl1-x62e.google.com with SMTP id n8so2966498plh.1 for ; Wed, 18 May 2022 14:12:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=berkeley-edu.20210112.gappssmtp.com; s=20210112; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=dbM/33C0xK7Ll08f7MIfHExyG7I0yCymnKGpvuK7Lfk=; b=2BNCUbbJ0dEB4WwfpAQQ82LdCMRtnaXSn4ZmpGQ85JqgHz0gnd0YAYth3HX9jyAWaQ ezyujtR/wmB0Yzb6X+Wgq1Td68NtW7Ot4xYEp7k5UVidBT84qyjvbFH+RPQ98m3bgcy8 ArSNetmQrKvwdabv/qsrp+LQyLQRS6sY8DZhRDnXWT0zBahYfVjL9Qqc28JibDOZhemt 6t6RspyE/edO6H4F5cXSx+qF4A83tnJfEByzSmIXPzhhtwQajktxuncX49J0n2tsYmS3 thyUlvgLMq+22qW0i3oXawtkecwhqW/6IjXPpfdQ2Rnv6DnkIz0/n0bymHCRteh356Vb cfKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=dbM/33C0xK7Ll08f7MIfHExyG7I0yCymnKGpvuK7Lfk=; b=VDKJpyfoMG7m8hMerokx5KFAjxDZ31POemBlYKzH3ojBquXgsNMU/bwulEOJpAoZ98 vsMDiOCXOBVX1i+NPqYyD+NtPnA4mpgf9wlNn+ETOAmoXUO/bTu+mq7ERJtNPyZO6tzn H8or15H/U/nkwFKJcUTPi4Ef3nShKA7GKZYxE7Cn7CDtc4XVHtEipmQRhgcs5X1jM4Kw HeuUnmMy57T7EmMbkPp6Z3EenfkVkkkXbOnjhMyXdlumfW1goVlQgCrLkDtwrBKmGeAX aaINTzCNeUzPmXqdqmEpHvGbwLdqPIpYJ3qZMpLnqOz3PanuWkn6ddw3eDXdw8IY/82g 6kOw== X-Gm-Message-State: AOAM531MBUMDZsl4VAIKqkRZ6rSlMMFFwjZgtZjLgL6lkhhBJhGCic6E cVZ1FOkoXj8ZaJ0YNLHsWhBV+w== X-Google-Smtp-Source: ABdhPJzXVqs1R9PKSXqrN9zsdaVE4LbnjzuFFX0olTvjZDjUpXquHGrg+UqRWGRs6X9YTX3JfAZZ6A== X-Received: by 2002:a17:903:240c:b0:153:c452:f282 with SMTP id e12-20020a170903240c00b00153c452f282mr1269311plo.88.1652908340639; Wed, 18 May 2022 14:12:20 -0700 (PDT) Received: from smtpclient.apple (157-131-222-176.fiber.dynamic.sonic.net. [157.131.222.176]) by smtp.gmail.com with ESMTPSA id e7-20020a17090ab38700b001cd4989ff41sm1991911pjr.8.2022.05.18.14.12.19 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 May 2022 14:12:20 -0700 (PDT) From: Richard Stanton Message-Id: <09EF74F5-8C39-4773-9407-E65A46E2FE3B@berkeley.edu> Content-Type: multipart/alternative; boundary="Apple-Mail=_575E90DD-47C1-4BE4-9C75-DF172C5E1C0F" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.100.31\)) Subject: Re: Trouble producing nicely aligned org tables from emacs-jupyter code blocks using latest org version Date: Wed, 18 May 2022 14:12:19 -0700 In-Reply-To: Cc: orgmode To: John Kitchin References: X-Mailer: Apple Mail (2.3696.100.31) Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=rhstanton@berkeley.edu; helo=mail-pl1-x62e.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, HTML_MESSAGE=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" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1652908412; 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=dbM/33C0xK7Ll08f7MIfHExyG7I0yCymnKGpvuK7Lfk=; b=gs4sHvTLpk74nVYB1Bu7618ayWjFapV1yzCsB0m4NkKzvMRKJktna4ZSWvXGoB4PDY0yjf s+JnEgDJgzOZB17sPP651eAMh3mAV3U6g5ewz3SuSsNOhgNBa6SwWW6flmGaLm/UVrivqy c55Gfu14PNBEmuvzCSs23pT4L8sX6rGuc+yLbxZa8/GqmZn6DgOBbIhYJaeGcvTgjnllAR prNOWwE0tnphf0aJqZktyWIrptXJj7bop/6qLHmHnrsqttoGnoWaoALYAavwN86ceQeHQ9 E/ByOpd7Gh/Ls/OFTXyDy8UDkj5bJbkbe1+5U21Du4wbueh7Q/8Soq6sBYL8CQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1652908412; a=rsa-sha256; cv=none; b=VeElGO1YDflolUQ/tKvNY1eOMojWLf43qIw5wMKwbq5mewiPw/1SgA2GCR+DE1LQ1C/Q0F FBu/X4WM3dBCXo+HGq0bfIl010gdTpWzc2UCxj3J8TdXmc5UvscJ2fhiCcwyC62GHkANBb OZf7qJGkCjpqimpobUFCsopkIFMc+mJfRObLlry17zt/OIAKdnHxweCIbekmeraPvpfP4l 9vGRxbcec3gSBIaH2LC4Gw/SFNWNHQBzL8uP2bXuJkCu4fCelUGiCCmpL9CZRXz2l2Nc56 XM2XHyQZd7StCH3FPh/F6JSFx4TEuLrnNThl5499TWamMsRXRVem1nlHxEZgFA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=berkeley-edu.20210112.gappssmtp.com header.s=20210112 header.b=2BNCUbbJ; 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: -3.04 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=berkeley-edu.20210112.gappssmtp.com header.s=20210112 header.b=2BNCUbbJ; 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: 32BF4E4EA X-Spam-Score: -3.04 X-Migadu-Scanner: scn1.migadu.com X-TUID: wQsVUmo4v+29 --Apple-Mail=_575E90DD-47C1-4BE4-9C75-DF172C5E1C0F Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 A bit more experimenting shows that asynchronous execution is actually a = part of my original problem. By default, I have jupyter-python blocks = running asynchronously. In that case, the tables don=E2=80=99t format = quite right, as I noted. But if I add the header ":async nil", the table = comes out fine. Table formatting is OK in python blocks with or without = asynchronous execution.=20 > On May 18, 2022, at 2:00 PM, John Kitchin = wrote: >=20 > I would guess it could. I don't do anything asynchronous, and I am not = sure when org-babel-after-execute-hook runs, if it is immediately there = is no table to clean up I suppose. It is not necessary to run on a = subtree, but on a very large document you probably don't want to do = org-element-parse often. >=20 >=20 > John >=20 > ----------------------------------- > Professor John Kitchin (he/him/his) > Doherty Hall A207F > Department of Chemical Engineering > Carnegie Mellon University > Pittsburgh, PA 15213 > 412-268-7803 > @johnkitchin > http://kitchingroup.cheme.cmu.edu >=20 >=20 >=20 > On Wed, May 18, 2022 at 4:57 PM Richard Stanton = > wrote: > Thanks for the suggestion, John. I=E2=80=99ve tried playing around = with this, and am I right that it seems to have trouble when execution = is asynchronous? >=20 >> On May 18, 2022, at 1:16 PM, John Kitchin > wrote: >>=20 >> I use a function in an after execute hook for this: = https://github.com/jkitchin/scimax/blob/master/scimax-org.el#L205 = >>=20 >> This works on a subtree, which has been fine for me. You could adapt = it to only work in the results section. >>=20 >> John >>=20 >> ----------------------------------- >> Professor John Kitchin (he/him/his) >> Doherty Hall A207F >> Department of Chemical Engineering >> Carnegie Mellon University >> Pittsburgh, PA 15213 >> 412-268-7803 >> @johnkitchin >> http://kitchingroup.cheme.cmu.edu = >>=20 >>=20 >>=20 >> On Wed, May 18, 2022 at 4:07 PM Richard Stanton = > wrote: >> I=E2=80=99m running Emacs 28.1 under macOS 12.4 and want to create = tables from Python code blocks that can be exported to either LaTeX or = HTML. The simplest way to do this seems to be to generate the output as = an org table, and using the built-in version of org (9.4.6 = (9.4.6-798-g738759.dirty-elpaplus @ = /Users/stanton/.emacs.d/elpa/org-plus-contrib-20210929/)), this works = fine using either a python or emacs-jupyter code block: >>=20 >> #+begin_src jupyter-python >> [ >> ["Wide a", "b", "c"], >> None, >> [1, 2, 3], >> [4, 5, 6], >> None, >> [7, 8, 9] >> ] >> #+end_src >>=20 >> #+RESULTS: >> | Wide a | b | c | >> |--------+---+---| >> | 1 | 2 | 3 | >> | 4 | 5 | 6 | >> |--------+---+---| >> | 7 | 8 | 9 | >>=20 >> #+begin_src python=20 >> return [ >> ["Wide a", "b", "c"], >> None, >> [1, 2, 3], >> [4, 5, 6], >> None, >> [7, 8, 9] >> ] >> #+end_src >>=20 >> #+RESULTS: >> | Wide a | b | c | >> |--------+---+---| >> | 1 | 2 | 3 | >> | 4 | 5 | 6 | >> |--------+---+---| >> | 7 | 8 | 9 | >>=20 >>=20 >> To use the latest version of org, I change just two lines in my = init.el from >>=20 >> (straight-use-package '(org :type built-in)) >> (straight-use-package '(org-contrib :type built-in)) >>=20 >> to >>=20 >> (straight-use-package '(org :type git :repo = "https://code.orgmode.org/bzg/org-mode.git = ")) >> (straight-use-package '(org-contrib :type git :repo = "https://git.sr.ht/~bzg/org-contrib = =E2=80=9D)) >>=20 >> Having done this, the python block still works fine, but the = horizontal lines in the jupyter-python block are no longer properly = aligned with the text: >>=20 >> #+begin_src jupyter-python >> [ >> ["Wide a", "b", "c"], >> None, >> [1, 2, 3], >> [4, 5, 6], >> None, >> [7, 8, 9] >> ] >> #+end_src >>=20 >> #+RESULTS: >> | Wide a | b | c | >> |---+---+---| >> | 1 | 2 | 3 | >> | 4 | 5 | 6 | >> |---+---+---| >> | 7 | 8 | 9 | >>=20 >> #+begin_src python=20 >> return [ >> ["Wide a", "b", "c"], >> None, >> [1, 2, 3], >> [4, 5, 6], >> None, >> [7, 8, 9] >> ] >> #+end_src >>=20 >> #+RESULTS: >> | Wide a | b | c | >> |--------+---+---| >> | 1 | 2 | 3 | >> | 4 | 5 | 6 | >> |--------+---+---| >> | 7 | 8 | 9 | >>=20 >> By the way, the org version loaded this time is 9.5.3 (9.5.3-g277897 = @ /Users/stanton/.emacs.d/straight/build/org/). >>=20 >> The table exports OK, but isn=E2=80=99t much fun to look at in the = org file itself. >>=20 >> Since I like to use emacs-jupyter, any suggestions would be = appreciated. I know this worked fine just a few weeks ago. >>=20 >> Thanks! >>=20 >> Richard Stanton >>=20 >>=20 >>=20 >>=20 >>=20 >=20 --Apple-Mail=_575E90DD-47C1-4BE4-9C75-DF172C5E1C0F Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 A = bit more experimenting shows that asynchronous execution is actually a = part of my original problem. By default, I have jupyter-python blocks = running asynchronously. In that case, the tables don=E2=80=99t format = quite right, as I noted. But if I add the header ":async nil", the table = comes out fine. Table formatting is OK in python blocks with or without = asynchronous execution. 

On May = 18, 2022, at 2:00 PM, John Kitchin <jkitchin@andrew.cmu.edu> wrote:

I would guess it could. I don't do anything asynchronous, and = I am not sure when org-babel-after-execute-hook runs, if it is = immediately there is no table to clean up I suppose. It is not necessary = to run on  a subtree, but on a very large document you probably = don't want to do org-element-parse often.


John

-----------------------------------
Professor = John Kitchin (he/him/his)
Doherty Hall A207F
Department of Chemical Engineering
Carnegie = Mellon University
Pittsburgh, PA 15213
412-268-7803


On Wed, May = 18, 2022 at 4:57 PM Richard Stanton <rhstanton@berkeley.edu> wrote:
Thanks for the suggestion, John. I=E2=80=99ve = tried playing around with this, and am I right that it seems to have = trouble when execution is asynchronous?

On May = 18, 2022, at 1:16 PM, John Kitchin <jkitchin@andrew.cmu.edu> wrote:

I use a function in an after = execute hook for this: https://github.com/jkitchin/scimax/blob/master/scimax-org.el#L2= 05

This = works on a subtree, which has been fine for me. You could adapt it = to only work in the results section.

John

-----------------------------------
Professor = John Kitchin (he/him/his)
Doherty Hall A207F
Department of Chemical Engineering
Carnegie = Mellon University
Pittsburgh, PA 15213
412-268-7803


On Wed, May 18, 2022 at 4:07 PM Richard = Stanton <rhstanton@berkeley.edu> wrote:
I=E2=80=99m running Emacs 28.1 under = macOS 12.4 and want to create tables from Python code blocks that can be = exported to either LaTeX or HTML. The simplest way to do this seems to = be to generate the output as an org table, and using the built-in = version of org (9.4.6 (9.4.6-798-g738759.dirty-elpaplus @ = /Users/stanton/.emacs.d/elpa/org-plus-contrib-20210929/)), this works = fine using either a python or emacs-jupyter code block:

#+begin_src jupyter-python
[
    ["Wide a", "b", "c"],
    None,
    [1, 2, 3],
    [4, 5, 6],
    None,
    [7, 8, 9]
]
#+end_src

#+RESULTS:
| Wide a | b | c |
|--------+---+---|
|      1 | 2 | 3 |
|      4 | 5 | 6 |
|--------+---+---|
|      7 | 8 | 9 |

#+begin_src python
return [
    ["Wide a", "b", "c"],
    None,
    [1, 2, 3],
    [4, 5, 6],
    None,
    [7, 8, 9]
]
#+end_src

#+RESULTS:
| Wide a | b | c |
|--------+---+---|
|      1 | 2 | 3 |
|      4 | 5 | 6 |
|--------+---+---|
|      7 | 8 | 9 |


To use the latest version of org, I change just two lines in my init.el = from

(straight-use-package '(org :type built-in))
(straight-use-package '(org-contrib :type built-in))

to

(straight-use-package '(org :type git :repo "https://code.orgmode.org/bzg/org-mode.git"))
= (straight-use-package '(org-contrib :type git :repo "https://git.sr.ht/~bzg/org-contrib=E2=80=9D))

Having done this, the python block still works fine, but the horizontal = lines in the jupyter-python block are no longer properly aligned with = the text:

#+begin_src jupyter-python
[
    ["Wide a", "b", "c"],
    None,
    [1, 2, 3],
    [4, 5, 6],
    None,
    [7, 8, 9]
]
#+end_src

#+RESULTS:
| Wide a | b | c |
|---+---+---|
| 1 | 2 | 3 |
| 4 | 5 | 6 |
|---+---+---|
| 7 | 8 | 9 |

#+begin_src python
return [
    ["Wide a", "b", "c"],
    None,
    [1, 2, 3],
    [4, 5, 6],
    None,
    [7, 8, 9]
]
#+end_src

#+RESULTS:
| Wide a | b | c |
|--------+---+---|
|      1 | 2 | 3 |
|      4 | 5 | 6 |
|--------+---+---|
|      7 | 8 | 9 |

By the way, the org version loaded this time is 9.5.3 (9.5.3-g277897 @ = /Users/stanton/.emacs.d/straight/build/org/).

The table exports OK, but isn=E2=80=99t much fun to look at in the org = file itself.

Since I like to use emacs-jupyter, any suggestions would be appreciated. = I know this worked fine just a few weeks ago.

Thanks!

Richard Stanton







= --Apple-Mail=_575E90DD-47C1-4BE4-9C75-DF172C5E1C0F--