all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Org Babel "swallows" table column groups
@ 2024-06-28 12:43 Rudolf Adamkovič
  2024-06-28 15:28 ` Ihor Radchenko
  2024-06-28 17:42 ` S. Sajad Hosseini Balef
  0 siblings, 2 replies; 9+ messages in thread
From: Rudolf Adamkovič @ 2024-06-28 12:43 UTC (permalink / raw)
  To: emacs-orgmode

Given the source block

  #+BEGIN_SRC emacs-lisp
  (list (list 1 2) (list "/" "<>") 'hline (list 3 4) (list 5 6))
  #+END_SRC

Org Babel outputs

  #+RESULTS:
  | 1 | 2 |
  |---+---|
  | 3 | 4 |
  | 5 | 6 |

with the second element of the list

  (list "/" "<>")

swallowed, without a word.

Why would Org Babel do this?

And, how can one output tables with column groups?

Rudy
-- 
"I do not fear death.  I had been dead for billions and billions of years
before I was born, and had not suffered the slightest inconvenience from it."
--- Mark Twain, paraphrased

Rudolf Adamkovič <rudolf@adamkovic.org> [he/him]
http://adamkovic.org


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Org Babel "swallows" table column groups
  2024-06-28 12:43 Org Babel "swallows" table column groups Rudolf Adamkovič
@ 2024-06-28 15:28 ` Ihor Radchenko
  2024-06-30  8:53   ` Rudolf Adamkovič
  2024-07-08 12:05   ` Ihor Radchenko
  2024-06-28 17:42 ` S. Sajad Hosseini Balef
  1 sibling, 2 replies; 9+ messages in thread
From: Ihor Radchenko @ 2024-06-28 15:28 UTC (permalink / raw)
  To: Rudolf Adamkovič; +Cc: emacs-orgmode

Rudolf Adamkovič <rudolf@adamkovic.org> writes:

> Given the source block
>
>   #+BEGIN_SRC emacs-lisp
>   (list (list 1 2) (list "/" "<>") 'hline (list 3 4) (list 5 6))
>   #+END_SRC
>
> Org Babel outputs
> ...
> with the second element of the list
>
>   (list "/" "<>")
>
> swallowed, without a word.
>
> Why would Org Babel do this?
>
> And, how can one output tables with column groups?

This is because of how `orgtbl-to-generic' is implemented. It is taking
pieces from the full ox.el exporter, hard-coding certain things. For
example, it always removes special table lines:

    ;; Since we are going to export using a low-level mechanism,
    ;; ignore special column and special rows manually.

ox.el used to do the same recently, until I added a feature to keep
special lines in tables during export (for ox-org purposes).

See also https://list.orgmode.org/orgmode/87bkjy9tew.fsf@mat.ucm.es/

-- 
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>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Org Babel "swallows" table column groups
  2024-06-28 12:43 Org Babel "swallows" table column groups Rudolf Adamkovič
  2024-06-28 15:28 ` Ihor Radchenko
@ 2024-06-28 17:42 ` S. Sajad Hosseini Balef
  2024-06-30  8:13   ` Rudolf Adamkovič
  1 sibling, 1 reply; 9+ messages in thread
From: S. Sajad Hosseini Balef @ 2024-06-28 17:42 UTC (permalink / raw)
  To: rudolf; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 9847 bytes --]

 From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <emacs-orgmode-bounces+larch=yhetil.org@gnu.org>
Received: from mp2.migadu.com ([2001:41d0:403:58f0::])
     (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
     by ms13.migadu.com with LMTPS
     id QIBcKZmwfmY+JwAAe85BDQ:P1
     (envelope-from <emacs-orgmode-bounces+larch=yhetil.org@gnu.org>)
     for <larch@yhetil.org>; Fri, 28 Jun 2024 12:46:17 +0000
Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::])
     (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
     by mp2.migadu.com with LMTPS
     id QIBcKZmwfmY+JwAAe85BDQ
     (envelope-from <emacs-orgmode-bounces+larch=yhetil.org@gnu.org>)
     for <larch@yhetil.org>; Fri, 28 Jun 2024 14:46:17 +0200
X-Envelope-To: larch@yhetil.org
Authentication-Results: aspmx1.migadu.com;
     dkim=pass header.d=adamkovic.org header.s=fm3 header.b="U/f6NnaG";
     dkim=pass header.d=messagingengine.com header.s=fm2 header.b=FpL7cHAz;
     dmarc=pass (policy=none) header.from=adamkovic.org;
     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=1719578777;
  h=from:from:sender:sender:reply-to:subject:subject:date:date:
      message-id:message-id:to:to:cc:mime-version:mime-version:
      content-type:content-type:
content-transfer-encoding:content-transfer-encoding:list-id:list-help:
      list-unsubscribe:list-subscribe:list-post:dkim-signature;
     bh=C2cE9CoSnYYr2BGJev1QhmuB1Z+39WbbFyxYuCDvrCk=;
  b=mYHAOOLr3cUA4aYA3SU7IsKHuxaclFCk27AU1SZiRUgLyiT1lDhE9/uXwoM+BE/Bl12TCy
  O67TZgZoPmHAS9aUo6HFawsZiTKqzGBnRn3T0p8RVVta6m8VDiaJ08NZxDkGHfx1CWbvAb
  dB+LT58cjfNpyI7UNPzUP1hyTg0uJ5xcXwFff623wk7IvYAFvhlrgNahZlB4V9Jq5DA8f2
  6NnHeWEtw2FAS6kWCUaxnfM3wFB+e6UhoJONlS0dQSQprJt1N6FAXQjUfMZMmOvjD9Y7+1
  5C3fybFY2ItmnDgFRRX5tOosLuUZ4jSPDwCdTK6GmU2utoBBJ0fe5+qjiF8uvQ==
ARC-Seal: i=1; s=key1; d=yhetil.org; t=1719578777; a=rsa-sha256; cv=none;
  b=XAkAEOoaYm+MQAgT66QHfA9rSiEjaFRNPhAjUf2dAkGq0UrAhJxN7VCUZYzXEJNJTTrkoH
  kq+r336QjJb0zqAz0iVXpAJ+O0awc9x9KBPrqUnKoLWpsk41I1QuOR9mrak7XLUJbLYOri
  QnhQ+L5h5uNEYW+Or2Q5J9YXP/QxiCCe/CK+7yqPBxGj21i4sxkP3St2wNN304tlbWKFk8
  b+69YfUiMQirKk0+f3rQ7O6z9ZIUKKTAhpC0UWOG9EFZLqzMKMezs+DTyDnM/tlAJ4BPpJ
  xyZjm5m5ScvCFFFEYBwKgQes/SAeNwa6aylpmclNLr+0PegBkiJAcQk84LPuEA==
ARC-Authentication-Results: i=1;
     aspmx1.migadu.com;
     dkim=pass header.d=adamkovic.org header.s=fm3 header.b="U/f6NnaG";
     dkim=pass header.d=messagingengine.com header.s=fm2 header.b=FpL7cHAz;
     dmarc=pass (policy=none) header.from=adamkovic.org;
     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"
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 1ED15631B9
     for <larch@yhetil.org>; Fri, 28 Jun 2024 14:46:16 +0200 (CEST)
Received: from localhost ([::1] helo=lists1p.gnu.org)
     by lists.gnu.org with esmtp (Exim 4.90_1)
     (envelope-from <emacs-orgmode-bounces@gnu.org>)
     id 1sNAy0-0007BS-8n; Fri, 28 Jun 2024 08:44:40 -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 <rudolf@adamkovic.org>)
  id 1sNAx3-00055r-TL
  for emacs-orgmode@gnu.org; Fri, 28 Jun 2024 08:43:42 -0400
Received: from fhigh2-smtp.messagingengine.com ([103.168.172.153])
  by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
  (Exim 4.90_1) (envelope-from <rudolf@adamkovic.org>)
  id 1sNAx1-0005sX-40
  for emacs-orgmode@gnu.org; Fri, 28 Jun 2024 08:43:40 -0400
Received: from compute3.internal (compute3.nyi.internal [10.202.2.43])
  by mailfhigh.nyi.internal (Postfix) with ESMTP id 0EF6F114029B
  for <emacs-orgmode@gnu.org>; Fri, 28 Jun 2024 08:43:36 -0400 (EDT)
Received: from mailfrontend2 ([10.202.2.163])
  by compute3.internal (MEProxy); Fri, 28 Jun 2024 08:43:36 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adamkovic.org;
  h=cc:content-transfer-encoding:content-type:content-type:date
  :date:from:from:in-reply-to:message-id:mime-version:reply-to
  :subject:subject:to:to; s=fm3; t=1719578616; x=1719665016; bh=C2
  cE9CoSnYYr2BGJev1QhmuB1Z+39WbbFyxYuCDvrCk=; b=U/f6NnaGxnB/sGWrY2
  Y5n0EJ0AyjVkricdpx83GBawskrgGOkGl9phajOEiIzXBaSPmlxydFv41FpYI8O2
  jB87FxiuDYC4rGcfLvaAbQnN/Oy7jj1ckhb8mLABGWFufKgr4SPsQqw7TtoevQcQ
  d4DAMPkelQev/OeGp0qplQcRYe5f74amOE2e8ejig126BbzWGnBZX+FeyFqFjJoq
  XD7kGtvljKS0NFSADZqBHfhHr3WSJv+DpgT1YC8WvPGZTNzDwXl9nPSvp99Ytw+l
  2F4WIlUavjhu6qWHrZZS/xj+04FzJizRc1taS/+zWlqBhPkYh0Vv6/ndJED/lhR2
  kDlw==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
  messagingengine.com; h=cc:content-transfer-encoding:content-type
  :content-type:date:date:feedback-id:feedback-id:from:from
  :in-reply-to:message-id:mime-version:reply-to:subject:subject:to
  :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=
  fm2; t=1719578616; x=1719665016; bh=C2cE9CoSnYYr2BGJev1QhmuB1Z+3
  9WbbFyxYuCDvrCk=; b=FpL7cHAzSzzkCurGnmXT8VggmSV5JB4dkWmFjy00+QAn
  UVMCvaedhVIxr8T2vC44AFAmwV0ifJqp0/2AwJWZEbTb9+IJEyDB5ugJhmOyEAAL
  vXnj/s/XRxeUeqFX+lAT3zgOUMrJlPfZM66DVQF/JrvWiupvSkBsWmhE0JB7kLe/
  lthxqaSHTy3OnXgK1QN97QjrhfCx/Ubu511muQM1YVEGNuleHJH4Xw3coXpy8D56
  iW6GlDjzzBu+y0RhmHqSTNw+s0ZJVvNMrBWFVed+Moo3mFy0doAhQVI4OHzNBJbM
  Wl67brZMWhGuCKoz/9Yw3k1oDLCzGs/QzJUHRcb9rA==
X-ME-Sender: <xms:969-ZkDJVQhDE-_azZm_eD_fZ9qkRmCrNUEJrazGy16MlCyZS9-9YA>
  <xme:969-ZmhMTO6Y43v1vnSXyXImAPR7GmctpeQ27vr_6CuHXju-6cQ7A_d7ZigwVD6TY
  Eckl0vzNwwjEQATvGE>
X-ME-Received: 
<xmr:969-ZnlQYprvVdAUJ07CFcNxy-zbuumnsKpptGp-FxnE5GRMQc0VO54U4vaNGfvAzIuHc-Fq4cziuVf4Eg>
X-ME-Proxy-Cause: 
gggruggvucftvghtrhhoucdtuddrgeeftddrtdeigdehhecutefuodetggdotefrodftvf
  curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu
  uegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkfggtgfgsehtqhertddttd
  ejnecuhfhrohhmpeftuhguohhlfhcutegurghmkhhovhhitgcuoehruhguohhlfhesrggu
  rghmkhhovhhitgdrohhrgheqnecuggftrfgrthhtvghrnhepkeelkeevtdeiudevvedtff
  eghfdvgffhkeeileehtefhudeiueetudegheffvdffnecuffhomhgrihhnpegruggrmhhk
  ohhvihgtrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh
  hfrhhomheprhhuugholhhfsegruggrmhhkohhvihgtrdhorhhg
X-ME-Proxy: <xmx:969-ZqxlmHIW5aG7HfF88IRUA1iVIs3at80dC05XI2WnWVEP27BTIA>
  <xmx:969-ZpSWD9UJjYp8JJ_lCBelL0U8OgF1diQbjELcfDLmoXQu9NZmmw>
  <xmx:969-ZlaxQmK47xtHjGvAGrgDU2ITq4Sz7E-yI_JrRqXa10aXbFKRgQ>
  <xmx:969-ZiRXnkN4w8N3yk3TM09yE425hbpn6Vx8BwJm0ilF8pNd6ejt5Q>
  <xmx:-K9-ZoL6_Q2ROQKMrLOnrs3mYrUdKk9yP5HBpLy-BT8i0PBuagsQNaCt>
Feedback-ID: i88214938:Fastmail
Received: by mail.messagingengine.com (Postfix) with ESMTPA for
  <emacs-orgmode@gnu.org>; Fri, 28 Jun 2024 08:43:34 -0400 (EDT)
From: =?utf-8?Q?Rudolf_Adamkovi=C4=8D?= <rudolf@adamkovic.org>
To: emacs-orgmode@gnu.org
Subject: Org Babel "swallows" table column groups
Date: Fri, 28 Jun 2024 14:43:31 +0200
Message-ID: <m2h6dd9r0s.fsf@adamkovic.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Received-SPF: pass client-ip=103.168.172.153;
  envelope-from=rudolf@adamkovic.org; helo=fhigh2-smtp.messagingengine.com
X-Spam_score_int: -27
X-Spam_score: -2.8
X-Spam_bar: --
X-Spam_report: (-2.8 / 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,
  RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-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." <emacs-orgmode.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/emacs-orgmode>,
  <mailto:emacs-orgmode-request@gnu.org?subject=unsubscribe>
List-Archive: <https://lists.gnu.org/archive/html/emacs-orgmode>
List-Post: <mailto:emacs-orgmode@gnu.org>
List-Help: <mailto:emacs-orgmode-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/emacs-orgmode>,
  <mailto:emacs-orgmode-request@gnu.org?subject=subscribe>
Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org
Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org
X-Migadu-Flow: FLOW_IN
X-Migadu-Country: US
X-Migadu-Spam-Score: -7.56
X-Spam-Score: -7.56
X-Migadu-Queue-Id: 1ED15631B9
X-Migadu-Scanner: mx11.migadu.com
X-TUID: NeUcjxz0HfbD

 > Given the source block
 >
 >   #+BEGIN_SRC emacs-lisp
 >   (list (list 1 2) (list "/" "<>") 'hline (list 3 4) (list 5 6))
 >   #+END_SRC
 >
 > Org Babel outputs
 >
 >   #+RESULTS:
 >   | 1 | 2 |
 >   |---+---|
 >   | 3 | 4 |
 >   | 5 | 6 |
 >
 > with the second element of the list
 >
 >   (list "/" "<>")
 >
 > swallowed, without a word.
 >
 > Why would Org Babel do this?
 >
 > And, how can one output tables with column groups?
 >
 > Rudy
 > --=20
 > "I do not fear death.  I had been dead for billions and billions of years
 > before I was born, and had not suffered the slightest inconvenience 
from it=
 > ."
 > --- Mark Twain, paraphrased
 >
 > Rudolf Adamkovi=C4=8D <rudolf@adamkovic.org> [he/him]
 > http://adamkovic.org

It's seems related to the "<>" bacuse with any other strings I haven't 
such issue. I tried to fix ob-emacs-lisp.el but there was no success at 
the moment.

S. Sajad Hosseini Balef

shosseinib@ut.ac.ir

[-- Attachment #2: Org-Babel-swallows-table-column-groups.txt --]
[-- Type: text/plain, Size: 9185 bytes --]

From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <emacs-orgmode-bounces+larch=yhetil.org@gnu.org>
Received: from mp2.migadu.com ([2001:41d0:403:58f0::])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	by ms13.migadu.com with LMTPS
	id QIBcKZmwfmY+JwAAe85BDQ:P1
	(envelope-from <emacs-orgmode-bounces+larch=yhetil.org@gnu.org>)
	for <larch@yhetil.org>; Fri, 28 Jun 2024 12:46:17 +0000
Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	by mp2.migadu.com with LMTPS
	id QIBcKZmwfmY+JwAAe85BDQ
	(envelope-from <emacs-orgmode-bounces+larch=yhetil.org@gnu.org>)
	for <larch@yhetil.org>; Fri, 28 Jun 2024 14:46:17 +0200
X-Envelope-To: larch@yhetil.org
Authentication-Results: aspmx1.migadu.com;
	dkim=pass header.d=adamkovic.org header.s=fm3 header.b="U/f6NnaG";
	dkim=pass header.d=messagingengine.com header.s=fm2 header.b=FpL7cHAz;
	dmarc=pass (policy=none) header.from=adamkovic.org;
	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=1719578777;
	h=from:from:sender:sender:reply-to:subject:subject:date:date:
	 message-id:message-id:to:to:cc:mime-version:mime-version:
	 content-type:content-type:
	 content-transfer-encoding:content-transfer-encoding:list-id:list-help:
	 list-unsubscribe:list-subscribe:list-post:dkim-signature;
	bh=C2cE9CoSnYYr2BGJev1QhmuB1Z+39WbbFyxYuCDvrCk=;
	b=mYHAOOLr3cUA4aYA3SU7IsKHuxaclFCk27AU1SZiRUgLyiT1lDhE9/uXwoM+BE/Bl12TCy
	O67TZgZoPmHAS9aUo6HFawsZiTKqzGBnRn3T0p8RVVta6m8VDiaJ08NZxDkGHfx1CWbvAb
	dB+LT58cjfNpyI7UNPzUP1hyTg0uJ5xcXwFff623wk7IvYAFvhlrgNahZlB4V9Jq5DA8f2
	6NnHeWEtw2FAS6kWCUaxnfM3wFB+e6UhoJONlS0dQSQprJt1N6FAXQjUfMZMmOvjD9Y7+1
	5C3fybFY2ItmnDgFRRX5tOosLuUZ4jSPDwCdTK6GmU2utoBBJ0fe5+qjiF8uvQ==
ARC-Seal: i=1; s=key1; d=yhetil.org; t=1719578777; a=rsa-sha256; cv=none;
	b=XAkAEOoaYm+MQAgT66QHfA9rSiEjaFRNPhAjUf2dAkGq0UrAhJxN7VCUZYzXEJNJTTrkoH
	kq+r336QjJb0zqAz0iVXpAJ+O0awc9x9KBPrqUnKoLWpsk41I1QuOR9mrak7XLUJbLYOri
	QnhQ+L5h5uNEYW+Or2Q5J9YXP/QxiCCe/CK+7yqPBxGj21i4sxkP3St2wNN304tlbWKFk8
	b+69YfUiMQirKk0+f3rQ7O6z9ZIUKKTAhpC0UWOG9EFZLqzMKMezs+DTyDnM/tlAJ4BPpJ
	xyZjm5m5ScvCFFFEYBwKgQes/SAeNwa6aylpmclNLr+0PegBkiJAcQk84LPuEA==
ARC-Authentication-Results: i=1;
	aspmx1.migadu.com;
	dkim=pass header.d=adamkovic.org header.s=fm3 header.b="U/f6NnaG";
	dkim=pass header.d=messagingengine.com header.s=fm2 header.b=FpL7cHAz;
	dmarc=pass (policy=none) header.from=adamkovic.org;
	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"
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 1ED15631B9
	for <larch@yhetil.org>; Fri, 28 Jun 2024 14:46:16 +0200 (CEST)
Received: from localhost ([::1] helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <emacs-orgmode-bounces@gnu.org>)
	id 1sNAy0-0007BS-8n; Fri, 28 Jun 2024 08:44:40 -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 <rudolf@adamkovic.org>)
 id 1sNAx3-00055r-TL
 for emacs-orgmode@gnu.org; Fri, 28 Jun 2024 08:43:42 -0400
Received: from fhigh2-smtp.messagingengine.com ([103.168.172.153])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <rudolf@adamkovic.org>)
 id 1sNAx1-0005sX-40
 for emacs-orgmode@gnu.org; Fri, 28 Jun 2024 08:43:40 -0400
Received: from compute3.internal (compute3.nyi.internal [10.202.2.43])
 by mailfhigh.nyi.internal (Postfix) with ESMTP id 0EF6F114029B
 for <emacs-orgmode@gnu.org>; Fri, 28 Jun 2024 08:43:36 -0400 (EDT)
Received: from mailfrontend2 ([10.202.2.163])
 by compute3.internal (MEProxy); Fri, 28 Jun 2024 08:43:36 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adamkovic.org;
 h=cc:content-transfer-encoding:content-type:content-type:date
 :date:from:from:in-reply-to:message-id:mime-version:reply-to
 :subject:subject:to:to; s=fm3; t=1719578616; x=1719665016; bh=C2
 cE9CoSnYYr2BGJev1QhmuB1Z+39WbbFyxYuCDvrCk=; b=U/f6NnaGxnB/sGWrY2
 Y5n0EJ0AyjVkricdpx83GBawskrgGOkGl9phajOEiIzXBaSPmlxydFv41FpYI8O2
 jB87FxiuDYC4rGcfLvaAbQnN/Oy7jj1ckhb8mLABGWFufKgr4SPsQqw7TtoevQcQ
 d4DAMPkelQev/OeGp0qplQcRYe5f74amOE2e8ejig126BbzWGnBZX+FeyFqFjJoq
 XD7kGtvljKS0NFSADZqBHfhHr3WSJv+DpgT1YC8WvPGZTNzDwXl9nPSvp99Ytw+l
 2F4WIlUavjhu6qWHrZZS/xj+04FzJizRc1taS/+zWlqBhPkYh0Vv6/ndJED/lhR2
 kDlw==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
 messagingengine.com; h=cc:content-transfer-encoding:content-type
 :content-type:date:date:feedback-id:feedback-id:from:from
 :in-reply-to:message-id:mime-version:reply-to:subject:subject:to
 :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=
 fm2; t=1719578616; x=1719665016; bh=C2cE9CoSnYYr2BGJev1QhmuB1Z+3
 9WbbFyxYuCDvrCk=; b=FpL7cHAzSzzkCurGnmXT8VggmSV5JB4dkWmFjy00+QAn
 UVMCvaedhVIxr8T2vC44AFAmwV0ifJqp0/2AwJWZEbTb9+IJEyDB5ugJhmOyEAAL
 vXnj/s/XRxeUeqFX+lAT3zgOUMrJlPfZM66DVQF/JrvWiupvSkBsWmhE0JB7kLe/
 lthxqaSHTy3OnXgK1QN97QjrhfCx/Ubu511muQM1YVEGNuleHJH4Xw3coXpy8D56
 iW6GlDjzzBu+y0RhmHqSTNw+s0ZJVvNMrBWFVed+Moo3mFy0doAhQVI4OHzNBJbM
 Wl67brZMWhGuCKoz/9Yw3k1oDLCzGs/QzJUHRcb9rA==
X-ME-Sender: <xms:969-ZkDJVQhDE-_azZm_eD_fZ9qkRmCrNUEJrazGy16MlCyZS9-9YA>
 <xme:969-ZmhMTO6Y43v1vnSXyXImAPR7GmctpeQ27vr_6CuHXju-6cQ7A_d7ZigwVD6TY
 Eckl0vzNwwjEQATvGE>
X-ME-Received: <xmr:969-ZnlQYprvVdAUJ07CFcNxy-zbuumnsKpptGp-FxnE5GRMQc0VO54U4vaNGfvAzIuHc-Fq4cziuVf4Eg>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrtdeigdehhecutefuodetggdotefrodftvf
 curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu
 uegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkfggtgfgsehtqhertddttd
 ejnecuhfhrohhmpeftuhguohhlfhcutegurghmkhhovhhitgcuoehruhguohhlfhesrggu
 rghmkhhovhhitgdrohhrgheqnecuggftrfgrthhtvghrnhepkeelkeevtdeiudevvedtff
 eghfdvgffhkeeileehtefhudeiueetudegheffvdffnecuffhomhgrihhnpegruggrmhhk
 ohhvihgtrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh
 hfrhhomheprhhuugholhhfsegruggrmhhkohhvihgtrdhorhhg
X-ME-Proxy: <xmx:969-ZqxlmHIW5aG7HfF88IRUA1iVIs3at80dC05XI2WnWVEP27BTIA>
 <xmx:969-ZpSWD9UJjYp8JJ_lCBelL0U8OgF1diQbjELcfDLmoXQu9NZmmw>
 <xmx:969-ZlaxQmK47xtHjGvAGrgDU2ITq4Sz7E-yI_JrRqXa10aXbFKRgQ>
 <xmx:969-ZiRXnkN4w8N3yk3TM09yE425hbpn6Vx8BwJm0ilF8pNd6ejt5Q>
 <xmx:-K9-ZoL6_Q2ROQKMrLOnrs3mYrUdKk9yP5HBpLy-BT8i0PBuagsQNaCt>
Feedback-ID: i88214938:Fastmail
Received: by mail.messagingengine.com (Postfix) with ESMTPA for
 <emacs-orgmode@gnu.org>; Fri, 28 Jun 2024 08:43:34 -0400 (EDT)
From: =?utf-8?Q?Rudolf_Adamkovi=C4=8D?= <rudolf@adamkovic.org>
To: emacs-orgmode@gnu.org
Subject: Org Babel "swallows" table column groups
Date: Fri, 28 Jun 2024 14:43:31 +0200
Message-ID: <m2h6dd9r0s.fsf@adamkovic.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Received-SPF: pass client-ip=103.168.172.153;
 envelope-from=rudolf@adamkovic.org; helo=fhigh2-smtp.messagingengine.com
X-Spam_score_int: -27
X-Spam_score: -2.8
X-Spam_bar: --
X-Spam_report: (-2.8 / 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,
 RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-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." <emacs-orgmode.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/emacs-orgmode>,
 <mailto:emacs-orgmode-request@gnu.org?subject=unsubscribe>
List-Archive: <https://lists.gnu.org/archive/html/emacs-orgmode>
List-Post: <mailto:emacs-orgmode@gnu.org>
List-Help: <mailto:emacs-orgmode-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/emacs-orgmode>,
 <mailto:emacs-orgmode-request@gnu.org?subject=subscribe>
Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org
Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org
X-Migadu-Flow: FLOW_IN
X-Migadu-Country: US
X-Migadu-Spam-Score: -7.56
X-Spam-Score: -7.56
X-Migadu-Queue-Id: 1ED15631B9
X-Migadu-Scanner: mx11.migadu.com
X-TUID: NeUcjxz0HfbD

Given the source block

  #+BEGIN_SRC emacs-lisp
  (list (list 1 2) (list "/" "<>") 'hline (list 3 4) (list 5 6))
  #+END_SRC

Org Babel outputs

  #+RESULTS:
  | 1 | 2 |
  |---+---|
  | 3 | 4 |
  | 5 | 6 |

with the second element of the list

  (list "/" "<>")

swallowed, without a word.

Why would Org Babel do this?

And, how can one output tables with column groups?

Rudy
--=20
"I do not fear death.  I had been dead for billions and billions of years
before I was born, and had not suffered the slightest inconvenience from it=
."
--- Mark Twain, paraphrased

Rudolf Adamkovi=C4=8D <rudolf@adamkovic.org> [he/him]
http://adamkovic.org



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Org Babel "swallows" table column groups
  2024-06-28 17:42 ` S. Sajad Hosseini Balef
@ 2024-06-30  8:13   ` Rudolf Adamkovič
  2024-06-30  8:35     ` S. Sajad Hosseini Balef
  0 siblings, 1 reply; 9+ messages in thread
From: Rudolf Adamkovič @ 2024-06-30  8:13 UTC (permalink / raw)
  To: S. Sajad Hosseini Balef; +Cc: emacs-orgmode

"S. Sajad Hosseini Balef" <shosseinib@ut.ac.ir> writes:

> It's seems related to the "<>" bacuse with any other strings I haven't
> such issue.

From what I see, the culprit is the "/" because, as soon as it appears,
Org Babel drops the row from the output.  Then, when I replace the "/"
with something different, such as "xyz", the row is back.

> I tried to fix ob-emacs-lisp.el but there was no success at the
> moment.

I stumbled upon the problem when using Scheme.  The bug report uses
Emacs Lisp only to ease reproduction.  (I should have probably mentioned
that.)  In other words, the problem does not seem to be specific to
Emacs Lisp.

Rudy
-- 
"It is far better to have a question that can't be answered than an
answer that can't be questioned."  --- Carl Sagan

Rudolf Adamkovič <rudolf@adamkovic.org> [he/him]
http://adamkovic.org


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Org Babel "swallows" table column groups
  2024-06-30  8:13   ` Rudolf Adamkovič
@ 2024-06-30  8:35     ` S. Sajad Hosseini Balef
  0 siblings, 0 replies; 9+ messages in thread
From: S. Sajad Hosseini Balef @ 2024-06-30  8:35 UTC (permalink / raw)
  To: Rudolf Adamkovič; +Cc: emacs-orgmode

It's weird because with swapping "<>" and "/" with escape-syntax character has no problem in the table:

#+BEGIN_SRC emacs-lisp
   (list (list 1 2) (list "\<>" "\/") 'hline (list 3 4) (list 5 6))
#+end_src

#+RESULTS:
|  1 | 2 |
| <> | / |
|----+---|
|  3 | 4 |
|  5 | 6 |

On 6/30/24 11:43 AM, Rudolf Adamkovič wrote:
> "S. Sajad Hosseini Balef" <shosseinib@ut.ac.ir> writes:
>
>> It's seems related to the "<>" bacuse with any other strings I haven't
>> such issue.
>  From what I see, the culprit is the "/" because, as soon as it appears,
> Org Babel drops the row from the output.  Then, when I replace the "/"
> with something different, such as "xyz", the row is back.
>
>> I tried to fix ob-emacs-lisp.el but there was no success at the
>> moment.
> I stumbled upon the problem when using Scheme.  The bug report uses
> Emacs Lisp only to ease reproduction.  (I should have probably mentioned
> that.)  In other words, the problem does not seem to be specific to
> Emacs Lisp.
>
> Rudy


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Org Babel "swallows" table column groups
  2024-06-28 15:28 ` Ihor Radchenko
@ 2024-06-30  8:53   ` Rudolf Adamkovič
  2024-07-08 12:05   ` Ihor Radchenko
  1 sibling, 0 replies; 9+ messages in thread
From: Rudolf Adamkovič @ 2024-06-30  8:53 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

Ihor Radchenko <yantar92@posteo.net> writes:

> Rudolf Adamkovič <rudolf@adamkovic.org> writes:
>
> This is because of how `orgtbl-to-generic' is implemented. It is taking
> pieces from the full ox.el exporter, hard-coding certain things. For
> example, it always removes special table lines:
>
>     ;; Since we are going to export using a low-level mechanism,
>     ;; ignore special column and special rows manually.
>
> ox.el used to do the same recently, until I added a feature to keep
> special lines in tables during export (for ox-org purposes).

Bummer!

I wrote a little Scheme program to generate truth tables for my notes on
mathematical logic and also to aid future explorations.  It works well,
but without table separators, truth tables are harder to read.

Rudy
-- 
"We shall not cease from exploration
 And the end of all our exploring
 Will be to arrive where we started
 And know the place for the first time"
--- T. S. Eliot, Little Gidding, Four Quarters, 1943

Rudolf Adamkovič <rudolf@adamkovic.org> [he/him]
http://adamkovic.org


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Org Babel "swallows" table column groups
  2024-06-28 15:28 ` Ihor Radchenko
  2024-06-30  8:53   ` Rudolf Adamkovič
@ 2024-07-08 12:05   ` Ihor Radchenko
  2024-07-10 13:33     ` Rudolf Adamkovič
  1 sibling, 1 reply; 9+ messages in thread
From: Ihor Radchenko @ 2024-07-08 12:05 UTC (permalink / raw)
  To: Rudolf Adamkovič; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 900 bytes --]

Ihor Radchenko <yantar92@posteo.net> writes:

>>   #+BEGIN_SRC emacs-lisp
>>   (list (list 1 2) (list "/" "<>") 'hline (list 3 4) (list 5 6))
>>   #+END_SRC
>>
>> Org Babel outputs
>> ...
>> with the second element of the list
>>
>>   (list "/" "<>")
>>
>> swallowed, without a word.
>>
>> Why would Org Babel do this?
>>
>> And, how can one output tables with column groups?
>
> This is because of how `orgtbl-to-generic' is implemented. It is taking
> pieces from the full ox.el exporter, hard-coding certain things. For
> example, it always removes special table lines:
>
>     ;; Since we are going to export using a low-level mechanism,
>     ;; ignore special column and special rows manually.

I refactored `orgtbl-to-generic', so that it does not have to duplicate
`org-export-as'. Now, things should be more consistent with the normal
export.

May you try the attached tentative patch set?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ox-New-custom-option-to-disable-macro-replacement.patch --]
[-- Type: text/x-patch, Size: 4113 bytes --]

From f1ff68920c417343fda4c5a6450567d703ccf9b6 Mon Sep 17 00:00:00 2001
Message-ID: <f1ff68920c417343fda4c5a6450567d703ccf9b6.1720440129.git.yantar92@posteo.net>
From: Ihor Radchenko <yantar92@posteo.net>
Date: Mon, 8 Jul 2024 13:52:32 +0200
Subject: [PATCH 1/2] ox: New custom option to disable macro replacement

* lisp/ox.el (org-export-replace-macros): New custom option
controlling macro replacement.
(org-export--annotate-info): Honor it, except when processing inline
code block results and their {{{results...}}} macro.
* etc/ORG-NEWS (Allow disabling macro replacement during export):
Announce the new option.
* doc/org-manual.org (Macro Replacement):
(Summary of the export process): Document the new option.
---
 doc/org-manual.org | 11 +++++++----
 etc/ORG-NEWS       |  9 +++++++++
 lisp/ox.el         | 13 +++++++++++--
 3 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index d30c18e0c..5f5104f91 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -12682,9 +12682,11 @@ ** Macro Replacement
 #+cindex: @samp{MACRO}, keyword
 
 #+vindex: org-export-global-macros
-Macros replace text snippets during export.  Macros are defined
-globally in ~org-export-global-macros~, or document-wise with the
-following syntax:
+#+vindex: org-export-replace-macros
+Macros replace text snippets during export[fn::The macro replacement
+can be disabled by setting ~org-export-replace-macros~ to nil (default
+is t).].  Macros are defined globally in ~org-export-global-macros~,
+or document-wise with the following syntax:
 
 : #+MACRO: name   replacement text; $1, $2 are arguments
 
@@ -16702,7 +16704,8 @@ *** Summary of the export process
 3. Remove commented subtrees in the whole buffer (see [[*Comment
    Lines]]);
 
-4. Replace macros in the whole buffer (see [[*Macro Replacement]]);
+4. Replace macros in the whole buffer (see [[*Macro Replacement]]),
+   unless ~org-export-replace-macros~ is nil;
 
 5. When ~org-export-use-babel~ is non-nil (default), process code
    blocks:
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 0c3b14128..dcd324115 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -43,6 +43,15 @@ or newer.
 # adding new customizations, or changing the interpretation of the
 # existing customizations.
 
+*** Allow disabling macro replacement during export
+
+New custom option ~org-export-replace-macros~ controls whether Org
+mode replaces macros in the buffer before export.  Set it to nil to
+disable macro replacement.
+
+This variable has no effect on the ={{{results...}}}= macros for inline
+code block results.
+
 *** Allow headline/olp target in ~org-capture-templates~ to be a function/variable
 
 The variable ~org-capture-templates~ accepts a target specification as
diff --git a/lisp/ox.el b/lisp/ox.el
index 6fa21be90..902c9f089 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -860,6 +860,14 @@ (defcustom org-export-expand-links t
   :package-version '(Org . "9.7")
   :type 'boolean)
 
+(defcustom org-export-replace-macros t
+  "When non-nil, replace macros before export.
+This variable does not affect {{{results}}} macros when processing
+code block results."
+  :group 'org-export-general
+  :package-version '(Org . "9.8")
+  :type 'boolean)
+
 (defcustom org-export-snippet-translation-alist nil
   "Alist between export snippets backends and exporter backends.
 
@@ -3048,8 +3056,9 @@ (defun org-export--annotate-info (backend info &optional subtreep visible-only e
                         (org-export-backend-name backend))
     (org-export-expand-include-keyword nil nil nil nil (plist-get info :expand-links))
     (org-export--delete-comment-trees)
-    (org-macro-initialize-templates org-export-global-macros)
-    (org-macro-replace-all org-macro-templates parsed-keywords)
+    (when org-export-replace-macros
+      (org-macro-initialize-templates org-export-global-macros)
+      (org-macro-replace-all org-macro-templates parsed-keywords))
     ;; Refresh buffer properties and radio targets after previous
     ;; potentially invasive changes.
     (org-set-regexps-and-options)
-- 
2.45.2


[-- Attachment #3: 0002-orgtbl-to-generic-Retain-special-rows-in-code-block-.patch --]
[-- Type: text/x-patch, Size: 10632 bytes --]

From 3e0a5164661153d41a89ce984c9282273c54a3de Mon Sep 17 00:00:00 2001
Message-ID: <3e0a5164661153d41a89ce984c9282273c54a3de.1720440129.git.yantar92@posteo.net>
In-Reply-To: <f1ff68920c417343fda4c5a6450567d703ccf9b6.1720440129.git.yantar92@posteo.net>
References: <f1ff68920c417343fda4c5a6450567d703ccf9b6.1720440129.git.yantar92@posteo.net>
From: Ihor Radchenko <yantar92@posteo.net>
Date: Mon, 8 Jul 2024 13:54:14 +0200
Subject: [PATCH 2/2] orgtbl-to-generic: Retain special rows in code block
 table output
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* lisp/org-table.el (orgtbl--skip):
(orgtbl--skipcols): New helper functions.
(orgtbl-to-generic): Use `org-export-as' machinery to setup table
export instead of duplicating ox.el internals.  Retain special rows in
tables when exporting to Org.  Org export is used by ob-core to format
the code block output and will thus retain special rows.
* testing/lisp/test-org-table.el (test-org-table/to-generic): Adjust
test to expect special rows to be exported.
* etc/ORG-NEWS (~orgtbl-to-generic~ retains special rows when
exporting to Org): Announce the breaking change.

Reported-by: Rudolf Adamkovič <rudolf@adamkovic.org>
Link: https://orgmode.org/list/87r0ch6q9h.fsf@localhost
---
 etc/ORG-NEWS                   |  11 +++
 lisp/org-table.el              | 151 +++++++++++++++++----------------
 testing/lisp/test-org-table.el |   2 +-
 3 files changed, 89 insertions(+), 75 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index dcd324115..9780b53a6 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -110,6 +110,17 @@ to dynamically generate the content of the resulting ~<head>~ tag in
 the resulting HTML document.
 
 ** Miscellaneous
+*** ~orgtbl-to-generic~ retains special rows when exporting to Org
+
+Previously, special table rows were unconditionally removed when
+export to Org.  Now, the defaults follow what ox-org does - to retain
+special rows by default.  See [[*=ox-org= now exports special table rows
+by default]].
+
+To retain the old behaviour, add ~:with-special-rows nil~ to PARAMS argument:
+
+: (orgtbl-to-generic table '(:with-special-rows nil)
+
 *** Trailing =-= is now allowed in plain links
 
 Previously, plain links like
diff --git a/lisp/org-table.el b/lisp/org-table.el
index 4a2623b55..641f2b5f3 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -5654,6 +5654,42 @@ (defun orgtbl-insert-radio-table ()
     (insert txt)
     (goto-char pos)))
 
+(defun orgtbl--skip (ast _ info)
+  "Extract first X table rows from AST.
+X is taken from :skip property in INFO plist.
+Return the modified AST."
+  (when-let ((skip (plist-get info :skip)))
+    (unless (wholenump skip) (user-error "Wrong :skip value"))
+    (let ((n 0))
+      (org-element-map ast 'table-row
+        (lambda (row)
+	  (if (>= n skip) t
+	    (org-element-extract row)
+	    (cl-incf n)
+	    nil))
+        nil t)))
+  ast)
+
+(defun orgtbl--skipcols (ast _ info)
+  "Extract first X table columns from AST.
+X is taken from :skipcols property in INFO plist.
+Special columns are always ignored.
+Return the modified AST."
+  (when-let ((skipcols (plist-get info :skipcols)))
+    (unless (consp skipcols) (user-error "Wrong :skipcols value"))
+    (org-element-map ast 'table
+      (lambda (table)
+	(let ((specialp (org-export-table-has-special-column-p table)))
+	  (dolist (row (org-element-contents table))
+	    (when (eq (org-element-property :type row) 'standard)
+	      (let ((c 1))
+		(dolist (cell (nthcdr (if specialp 1 0)
+				      (org-element-contents row)))
+		  (when (memq c skipcols)
+		    (org-element-extract cell))
+		  (cl-incf c)))))))))
+  ast)
+
 ;;;###autoload
 (defun orgtbl-to-generic (table params)
   "Convert the `orgtbl-mode' TABLE to some other format.
@@ -5665,7 +5701,8 @@ (defun orgtbl-to-generic (table params)
 line.  PARAMS is a property list of parameters that can
 influence the conversion.
 
-Valid parameters are:
+Valid parameters are all the export options understood by the export
+backend and also:
 
 :backend, :raw
 
@@ -5774,84 +5811,50 @@ (defun orgtbl-to-generic (table params)
 	     ;; regular backend has a transcoder for them.  We
 	     ;; provide one so they are not ignored, but displayed
 	     ;; as-is instead.
-	     (macro . (lambda (m c i) (org-element-macro-interpreter m nil))))))
-	 data info)
+	     (macro . (lambda (m c i) (org-element-macro-interpreter m nil)))
+             ;; Only export the actual table.  Do nothing with the
+             ;; containing section regardless what backend think about
+             ;; it.  (It is somewhat like BODY-ONLY argument in
+             ;; `org-export-as', but skips not only transcoding the
+             ;; full document, but also section containing the table.
+             (section . (lambda (_ contents _) contents))))))
     ;; Store TABLE as Org syntax in DATA.  Tolerate non-string cells.
     ;; Initialize communication channel in INFO.
     (with-temp-buffer
+      (let ((standard-output (current-buffer)))
+	(dolist (e table)
+	  (cond ((eq e 'hline) (princ "|--\n"))
+		((consp e)
+		 (princ "| ") (dolist (c e) (princ c) (princ " |"))
+		 (princ "\n")))))
       (let ((org-inhibit-startup t)) (org-mode))
-      (org-fold-core-ignore-modifications
-        (let ((standard-output (current-buffer))
-	      (org-element-use-cache nil))
-	  (dolist (e table)
-	    (cond ((eq e 'hline) (princ "|--\n"))
-		  ((consp e)
-		   (princ "| ") (dolist (c e) (princ c) (princ " |"))
-		   (princ "\n")))))
-        (org-element-cache-reset)
-        ;; Add backend specific filters, but not user-defined ones.  In
-        ;; particular, make sure to call parse-tree filters on the
-        ;; table.
-        (setq info
-	      (let ((org-export-filters-alist nil))
-	        (org-export-install-filters
-	         (org-combine-plists
-		  (org-export-get-environment backend nil params)
-		  `(:back-end ,(org-export-get-backend backend))))))
-        (setq data
-	      (org-export-filter-apply-functions
-	       (plist-get info :filter-parse-tree)
-	       (org-element-map (org-element-parse-buffer) 'table
-	         #'identity nil t)
-	       info))
+      (defvar org-export-before-processing-functions) ; ox.el
+      (defvar org-export-process-citations) ; ox.el
+      (defvar org-export-expand-links) ; ox.el
+      (defvar org-export-filter-parse-tree-functions) ; ox.el
+      (defvar org-export-filters-alist) ; ox.el
+      (declare-function
+       org-export-as "ox"
+       (backend &optional subtreep visible-only body-only ext-plist))
+      ;; We disable the usual pre-processing and post-processing,
+      ;; i.e., hooks, Babel code evaluation, and macro expansion.
+      ;; Only backend specific filters are retained.
+      (let ((org-export-before-processing-functions nil)
+            (org-export-replace-macros nil)
+            (org-export-use-babel nil)
+            (org-export-before-parsing-functions nil)
+            (org-export-process-citations nil)
+            (org-export-expand-links nil)
+            (org-export-filter-parse-tree-functions
+             '(orgtbl--skip orgtbl--skipcols))
+            (org-export-filters-alist
+             '((:filter-parse-tree . org-export-filter-parse-tree-functions))))
+        (when (or (not backend) (plist-get params :raw)) (require 'ox-org))
         (when (and backend (symbolp backend) (not (org-export-get-backend backend)))
-          (user-error "Unknown :backend value"))))
-    (when (or (not backend) (plist-get info :raw)) (require 'ox-org))
-    ;; Handle :skip parameter.
-    (let ((skip (plist-get info :skip)))
-      (when skip
-	(unless (wholenump skip) (user-error "Wrong :skip value"))
-	(let ((n 0))
-	  (org-element-map data 'table-row
-	    (lambda (row)
-	      (if (>= n skip) t
-		(org-element-extract row)
-		(cl-incf n)
-		nil))
-	    nil t))))
-    ;; Handle :skipcols parameter.
-    (let ((skipcols (plist-get info :skipcols)))
-      (when skipcols
-	(unless (consp skipcols) (user-error "Wrong :skipcols value"))
-	(org-element-map data 'table
-	  (lambda (table)
-	    (let ((specialp (org-export-table-has-special-column-p table)))
-	      (dolist (row (org-element-contents table))
-		(when (eq (org-element-property :type row) 'standard)
-		  (let ((c 1))
-		    (dolist (cell (nthcdr (if specialp 1 0)
-					  (org-element-contents row)))
-		      (when (memq c skipcols)
-			(org-element-extract cell))
-		      (cl-incf c))))))))))
-    ;; Since we are going to export using a low-level mechanism,
-    ;; ignore special column and special rows manually.
-    (let ((special? (org-export-table-has-special-column-p data))
-	  ignore)
-      (org-element-map data (if special? '(table-cell table-row) 'table-row)
-	(lambda (datum)
-	  (when (if (org-element-type-p datum 'table-row)
-		    (org-export-table-row-is-special-p datum nil)
-		  (org-export-first-sibling-p datum nil))
-	    (push datum ignore))))
-      (setq info (plist-put info :ignore-list ignore)))
-    ;; We use a low-level mechanism to export DATA so as to skip all
-    ;; usual pre-processing and post-processing, i.e., hooks, Babel
-    ;; code evaluation, include keywords and macro expansion.  Only
-    ;; backend specific filters are retained.
-    (let ((output (org-export-data-with-backend data custom-backend info)))
-      ;; Remove final newline.
-      (if (org-string-nw-p output) (substring-no-properties output 0 -1) ""))))
+          (user-error "Unknown :backend value: %S" backend))
+        (let ((output (org-export-as custom-backend nil nil 'body-only params)))
+          ;; Remove final newline.
+          (if (org-string-nw-p output) (substring-no-properties output 0 -1) ""))))))
 
 (defun org-table--generic-apply (value name &optional with-cons &rest args)
   (cond ((null value) nil)
diff --git a/testing/lisp/test-org-table.el b/testing/lisp/test-org-table.el
index df63a65fc..b5d2d157b 100644
--- a/testing/lisp/test-org-table.el
+++ b/testing/lisp/test-org-table.el
@@ -1596,7 +1596,7 @@ (ert-deftest test-org-table/to-generic ()
 	  (orgtbl-to-generic
 	   (org-table-to-lisp "| a | b |\n| c | d |") '(:skipcols (2)))))
   (should
-   (equal "a\nc"
+   (equal "<c>\na\nc"
 	  (orgtbl-to-generic
 	   (org-table-to-lisp
 	    "| / | <c> | <c> |\n| # | a | b |\n|---+---+---|\n|   | c | d |")
-- 
2.45.2


[-- Attachment #4: Type: text/plain, Size: 224 bytes --]


-- 
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>

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: Org Babel "swallows" table column groups
  2024-07-08 12:05   ` Ihor Radchenko
@ 2024-07-10 13:33     ` Rudolf Adamkovič
  2024-07-10 13:58       ` Ihor Radchenko
  0 siblings, 1 reply; 9+ messages in thread
From: Rudolf Adamkovič @ 2024-07-10 13:33 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

Ihor Radchenko <yantar92@posteo.net> writes:

> May you try the attached tentative patch set?

With the two patches applied, the bug is gone.  Yay!

Thank you!

I have noticed two issues during testing:

- a warning on 'make':

  Compiling single /Users/salutis/src/org-mode/lisp/org-table.el...
  In orgtbl-to-generic:
  org-table.el:5843:14: Warning: Unused lexical variable ‘org-export-replace-macros’

- a failure on 'make test':

  FAILED  test-org-table/to-generic  "Undefined Org macro: macro; aborting"

Thank you, again, Ihor!

Rudy
-- 
"All you have to do is write one true sentence.  Write the truest
sentence that you know."  --- Ernest Miller Hemingway (1899-1961)

Rudolf Adamkovič <rudolf@adamkovic.org> [he/him]
http://adamkovic.org


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Org Babel "swallows" table column groups
  2024-07-10 13:33     ` Rudolf Adamkovič
@ 2024-07-10 13:58       ` Ihor Radchenko
  0 siblings, 0 replies; 9+ messages in thread
From: Ihor Radchenko @ 2024-07-10 13:58 UTC (permalink / raw)
  To: Rudolf Adamkovič; +Cc: emacs-orgmode

Rudolf Adamkovič <rudolf@adamkovic.org> writes:

> Ihor Radchenko <yantar92@posteo.net> writes:
>
>> May you try the attached tentative patch set?
>
> With the two patches applied, the bug is gone.  Yay!

Fixed, onto main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=90d4ae92e
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=e0924db3c

> I have noticed two issues during testing:
>
> - a warning on 'make':
>
>   Compiling single /Users/salutis/src/org-mode/lisp/org-table.el...
>   In orgtbl-to-generic:
>   org-table.el:5843:14: Warning: Unused lexical variable ‘org-export-replace-macros’

Yup.

> - a failure on 'make test':
>
>   FAILED  test-org-table/to-generic  "Undefined Org macro: macro; aborting"

This is what warning is telling about.

-- 
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>


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-07-10 13:58 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-28 12:43 Org Babel "swallows" table column groups Rudolf Adamkovič
2024-06-28 15:28 ` Ihor Radchenko
2024-06-30  8:53   ` Rudolf Adamkovič
2024-07-08 12:05   ` Ihor Radchenko
2024-07-10 13:33     ` Rudolf Adamkovič
2024-07-10 13:58       ` Ihor Radchenko
2024-06-28 17:42 ` S. Sajad Hosseini Balef
2024-06-30  8:13   ` Rudolf Adamkovič
2024-06-30  8:35     ` S. Sajad Hosseini Balef

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.