emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Help with tangling a table into a source-code representation of the data contained within
@ 2014-02-25  4:37 Grant Rettke
  2014-02-25  4:45 ` Samuel Wales
  2014-02-25  4:49 ` Thomas S. Dye
  0 siblings, 2 replies; 6+ messages in thread
From: Grant Rettke @ 2014-02-25  4:37 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org

Hi,

My goal is to define a table in org-mode, display it nicely to humans
using export, and tangle that same data table into
an elisp data structure for use elsewhere within the program. It might
look something like this:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

* Modes

This is a place for humans to keep track both of what
modes activated for what file types; and also what utilies are used
with those modes when they are activated.

#+tblname: modes_data
| mode name | file_type | paredit | auto-save |
|-----------+-----------+---------+-----------|
| scheme | .scm  | yes     | yes       |
| elisp     | .el       | yes     | yes       |
| ielm      | nil       | yes     | no        |

* Test

#+begin_src emacs-lisp :noweb tangle :tangle test.el
  (mapcar (lambda (row) (message (car row))) modes_data)
#+end_src

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

The problem right now is that modes_data is referenced but not defined
anywhere in the tangled file.
How do I include the data itself from modes_data as an elisp data
structure to be defined during the tangling?

What I need help with is:

1. Is the goal I seek realistic?
2. What am I doing wrongly?

An alternative that I figured would work fine is to define modes_data
in a code block with elisp and export
that in the tangling; it would be nicer to use the org table features though.

Regards,

-- 
Grant Rettke | ACM, AMA, COG, IEEE
gcr@wisdomandwonder.com | http://www.wisdomandwonder.com/
“Wisdom begins in wonder.” --Socrates
((λ (x) (x x)) (λ (x) (x x)))
“Life has become immeasurably better since I have been forced to stop
taking it seriously.” --Thompson

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

* Re: Help with tangling a table into a source-code representation of the data contained within
  2014-02-25  4:37 Help with tangling a table into a source-code representation of the data contained within Grant Rettke
@ 2014-02-25  4:45 ` Samuel Wales
  2014-02-25  4:49 ` Thomas S. Dye
  1 sibling, 0 replies; 6+ messages in thread
From: Samuel Wales @ 2014-02-25  4:45 UTC (permalink / raw)
  To: Grant Rettke; +Cc: emacs-orgmode@gnu.org

radio tables might be another way.

samuel

On 2/24/14, Grant Rettke <gcr@wisdomandwonder.com> wrote:
> Hi,
>
> My goal is to define a table in org-mode, display it nicely to humans
> using export, and tangle that same data table into
> an elisp data structure for use elsewhere within the program. It might
> look something like this:

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

* Re: Help with tangling a table into a source-code representation of the data contained within
  2014-02-25  4:37 Help with tangling a table into a source-code representation of the data contained within Grant Rettke
  2014-02-25  4:45 ` Samuel Wales
@ 2014-02-25  4:49 ` Thomas S. Dye
  2014-02-25  9:00   ` Rainer M Krug
  1 sibling, 1 reply; 6+ messages in thread
From: Thomas S. Dye @ 2014-02-25  4:49 UTC (permalink / raw)
  To: Grant Rettke; +Cc: emacs-orgmode@gnu.org

Aloha Grant,

Grant Rettke <gcr@wisdomandwonder.com> writes:

> Hi,
>
> My goal is to define a table in org-mode, display it nicely to humans
> using export, and tangle that same data table into
> an elisp data structure for use elsewhere within the program. It might
> look something like this:
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> * Modes
>
> This is a place for humans to keep track both of what
> modes activated for what file types; and also what utilies are used
> with those modes when they are activated.
>
> #+tblname: modes_data
> | mode name | file_type | paredit | auto-save |
> |-----------+-----------+---------+-----------|
> | scheme | .scm  | yes     | yes       |
> | elisp     | .el       | yes     | yes       |
> | ielm      | nil       | yes     | no        |
>
> * Test
>
> #+begin_src emacs-lisp :noweb tangle :tangle test.el
>   (mapcar (lambda (row) (message (car row))) modes_data)
> #+end_src

I think you want:
#+header: :var modes-data=modes-data

or something similar.

hth,
Tom

-- 
Thomas S. Dye
http://www.tsdye.com

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

* Re: Help with tangling a table into a source-code representation of the data contained within
  2014-02-25  4:49 ` Thomas S. Dye
@ 2014-02-25  9:00   ` Rainer M Krug
  2014-02-26  4:41     ` Grant Rettke
  0 siblings, 1 reply; 6+ messages in thread
From: Rainer M Krug @ 2014-02-25  9:00 UTC (permalink / raw)
  To: Thomas S. Dye; +Cc: emacs-orgmode@gnu.org, Grant Rettke

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

tsd@tsdye.com (Thomas S. Dye) writes:

> Aloha Grant,
>
> Grant Rettke <gcr@wisdomandwonder.com> writes:
>
>> Hi,
>>
>> My goal is to define a table in org-mode, display it nicely to humans
>> using export, and tangle that same data table into
>> an elisp data structure for use elsewhere within the program. It might
>> look something like this:
>>
>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>>
>> * Modes
>>
>> This is a place for humans to keep track both of what
>> modes activated for what file types; and also what utilies are used
>> with those modes when they are activated.
>>
>> #+tblname: modes_data
>> | mode name | file_type | paredit | auto-save |
>> |-----------+-----------+---------+-----------|
>> | scheme | .scm  | yes     | yes       |
>> | elisp     | .el       | yes     | yes       |
>> | ielm      | nil       | yes     | no        |
>>
>> * Test
>>
>> #+begin_src emacs-lisp :noweb tangle :tangle test.el
>>   (mapcar (lambda (row) (message (car row))) modes_data)
>> #+end_src
>
> I think you want:
> #+header: :var modes-data=modes-data

I don't know about the #+header, but the following works for me perfectly:'

* Columns to evaluate
#+NAME: COLS_TO_EVAL
|   | name          | usable |
|---+---------------+--------|
| 1 | NPPyC         | FALSE  |
| 2 | DBBVy         | TRUE   |
| 3 | DBRFy         | FALSE  |
| 4 | DBSSy         | FALSE  |
| 5 | levelstress_2 | TRUE   |
#+PROPERTY: var+ COLS_TO_EVAL=COLS_TO_EVAL

Cheers,

Rainer

>
> or something similar.
>
> hth,
> Tom

-- 
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Stellenbosch University
South Africa

Tel :       +33 - (0)9 53 10 27 44
Cell:       +33 - (0)6 85 62 59 98
Fax :       +33 - (0)9 58 10 27 44

Fax (D):    +49 - (0)3 21 21 25 22 44

email:      Rainer@krugs.de

Skype:      RMkrug

[-- Attachment #2: Type: application/pgp-signature, Size: 494 bytes --]

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

* Re: Help with tangling a table into a source-code representation of the data contained within
  2014-02-25  9:00   ` Rainer M Krug
@ 2014-02-26  4:41     ` Grant Rettke
  2014-02-26  5:21       ` Grant Rettke
  0 siblings, 1 reply; 6+ messages in thread
From: Grant Rettke @ 2014-02-26  4:41 UTC (permalink / raw)
  To: Rainer M Krug; +Cc: emacs-orgmode@gnu.org, Thomas S. Dye

Thanks everyone.

My tentative plan is to run some elisp that will dump the table to an
intermediate file and then dependent files may load it themselves.

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

* Re: Help with tangling a table into a source-code representation of the data contained within
  2014-02-26  4:41     ` Grant Rettke
@ 2014-02-26  5:21       ` Grant Rettke
  0 siblings, 0 replies; 6+ messages in thread
From: Grant Rettke @ 2014-02-26  5:21 UTC (permalink / raw)
  To: Rainer M Krug; +Cc: emacs-orgmode@gnu.org, Thomas S. Dye

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

This seems like a fine option:

#+name: mode_data
| mode       | paredit | auto-save |
|------------+---------+-----------|
| scheme     | TRUE    | TRUE      |
| emacs-lisp | TRUE    | TRUE      |
| ielm       | TRUE    | FALSE     |

#+begin_src emacs-lisp :var data=mode_data :exports results :file modes.json
  (require 'json)
  (json-encode data)
#+end_src

JSON because I will probably use it a few different ways, and most langs
today handle JSON just fine.


On Tue, Feb 25, 2014 at 10:41 PM, Grant Rettke <gcr@wisdomandwonder.com>wrote:

> Thanks everyone.
>
> My tentative plan is to run some elisp that will dump the table to an
> intermediate file and then dependent files may load it themselves.
>



-- 
Grant Rettke | ACM, AMA, COG, IEEE
gcr@wisdomandwonder.com | http://www.wisdomandwonder.com/
“Wisdom begins in wonder.” --Socrates
((λ (x) (x x)) (λ (x) (x x)))
“Life has become immeasurably better since I have been forced to stop
taking it seriously.” --Thompson

[-- Attachment #2: Type: text/html, Size: 1655 bytes --]

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

end of thread, other threads:[~2014-02-26  5:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-25  4:37 Help with tangling a table into a source-code representation of the data contained within Grant Rettke
2014-02-25  4:45 ` Samuel Wales
2014-02-25  4:49 ` Thomas S. Dye
2014-02-25  9:00   ` Rainer M Krug
2014-02-26  4:41     ` Grant Rettke
2014-02-26  5:21       ` Grant Rettke

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