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 11:35:15 -0700	[thread overview]
Message-ID: <87sjvp5dzr.fsf@gmail.com> (raw)
In-Reply-To: 877hd2uxym.fsf@gnu.org

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

jemarch@gnu.org (Jose E. Marchesi) writes:

> Hi.
>
> I have been playing a bit with org babel, the goal being to be able to
> query a recfile[1] and insert the result as a rec table.  Thanks to the
> superb design of org-babel and the existing examples, I quickly wrote
> the attached little hack.
>
> The hack allows to query a rec file 'foo.rec' as follows:
>
> #+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

>
> Where :data points to the recfile (or list of files), :fields is a
> comma-separated list of fields (allowing subscripts) and :type selects
> the record set where to make the query. :cmdline can also be used to
> specify any other command line option to recsel.  All parameters but
> :data are optional.
>
> The selection expression can be any expression allowed by recsel in the
> -e command line option.
>
> Of course you have to install the recutils for it to work.
>
> It roughly works and I want to add more functionality, but due to my
> lack of experience with org-babel I would like to ask some questions
> before continuing working on it.
>
> - Is there a way to execute empty code blocks?  It would be quite common
>   to require all the records stored in a record set, e.g.
>
>   #+begin_src rec :data inventory.rec
>   #+end_src
>
>   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.

#+begin_src rec :data book.rec :fields Title,Author
  
#+end_src

#+results:
| Title...
| GNU Emacs Manual...

>
>   #+begin_src rec :data inventory.rec
>   1
>   #+end_src
>
>   but it would be nice to avoid it.
>
> - 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?

>

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?

Thanks for sharing! -- Eric


[-- Attachment #2: ob-rec.el --]
[-- Type: application/emacs-lisp, Size: 2319 bytes --]

[-- Attachment #3: Type: text/plain, Size: 71 bytes --]


>
> Thanks in advance :)
>
> [1] http://www.gnu.org/software/recutils

[-- Attachment #4: 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

  reply	other threads:[~2011-02-15 18:50 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 [this message]
2011-02-15 19:29   ` Jose E. Marchesi
2011-02-15 20:35     ` Eric Schulte
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=87sjvp5dzr.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).