emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [parser] feature request: column and row numbers available for table-cell elements
@ 2017-01-18 21:55 Eric S Fraga
  2017-01-19 21:15 ` Nicolas Goaziou
       [not found] ` <a6c057b982054dc896ad78973aa0d220@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>
  0 siblings, 2 replies; 4+ messages in thread
From: Eric S Fraga @ 2017-01-18 21:55 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 2066 bytes --]

Hello,

I have been writing a derived backend for LaTeX export which outputs the
formulae used in a table.  This is for teaching purposes where I
currently use an external spreadsheet to illustrate some simple
modelling concepts.  I would prefer to use org (as my slides are
generated by org via beamer) and am able to output a formatted table of
the formulae used in a table.

However, due to various possible hidden rows and columns that do not
appear in the exported table, the row and column references are not
easily usable directly to identify the reference entries in the table.

Would it be possible to extend the table-cell element in the parser to
add :row and :column attributes that have the internal org values, as
used by the formulae?

An example table that I have been using to test my derived backend and
which illustrates the issue is:

#+begin_src org
  |   | Strategy | Average performance |
  |---+----------+---------------------|
  | / |          |                8.69 |
  | / |          |                9.72 |
  | / |          |                9.03 |
  |---+----------+---------------------|
  |   |        1 |                9.15 |
  |---+----------+---------------------|
  | / |          |                9.15 |
  | / |          |                7.60 |
  | / |          |                7.46 |
  |---+----------+---------------------|
  |   |        2 |                8.07 |
  |---+----------+---------------------|
  ,#+TBLFM: @5$3=vmean(@-I..@-II);%.2f::@9$3=vmean(@-I..@-II);%.2f
#+end_src

This table does not export the first column nor any of the rows with /
in the first column.  So, in the exported table, there are only 3 rows
and 2 columns but the formulae refer to, e.g. column 3 and row 9.  I
would like to be able to annotate the output with the org row and column
numbers so need access to these data.

A screenshot of what the derived backend generates currently is attached.

thanks,
eric

-- 
: Eric S Fraga (0xFFFCF67D), Emacs 26.0.50.1, Org release_9.0.2-104-gf5b7de

[-- Attachment #1.2: screendump-20170118214644.png --]
[-- Type: image/png, Size: 19319 bytes --]

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 194 bytes --]

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

* Re: [parser] feature request: column and row numbers available for table-cell elements
  2017-01-18 21:55 [parser] feature request: column and row numbers available for table-cell elements Eric S Fraga
@ 2017-01-19 21:15 ` Nicolas Goaziou
       [not found] ` <a6c057b982054dc896ad78973aa0d220@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>
  1 sibling, 0 replies; 4+ messages in thread
From: Nicolas Goaziou @ 2017-01-19 21:15 UTC (permalink / raw)
  To: emacs-orgmode

Hello,

Eric S Fraga <e.fraga@ucl.ac.uk> writes:

> Would it be possible to extend the table-cell element in the parser to
> add :row and :column attributes that have the internal org values, as
> used by the formulae?

I don' think this is needed since this information is readily available
during the export process. For example

  (1+ (length (org-export-get-previous-element table-cell info 'all)))

returns the column number table-cell belongs to, whereas

  (1+ (cl-count-if
       (lambda (row) (eq (org-element-property :type row) 'standard))
       (org-export-get-previous-element (org-export-get-parent table-cell) 'all)))

returns the row number.

Regards,

-- 
Nicolas Goaziou

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

* Re: [parser] feature request: column and row numbers available for table-cell elements
       [not found] ` <a6c057b982054dc896ad78973aa0d220@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>
@ 2017-01-19 22:18   ` Eric S Fraga
  2017-01-20  8:09   ` Eric S Fraga
  1 sibling, 0 replies; 4+ messages in thread
From: Eric S Fraga @ 2017-01-19 22:18 UTC (permalink / raw)
  To: emacs-orgmode

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

On Thursday, 19 Jan 2017 at 21:15, Nicolas Goaziou wrote:
> Hello,
>
> Eric S Fraga <e.fraga@ucl.ac.uk> writes:
>
>> Would it be possible to extend the table-cell element in the parser to
>> add :row and :column attributes that have the internal org values, as
>> used by the formulae?
>
> I don' think this is needed since this information is readily available
> during the export process. For example

Ah, okay.  Sounds good.  Counting each time seems inefficient at first
glance but I guess it's not a real issue, especially in my case where
the tables are all quite small.  I'll give this a try tomorrow.

Thanks,
eric

-- 
: Eric S Fraga (0xFFFCF67D), Emacs 26.0.50.1, Org release_9.0.3-241-gc3d67b

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 194 bytes --]

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

* Re: [parser] feature request: column and row numbers available for table-cell elements
       [not found] ` <a6c057b982054dc896ad78973aa0d220@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>
  2017-01-19 22:18   ` Eric S Fraga
@ 2017-01-20  8:09   ` Eric S Fraga
  1 sibling, 0 replies; 4+ messages in thread
From: Eric S Fraga @ 2017-01-20  8:09 UTC (permalink / raw)
  To: emacs-orgmode

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

Hi Nicolas,

On Thursday, 19 Jan 2017 at 21:15, Nicolas Goaziou wrote:
> I don' think this is needed since this information is readily available
> during the export process. For example
>
>   (1+ (length (org-export-get-previous-element table-cell info 'all)))

Well, this returns the column number in the elided table, not the
original table.  In other words, after columns have been removed before
processing for export.

I need the row and column numbers in the original table in the org file,
not what is actually exported!

> returns the column number table-cell belongs to, whereas
>
>   (1+ (cl-count-if
>        (lambda (row) (eq (org-element-property :type row) 'standard))
>        (org-export-get-previous-element (org-export-get-parent table-cell) 'all)))

And this one gives me an error which I do not understand:

,----
| Debugger entered--Lisp error: (wrong-type-argument listp table-row)
|   org-element-property(:type table-row)
|   (eq (org-element-property :type row) (quote standard))
|   (lambda (row) (eq (org-element-property :type row) (quote standard)))(table-row)
|   cl-count(nil (table-row (:type rule :begin 76 :end 96 :contents-begin nil [...]
|   apply(cl-count nil (table-row (:type rule :begin 76 :end 96 [...]
|   cl-count-if((lambda (row) (eq (org-element-property :type row) [...]
`----

Any suggestions very welcome!

Thanks,
eric

-- 
: Eric S Fraga (0xFFFCF67D), Emacs 26.0.50.1, Org release_9.0.3-241-gc3d67b

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 194 bytes --]

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

end of thread, other threads:[~2017-01-20 17:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-18 21:55 [parser] feature request: column and row numbers available for table-cell elements Eric S Fraga
2017-01-19 21:15 ` Nicolas Goaziou
     [not found] ` <a6c057b982054dc896ad78973aa0d220@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>
2017-01-19 22:18   ` Eric S Fraga
2017-01-20  8:09   ` Eric S Fraga

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).