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.

7

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 |
  • Exactly what I was hoping for! Thanks. – Jon O. Feb 16 '17 at 21:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.