[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Orgmode] [BABEL] ob-rec.el and some questions
From: |
Eric Schulte |
Subject: |
Re: [Orgmode] [BABEL] ob-rec.el and some questions |
Date: |
Tue, 15 Feb 2011 13:35:00 -0700 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
address@hidden (Jose E. Marchesi) writes:
> > #+begin_src rec :data hackers.rec :fields Name,Email :type Hacker
> > Papers = 'requested' && CreatedAt << '01 January 2011'
> > #+end_src
> >
>
> Very cool! Now is the time when I ask, would you consider adding this
> to the Org-mode core, which requires filling out the FSF copyright
> assignment form? http://orgmode.org/worg/org-contribute.html#sec-2
>
> Sure. I assigned future changes to Emacs some years ago.
>
Ah, I should have noticed the @gnu in your email address. That's great,
once this file settles down I'll add it to the repository.
>
> > C-cC-c in that block echoes "Local setup has been refreshed" and
> > nothing happens. A workaround would be to use a selection expression
> > that always evaluates to "true", such as:
> >
>
> With my attached version of ob-rec.el it is possible to have a
> mostly empty body as follows, however, currently
> `org-babel-get-src-block-info' *does* require that there be at least
> 1 character as well as a newline in the body. This could be
> changed, however I'd want to do some local testing before pushing up
> such a change, as I fear it may break existing code blocks.
>
> That looks like a reasonable workaround.
>
> > - Is there a way to dinamically change the value of the :results
> > parameter in the org-babel-execute:rec function? I would like to add
> > a :template parameter containing a template for recfmt, and in that
> > case the default value "raw" would not be appropriate.
> >
>
> Please see my attached revision of ob-rec.el. I do not believe that the
> default value of raw is appropriate currently as Babel should know when
> the returned results are a table. I've slightly modified your existing
> code so that raw is no longer the default value, and so that tables are
> passed back as tables. Does this change subsume your format
> question?
>
> Yes, now it is clear: I have to adapt the returned data to the
> result-params settings, and not the other way around.
>
well put
>
> Thanks for the fixes :)
>
> Also, it sounds like there is currently only support for selecting
> records *from* a .rec file, do you plan on adding support for inserting
> records *into* a .rec file?
>
> Extracting the records from org tables or raw rec data, you mean? It
> would be easy to use csv2rec and recins to implement a recins block:
>
Yes, I was thinking of something like the following. Rather than create
a new block type, simply add a header argument (or body content) that
(somehow) indicates that we are writing not reading. So for example
writing an Org-mode table into a fresh .rec file would look like the
following.
#+tblname: org-data
| Foo | Bar |
|-----+-----|
| 1 | a |
| 2 | b |
| 3 | c |
| 4 | d |
#+begin_src rec :data something.rec :var data=org-data :write
some rec code to dump data into the rec file...
#+end_src
[...]
>
> By evaluating all the code blocks in the file in a sequential way,
> additional "rec" blocks could then be used to make (and publish)
> selections of the table inserted above:
>
Yes, and once two-way movement of data is possible, then other languages
could be used to update the contents of column in rec-files from within
an Org-mode document. Running an arbitrary python function over the
"Foo" column of a .rec file and saving the results should be as easy as
evaluating the write-foos code block below.
1. Select Foo for all records
#+source: all-foos
#+begin_src rec :data something.rec :fields Foo
1
#+end_src
2. Run all foos through some arbitrary processing in any Babel language
#+source: process-foos
#+begin_src python :var foos=all-foos
do something to foos
#+end_src
3. Save the processed values back into the foos column of the original
rec file
#+source: write-foos
#+begin_src rec :data something.rec :fields Foo :write :var foos=process-foos
insert foos
#+end_src
Hope this makes sense. Best -- Eric
>
> #+begin_src rec :data foo.rec
> some selection expression
> #+end_src
>
> #+results
> | Title | Author |
> | ... | ... |
>
>
> That sounds like fun! org-mode could then be used as a GUI for recutils
> :D