#+source: table
#+begin_src emacs-lisp
(mapcar
(lambda (el) (number-sequence el (+ el 3)))
(number-sequence 0 4))
#+end_src
writes the results out as csv file
#+call: write(data=table, file="~/Desktop/example.csv") :results silent
writes the results out as tab separated file
#+call: write(data=table, file="~/Desktop/example.tsv") :results silent
write the results out as a normal org-mode file
#+call: write(data=table, file="~/Desktop/example.org") :results silent
* contrib/babel/library-of-babel.org: more control over exporting
results to files
* contrib/babel/library-of-babel.org(read): adding explicit format
argument
(gdoc-read): explicit format argument, and passing the csv
specification through to org-table-import
also removing org example code blocks
A quick example of accessing remote json data from Babel code blocks.
Evaluate the following to see a listing of parks in DC by ward.
#+source: dc-parks
#+begin_src emacs-lisp :var keys='(ward address) :var data=json(url="http://ogdi.cloudapp.net/v1/dc/RecreationParks?format=json")
(append
(list keys 'hline)
(mapcar
(lambda (lis) (mapcar (lambda (key) (cdr (assoc key lis))) keys))
(cdr (car data))))
#+end_src
we are keeping two things in the contrib directory
1) the library-of-babel.org file, this is with the goal of lowering
the barrier of entry for contribution of functions to the library
of babel
2) we are also keeping a langs directory in the contrib directory
because some language files do not have FSF copyright assignment
-- current org-babel-oz.el is the only such file
* contrib/babel/lisp/org-babel.el (org-babel-where-is-src-block-result):
on result insertion, ensure that code blocks don't overrun
subsequent lines or source blocks
* contrib/babel/lisp/org-babel-exp.el (org-export-blocks-postblock-hook):
adding function to cleanup leftovers after block exportation
(org-exp-res/src-name-cleanup): function to cleanup leftovers from
block exportation
* contrib/babel/lisp/langs/org-babel-latex.el (org-babel-latex-body-to-tex-file):
now calling `org-export-latex-fix-inputenc' to sort out encodings in
latex package list
* contrib/babel/lisp/org-babel.el (org-babel-set-interpreters): less
greedy regexp for inline source blocks ensures that there is no
confusion when two inline blocks are on the same line.
e.g. placing the following at the top of your buffer
will result in all source-code blocks in the buffer having their
:session header argument set to "example"
* contrib/babel/lisp/org-babel-lob.el (org-babel-lob-execute): now
included buffer-wide header arguments in lob header arguments
* contrib/babel/lisp/org-babel.el (org-babel-params-from-buffer): new
function for grabbing header arguments from the top of the buffer
(org-babel-parse-src-block-match): now includes buffer-wide header
arguments
(org-babel-parse-inline-src-block-match): now includes buffer-wide
header arguments
(org-babel-current-buffer-properties): buffer-local variable to hold
buffer-wide header arguments
* contrib/babel/lisp/org-babel-exp.el (org-babel-exp-lob-one-liners):
exportation of #+lob and #+call type lines is now correctly handling
the addition of the indentation information to the info list
* contrib/babel/lisp/org-babel-lob.el
(org-babel-lob-one-liner-regexp):
(org-babel-lob-get-info):
(org-babel-lob-execute):
all org-babel elements should now work when indented
* contrib/babel/lisp/org-babel-ref.el
(org-babel-ref-at-ref-p):
all org-babel elements should now work when indented
* contrib/babel/lisp/org-babel.el
(org-babel-set-interpreters):
(org-babel-execute-src-block):
(org-babel-expand-src-block):
(org-babel-get-src-block-info):
(org-babel-hash-at-point):
(org-mode-hook):
(org-babel-parse-src-block-match):
(org-babel-where-is-src-block-result):
(org-babel-read-result):
(org-babel-insert-result):
(org-babel-result-end):
all org-babel elements should now work when indented
Thanks to Sébastien Vauban for pointing this out -- as well as the
previous babel commit :)
* contrib/babel/lisp/org-babel.el (org-babel-insert-result):
results are now indented to the level of any existing #+results
line.
* contrib/babel/lisp/org-babel-ref.el (org-babel-ref-resolve-reference):
now able to recognize #+tblname, #+resname and #+results lines which
do not start on column 0
* contrib/babel/lisp/org-babel-exp.el (org-babel-exp-inline-src-blocks):
only evaluate inline source code blocks if they do not appear in a
verbatim or quoted context
(org-babel-in-example-or-verbatim): check if the point is currently
located in a verbatim or quoted context
* contrib/babel/lisp/org-babel-exp.el (org-babel-exp-results):
removing forced verbatim '=' tags from around inline source code
results, if users want their results displayed in this way they can
add the '='s easily themselves, but there is no way to remove '='s
inserted automatically by Org-babel.
this is required because in the temporary org-mode file used during
export code blocks may be removed entirely leading to unresolved
references
* contrib/babel/lisp/org-babel-exp.el (org-babel-exp-src-blocks):
expanding noweb references during export now takes place in the
pre-export buffer
(org-babel-exp-inline-src-blocks): expanding noweb references during
export now takes place in the pre-export buffer
(org-babel-exp-results): ensure that the expanded body is passed
through to org-babel-execute-src-block
Thanks to Tom Dye for pointing out the need for this fix
* contrib/babel/lisp/org-babel.el (org-babel-expand-noweb-references):
now able to find noweb references even outside of the narrowed
portion of the buffer when the buffer is narrowed
* contrib/babel/lisp/org-babel-ref.el (org-babel-ref-resolve-reference):
now able to resolve references which are located outside of the
narrowed portion of the buffer when the buffer is narrowed
Thanks to Graham Smith for pointing out the need for in-place
results updates
* contrib/babel/lisp/org-babel.el (org-babel-merge-params): adding
append and prepend as exclusive options to the :results header
argument
(org-babel-insert-result): now updating results in place, and
honoring the `prepend' and `append' :results header arguments
* contrib/babel/lisp/org-babel.el (org-babel-header-arg-names): adding
:noeval header argument which can be specified to inhibit the
execution of a source block during export.
* contrib/babel/lisp/org-babel-exp.el (org-babel-exp-do-export):
adding :noeval header argument which can be specified to inhibit the
execution of a source block during export.
* contrib/babel/lisp/org-babel-comint.el (org-babel-comint-with-output):
Placing a more general regexp substitution for matching newlines
returned by comint. This new option should definitely cover all
cases.
* contrib/babel/lisp/org-babel-comint.el (org-babel-comint-with-output):
If there is dangling text left after the process mark in a comint
buffer, it will now be safely stored away during babel execution,
and then replaced when babel is finished with the buffer.
This commit also fixes some indentation issues.
* contrib/babel/lisp/langs/org-babel-ruby.el (org-babel-ruby-initiate-session):
Adding a small wait after stating a new ruby session. This avoids
errors with `ansi-color-process-output' not being able to find the
process mark.
* contrib/babel/lisp/org-babel.el (org-babel-insert-result): Replaced
call to `org-cycle' with a call to the simpler and more appropriate
`org-table-align'.
* contrib/babel/library-of-babel.org (Read/Write): adding
library-of-babel functions for file I/O
* contrib/babel/lisp/org-babel-exp.el (org-babel-exp-do-export):
This brings babel more inline with Sweave, by ensuring that any code
block which could change the state in a persistent session is
executed. Prior to this change the following org-mode text like would
not export as expected because the x variable would not be
initialized.
** inline expressions
:PROPERTIES:
:session: *R*
:END:
#+begin_src R :exports code :results silent
x<-5
#+end_src
the sum of 1 and 4 is equal to src_R{x}