18 Using ob-rec.el

ob-rec.el allows you to use Recutils as a language in org-mode source blocks.

18.1 Setup

Recutils should install the necessary files where emacs can see them.

In your .emacs you may need to add:

(require 'ob-rec)

You will need to add "rec" to your list of ’org-babel-load-languages’ like below:

(org-babel-do-load-languages
 'org-babel-load-languages
 '((rec . t)))

18.2 Usage

To your org file, add a src code block like:

#+BEGIN_SRC rec :data books.rec
  Location = 'loaned'
#+END_SRC

This performs the equivalent of the command:

 $ recsel -e "Location = 'loaned'" books.rec

It will produce a result like:

#+RESULTS:
| Title               | Author          | Date            | Location |
|---------------------+-----------------+-----------------+----------|
| The Colour of Magic | Terry Pratchett | 4/20/01 11:15pm | loaned   |

18.3 Header Arguments

:data

The recfile you would like to query. Can be a relative path. Spaces in the filename or path need to be escaped with a backslash (for example, file\ name.rec). This is the only required header argument.

:results

If this list contains "scalar", "html", "code" or "verbatim" then the output will look the same as if called from the command line and it will not be put into an org table.

:type

Only returns this type of record. Corresponds to the -t argument. Accepts only one argument.

:fields

Comma-separated list of fields to print. Corresponds to the -p argument.

:sort

Comma-separated list of fields by which to sort records. Corresponds to the -S argument.

:groupby

Comma-separated list of fields by which to group records. If the records grouped together share fields in common, these will be in separate columns with a "_N" appended. Corresponds to the -G argument.

:join

Field on which to join records from one record set to another. Please see blah for more on how joins work. Corresponds to the -j argument.

18.4 Warnings

  1. Output may be unpredictable if fields contain newlines, as would be the case for a multi-line field. This appears to be a limitation in org-mode’s ’org-table-convert-region’ function.