emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Eric Schulte" <schulte.eric@gmail.com>
To: "Jose E. Marchesi" <jemarch@gnu.org>
Cc: emacs-orgmode@gnu.org
Subject: Re: [BABEL] ob-rec.el and some questions
Date: Tue, 15 Feb 2011 13:35:00 -0700	[thread overview]
Message-ID: <87ei793ukr.fsf@gmail.com> (raw)
In-Reply-To: <87zkpxm6zy.fsf@gnu.org> (Jose E. Marchesi's message of "Tue, 15 Feb 2011 20:29:21 +0100")

jemarch@gnu.org (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

  reply	other threads:[~2011-02-15 20:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-14 21:07 [BABEL] ob-rec.el and some questions Jose E. Marchesi
2011-02-15 18:35 ` Eric Schulte
2011-02-15 19:29   ` Jose E. Marchesi
2011-02-15 20:35     ` Eric Schulte [this message]
2011-02-15 21:05       ` Jose E. Marchesi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ei793ukr.fsf@gmail.com \
    --to=schulte.eric@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=jemarch@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).