Re: BUG: org-table: table option “:missing” not working (in ob-gnuplot.el)

2021-10-01 Thread Ihor Radchenko
Nicolas Goaziou  writes:

>> At this point, third-party code is likely to rely on the existing logic,
>> so I do not see any reason to insist on changing org-table.
>
> If you think it is overall an improvement, feel free to discuss it. I'm
> merely pointing out what was the initial intent, not necessarily how it
> should be.

I feel that it would be more consistent, though not necessary an
improvement.  Special formatting for empty cells is probably a rare
need---much more rare compared to skipping them.  I am fine with current
behaviour if it is documented.  It's just that it caught me by surprise
while fixing the current bug report.

>> To avoid confusion, can we change the docstring explicitly saying that
>> empty cells are ignored? (see the attached)

> Sure. Thanks.

Applied as 60365a164 on main.

Best,
Ihor



Re: BUG: org-table: table option “:missing” not working (in ob-gnuplot.el)

2021-10-01 Thread Nicolas Goaziou
Hello,

Ihor Radchenko  writes:

> At this point, third-party code is likely to rely on the existing logic,
> so I do not see any reason to insist on changing org-table.

If you think it is overall an improvement, feel free to discuss it. I'm
merely pointing out what was the initial intent, not necessarily how it
should be.

> To avoid confusion, can we change the docstring explicitly saying that
> empty cells are ignored? (see the attached)

Sure. Thanks.

Regards,
-- 
Nicolas Goaziou



Re: BUG: org-table: table option “:missing” not working (in ob-gnuplot.el)

2021-09-30 Thread Ihor Radchenko
Nicolas Goaziou  writes:

> I'm not sure. I wrote this some years ago. I guess the rationale at that
> time was that it didn't feel useful to apply a format to an empty cell.
> For example, if you use `:fmt "$%s$"', I assume you wouldn't want to get
> "$$" in otherwise empty cells.

Also makes sense.

At this point, third-party code is likely to rely on the existing logic,
so I do not see any reason to insist on changing org-table.

To avoid confusion, can we change the docstring explicitly saying that
empty cells are ignored? (see the attached)

Best,
Ihor

>From 60365a164147dfc71f0047661c143b54064a459b Mon Sep 17 00:00:00 2001
Message-Id: <60365a164147dfc71f0047661c143b54064a459b.1633060596.git.yanta...@gmail.com>
From: Ihor Radchenko 
Date: Fri, 1 Oct 2021 11:40:54 +0800
Subject: [PATCH] orgtbl-to-generic: Mention that :fmt is ignored for empty
 cells

* lisp/org-table.el (orgtbl-to-generic): Amend docstring mentioning
that :fmt is ignored for empty table cells.
---
 lisp/org-table.el | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lisp/org-table.el b/lisp/org-table.el
index 89c57fb06..3fed15054 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -5649,6 +5649,9 @@ (defun orgtbl-to-generic (table params)
 
 (:fmt (2 \"$%s$\" 4 (lambda (c) (format \"$%s$\" c
 
+  The format is ignored for empty fields.  Use :raw t with non-nil
+  :backend option to force formatting empty fields.
+
 :hlstart :hllstart :hlend :hllend :hsep :hlfmt :hllfmt :hfmt
 
  Same as above, specific for the header lines in the table.
-- 
2.32.0



Re: BUG: org-table: table option “:missing” not working (in ob-gnuplot.el)

2021-09-30 Thread Ihor Radchenko
Ihor Radchenko  writes:

> The attached patch should fix the issue, though it may be more
> reasonable to fix orgtbl-to-generic logic.

Given Nicholas' reply, changing orgtbl-to-generic may not be a good idea
and break other code using orgtbl-to-generic.

Applied as ddee7b617 on bugfix

Best,
Ihor



Fixed



Re: BUG: org-table: table option “:missing” not working (in ob-gnuplot.el)

2021-09-30 Thread Nicolas Goaziou
Hello,

Ihor Radchenko  writes:

> Nicolas,
>
> Is there a rationale behind bypassing :fmt and :hfmt for empty table
> cells in `org-table--to-generic-cell'? In this patch, I have to work
> around this using :raw parameter in `orgtbl-to-generic' call. I do not
> feel like such workaround should be needed.

I'm not sure. I wrote this some years ago. I guess the rationale at that
time was that it didn't feel useful to apply a format to an empty cell.
For example, if you use `:fmt "$%s$"', I assume you wouldn't want to get
"$$" in otherwise empty cells.

Regards,
-- 
Nicolas Goaziou



Re: BUG: org-table: table option “:missing” not working (in ob-gnuplot.el)

2021-09-30 Thread Ihor Radchenko
Robert Klein  writes:

> When trying to run a table with missing values with ob-gnuplot.el
> there's a “:missing value” option.  ob-gnuplot is supposed to put the
> “value” into the place of empty cell values before calling on gnuplot.
> It doesn't do this currently.

Confirmed

The problem is partially because of the way `org-table--to-generic-cell'
works. It disallows custom processing of empty table cells unless both
:raw and :backend arguments are supplied to `orgtbl-to-generic'.

The attached patch should fix the issue, though it may be more
reasonable to fix orgtbl-to-generic logic.

Nicolas,

Is there a rationale behind bypassing :fmt and :hfmt for empty table
cells in `org-table--to-generic-cell'? In this patch, I have to work
around this using :raw parameter in `orgtbl-to-generic' call. I do not
feel like such workaround should be needed.

Best,
Ihor

>From 7033289d7e717eb841d550fbdbc0cc878b96cd32 Mon Sep 17 00:00:00 2001
Message-Id: <7033289d7e717eb841d550fbdbc0cc878b96cd32.1633005978.git.yanta...@gmail.com>
From: Ihor Radchenko 
Date: Thu, 30 Sep 2021 20:40:37 +0800
Subject: [PATCH] ob-gnuplot: Honour :missing argument

* lisp/ob-gnuplot.el (org-babel-gnuplot-table-to-data): Force applying
`org-babel-gnuplot-quote-tsv-field' to empty table cells when
converting org tables to gnuplot input.  By default,
`orgtbl-to-generic' ignores :fmt for empty table cells.  We need to
set :raw to non-nil AND :backend to non-nil to force custom formatting
of empty table cells.

Fixes https://orgmode.org/list/20210617211347.59e4d...@happy.intern.roklein.de
---
 lisp/ob-gnuplot.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/ob-gnuplot.el b/lisp/ob-gnuplot.el
index 6489c23f5..120aaa18e 100644
--- a/lisp/ob-gnuplot.el
+++ b/lisp/ob-gnuplot.el
@@ -272,7 +272,7 @@ (defun org-babel-gnuplot-table-to-data (table data-file params)
 	  (orgtbl-to-generic
 	   table
 	   (org-combine-plists
-		'(:sep "\t" :fmt org-babel-gnuplot-quote-tsv-field)
+		'(:sep "\t" :fmt org-babel-gnuplot-quote-tsv-field :raw t :backend ascii)
 		params)
   data-file)
 
-- 
2.32.0



BUG: org-table: table option “:missing” not working (in ob-gnuplot.el)

2021-06-17 Thread Robert Klein
Hi everyone,
 a bug report:


Emacs  : GNU Emacs 27.2 (build 1, x86_64-unknown-openbsd, GTK+ Version 2.24.33)
 of 2021-04-20
Package: Org mode version 9.4.6 (release_9.4.6-4-g093c94 @ 
/home/roklein/.emacs.d/org-mode/lisp/)


When trying to run a table with missing values with ob-gnuplot.el
there's a “:missing value” option.  ob-gnuplot is supposed to put the
“value” into the place of empty cell values before calling on gnuplot.
It doesn't do this currently.  Bi-secting suggests,
“9209aa3c9d456bcfdd9d8cd223367f7cfb6b3231 is the first bad commit”:

--  commit 9209aa3c9d456bcfdd9d8cd223367f7cfb6b3231
--  Author: Nicolas Goaziou 
--  --  Sun Aug 24 01:31:56 2014 +0200
--
--  org-table: Use "ox.el" internally for radio tables


By my reading:
- in ob-gnuplot.el:org-babel-gnuplot-process-vars :missing variable is
  read, used in
- ob-gnuplot.el:org-babel-gnuplot-quote-tsv-field, called from
- ob-gnuplot.el:org-babel-gnuplot-table-to-data
- used in org-table.el:orgtbl-to-generic (as (part of the) :fmt param)
- which calls org-table--to-generic-cell
- which calle org-table.el:org-table--generic-apply
- which I don't understand

my dotemacs and a sample org file are attached.

When running the code (e.g. C-c C-c on the #+Call: line), temporary
files are created in /tmp/babel-/gnuplot.

These files should have "?" (as choosen :missing).  In the current
version there is nothing, so gnuplot uses up the values in the following
columns and the resulting graph is wrong.

Also, I couldn't find this in the manual, but there's a thread “using
gnuplot's "splot" and "every" comma nds on org-mode table” on the
mailing list (2013/09/23 - 3013/09/25) about the :missing feature.

Thanks for any help.

Best regards
Robert



gp.org
Description: Binary data


dotemacs
Description: Binary data