5

I have some Emacs Lisp code blocks in an Org file which I evaluate to get tables of results. It would be nice if I could include horizontal separators to separate individual lines of data from headers and summary lines, because that makes it easier to use org-sort. Concretely, I have something like this:

#+BEGIN_SRC emacs-lisp
'((foo bar baz) (1 2 3) (4 5 6))
#+END_SRC

#+RESULTS:
| foo | bar | baz |
|   1 |   2 |   3 |
|   4 |   5 |   6 |

but it would be nice if I could make the output automatically format itself more like this:

#+RESULTS:
| foo | bar | baz |
|-----+-----+-----|
|   1 |   2 |   3 |
|   4 |   5 |   6 |

Is there an easy way to do this? I thought that including nil in place of a row of results might do the trick, but it seems not to do the trick.

1 Answer 1

6

Looking at org-babel-get-colnames, the easiest way to do this probably is adding an hline as second element of your list:

#+BEGIN_SRC emacs-lisp
'((foo bar baz) hline (1 2 3) (4 5 6))
#+END_SRC

#+results:
| foo | bar | baz |
|-----+-----+-----|
|   1 |   2 |   3 |
|   4 |   5 |   6 |
1
  • Exactly what I was hoping for! Thanks.
    – user1968
    Feb 16, 2017 at 21:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.