Re: Org Babel "swallows" table column groups

2024-07-10 Thread Ihor Radchenko
Rudolf Adamkovič  writes:

> Ihor Radchenko  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 .
Support Org development at ,
or support my work at 



Re: Org Babel "swallows" table column groups

2024-07-10 Thread Rudolf Adamkovič
Ihor Radchenko  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č  [he/him]
http://adamkovic.org



Re: Org Babel "swallows" table column groups

2024-07-08 Thread Ihor Radchenko
Ihor Radchenko  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?

>From f1ff68920c417343fda4c5a6450567d703ccf9b6 Mon Sep 17 00:00:00 2001
Message-ID: 
From: Ihor Radchenko 
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

>From 3e0a5164661153d41a89ce984c9282273c54a3de Mon Sep 17 00:00:00 2001
Message-ID: <3e0a5164661153d41a8

Re: Org Babel "swallows" table column groups

2024-06-30 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> Rudolf Adamkovič  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č  [he/him]
http://adamkovic.org



Re: Org Babel "swallows" table column groups

2024-06-30 Thread S. Sajad Hosseini Balef

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




Re: Org Babel "swallows" table column groups

2024-06-30 Thread Rudolf Adamkovič
"S. Sajad Hosseini Balef"  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č  [he/him]
http://adamkovic.org



Re: Org Babel "swallows" table column groups

2024-06-28 Thread S. Sajad Hosseini Balef
e-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: 
 
X-ME-Received: 

X-ME-Proxy-Cause: 
gggruggvucftvghtrhhoucdtuddrgeeftddrtdeigdehhecutefuodetggdotefrodftvf

 curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu
 uegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkfggtgfgsehtqhertddttd
 ejnecuhfhrohhmpeftuhguohhlfhcutegurghmkhhovhhitgcuoehruhguohhlfhesrggu
 rghmkhhovhhitgdrohhrgheqnecuggftrfgrthhtvghrnhepkeelkeevtdeiudevvedtff
 eghfdvgffhkeeileehtefhudeiueetudegheffvdffnecuffhomhgrihhnpegruggrmhhk
 ohhvihgtrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh
 hfrhhomheprhhuugholhhfsegruggrmhhkohhvihgtrdhorhhg
X-ME-Proxy: 
 
 
 
 
Feedback-ID: i88214938:Fastmail
Received: by mail.messagingengine.com (Postfix) with ESMTPA for
 ; Fri, 28 Jun 2024 08:43:34 -0400 (EDT)
From: =?utf-8?Q?Rudolf_Adamkovi=C4=8D?= 
To: emacs-orgmode@gnu.org
Subject: Org Babel "swallows" table column groups
Date: Fri, 28 Jun 2024 14:43:31 +0200
Message-ID: 
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=rud...@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." 
List-Unsubscribe: <https://lists.gnu.org/mailman/options/emacs-orgmode>,
 <mailto:emacs-orgmode-requ...@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-requ...@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/emacs-orgmode>,
 <mailto:emacs-orgmode-requ...@gnu.org?subject=subscribe>
Errors-To: emacs-orgmode-bounces+larch=yhetil@gnu.org
Sender: emacs-orgmode-bounces+larch=yhetil@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  [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

shossei...@ut.ac.ir
From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: 
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 )
for ; Fri, 28 Jun 2024 12:46:17 +
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 )
for ; Fri, 28 Jun 2024 14:46:17 +0200
X-Envelope-To: la...@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@gnu.org" designates 209.51.188.17 as 
permitted sender) smtp.mailfrom="emacs-orgmod

Re: Org Babel "swallows" table column groups

2024-06-28 Thread Ihor Radchenko
Rudolf Adamkovič  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@mat.ucm.es/

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Org Babel "swallows" table column groups

2024-06-28 Thread Rudolf Adamkovič
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č  [he/him]
http://adamkovic.org