Adding support for column/row names (as currently being implemented
for R) on a language by language basis is definitely the right way to
handle this hline/header issue. I am going to try to do the same for
gnuplot.
I don't believe this solves it, but chomp is more the right thing to
do than trim. I'd like to retain all the whitespace so that alignment
of columns is correct in stdout.
Unlike the other languages, it's central to R to be able to index
columns of a data frame d, either by d[,"columnname"] of d$columnname.
With this change, if colnames are present in the *input* from
org-babel, the corresponding R variable is *always* constructed with
the colnames.
In addition, with the :colnames header arg, the *output* to elisp/org
buffer contains the colnames separated from the rest of the table by
'hline. This behaviour is not default because other languages may
expect a simple table without the 'hline.
These are currently needed, due to the regexp in org-babel-get-src-block-name.
Changing that needs to be done with care to make sure that expectations regarding match-string are met,
so I'm leaving it for now
At some point it might be useful (to me at least) to clarify our rules
regarding whitespace, and make guidelines for using " \t\f\n\v\r" et
al (and [:space:]?).
THis brings in the bugfix from 4f15280631, as well as gnuplot. The bugfix required manual resolution as it had already been partially addressed in this branch. Also, the interaction of the possibility of being on a #+lob line and the possiblity of being in the middle of an org-babel-exp-results call, meant I had to rearrange things a bit, so this commit has new changes in org-babel-where-is-src-block-result in addition to the merge.
The o-b-insert-result code was assuming that we were in a source
block, where it could find the head, etc. However there are two
situations when this is not true LoB calls (although they can't output
results to buffer in this branch, they can in branch 'results'), and
org-babel-exp (which calls o-b-insert-result in an empty temp buffer).