emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* include value of single table cell in text?
@ 2010-07-27  8:45 Austin Frank
  2010-07-27 14:43 ` Eric Schulte
  0 siblings, 1 reply; 3+ messages in thread
From: Austin Frank @ 2010-07-27  8:45 UTC (permalink / raw)
  To: emacs-orgmode


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

Hello!

Is it possible to include the value of a single cell from an org-mode
table in the body of an org-mode document? That is, given

#+TBLNAME:  test-table
| key | value |
|-----+-------|
| a   |     1 |
| b   |     2 |

Is there any way to refer to cell @2$2 within the text of an org-mode
document, and have that reference converted to the value "2" during
export?

I believe one approach would be to use babel's in-line source evaluation
capabilities along with the remote() function from the org spreadsheet
editor.  But I haven't yet been able to identify the right combination
of those functions to get the desired result.  This, for example,
doesn't work for me:

--8<---------------cut here---------------start------------->8---
#+TBLNAME:  test-table
| key | value |
|-----+-------|
| a   | 1     |
| b   | 2     |

I'm testing to see whether
src_emacs-lisp{(org-table-eval-formula "remote(test-table @2$2)")}
works.
--8<---------------cut here---------------end--------------->8---

It throws an error during export, because I'm not in a table data field.


Additionally, if there's not already a built-in way to do this, I'd
nominate this functionality for some special syntax.  Following babel's
inlining and remote reference conventions, maybe

  table{test-table @2$2}

or

  <<test-table:@2$2>>

This would make it very easy to refer to specific elements the tabular
output of babel blocks, adding to the utility of babel as a
meta-programming language for org-mode.


Thanks for any help!
/au

-- 
Austin Frank
http://aufrank.net
GPG Public Key (D7398C2F): http://aufrank.net/personal.asc

[-- Attachment #1.2: Type: application/pgp-signature, Size: 194 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: include value of single table cell in text?
  2010-07-27  8:45 include value of single table cell in text? Austin Frank
@ 2010-07-27 14:43 ` Eric Schulte
  2010-07-28 18:38   ` Austin Frank
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Schulte @ 2010-07-27 14:43 UTC (permalink / raw)
  To: Austin Frank; +Cc: emacs-orgmode

The following should work.  It uses an inline code block

--8<---------------cut here---------------start------------->8---
#+TBLNAME:  test-table
| key | value |
|-----+-------|
| a   |     1 |
| b   |     2 |

Is there any way to refer to cell @2$2 within the text of an org-mode
document, and have that reference converted to the value
src_emacs-lisp[:var d=test-table[3,1]]{d} during export?
--8<---------------cut here---------------end--------------->8---

Best -- Eric

Austin Frank <austin.frank@gmail.com> writes:

> Hello!
>
> Is it possible to include the value of a single cell from an org-mode
> table in the body of an org-mode document? That is, given
>
> #+TBLNAME:  test-table
> | key | value |
> |-----+-------|
> | a   |     1 |
> | b   |     2 |
>
> Is there any way to refer to cell @2$2 within the text of an org-mode
> document, and have that reference converted to the value "2" during
> export?
>
> I believe one approach would be to use babel's in-line source evaluation
> capabilities along with the remote() function from the org spreadsheet
> editor.  But I haven't yet been able to identify the right combination
> of those functions to get the desired result.  This, for example,
> doesn't work for me:
>
> #+TBLNAME:  test-table
> | key | value |
> |-----+-------|
> | a   | 1     |
> | b   | 2     |
>
> I'm testing to see whether
> src_emacs-lisp{(org-table-eval-formula "remote(test-table @2$2)")}
> works.
>
> It throws an error during export, because I'm not in a table data field.
>
>
> Additionally, if there's not already a built-in way to do this, I'd
> nominate this functionality for some special syntax.  Following babel's
> inlining and remote reference conventions, maybe
>
>   table{test-table @2$2}
>
> or
>
>   <<test-table:@2$2>>
>
> This would make it very easy to refer to specific elements the tabular
> output of babel blocks, adding to the utility of babel as a
> meta-programming language for org-mode.
>
>
> Thanks for any help!
> /au

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

* Re: include value of single table cell in text?
  2010-07-27 14:43 ` Eric Schulte
@ 2010-07-28 18:38   ` Austin Frank
  0 siblings, 0 replies; 3+ messages in thread
From: Austin Frank @ 2010-07-28 18:38 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode


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

On Tue, Jul 27 2010, Eric Schulte wrote:

> The following should work.  It uses an inline code block
>
> #+TBLNAME:  test-table
> | key | value |
> |-----+-------|
> | a   |     1 |
> | b   |     2 |
>
> Is there any way to refer to cell @2$2 within the text of an org-mode
> document, and have that reference converted to the value
> src_emacs-lisp[:var d=test-table[3,1]]{d} during export?

Eric--

This is great!  Thanks very much.  If you're accepting feature requests,
I'd still love to have a way to use org-table reference syntax to embed
cell values inline.  I don't know whether this is better thought of as a
core or babel feature, though.

Looking at the source of org-table-fix-formulas and
org-table-eval-formula in org-table.el, there may be some room for
refactoring the reference resolution procedure into a standalone
function.  I'm in the middle of wrapping up my thesis and moving, so I
definitely won't look at this any time soon.  If this itch still needs
scratching in September I may revisit it then.  If a talented soul
addresses it before then, even better!

Thanks again,
/au

-- 
Austin Frank
http://aufrank.net
GPG Public Key (D7398C2F): http://aufrank.net/personal.asc

[-- Attachment #1.2: Type: application/pgp-signature, Size: 194 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

end of thread, other threads:[~2010-07-28 18:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-27  8:45 include value of single table cell in text? Austin Frank
2010-07-27 14:43 ` Eric Schulte
2010-07-28 18:38   ` Austin Frank

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