* lisp/ob-R.el: org-babel-R-evaluate-external-process and
org-babel-R-evaluate-session trim the extraneous newlines from the
end of R output.
* testing/lisp/test-ob-R.el: test-ob-R/results-file tests that
`:results file' yields one line enclosed in square brackets for a
result like "abc/def.ghi".
Fixes issue noted by Andreas Leha
Subject: [babel] return file from R
Archived-At: <http://permalink.gmane.org/gmane.emacs.orgmode/103658>
* lisp/ob-R.el (org-babel-R-evaluate-session) should find prompts more
reliably. First, the regular expression used requires spacing
between and after instances of `[>+.]'. Also, the search terminates
at the first `\n', so complicated results with prompt like strings
in them are not deleted.
Prompt finding is necessarily heuristic. It may be necessary to render
the regular expression with a defcustom as is done in ess-mode.
Protect apostrophes not covered by the last backport. Convert
expressions like '(...) to \\='(...) and symbols written as 'name to
`name'. (In addition to ensuring the correct display, the latter also
improves consistency with many Org docstrings.)
If these aren't protected, Emacs 25 may display them as curved quotes in
the help buffer, depending on the value of text-quoting-style.
* lisp/ob-R.el (org-babel-header-args:R): Allow "drawer" and "none",
since they are supported in `org-babel-common-header-args-w-values'.
Reported-by: Andreas Leha <andreas.leha@med.uni-goettingen.de>
<http://permalink.gmane.org/gmane.emacs.orgmode/97683>
* lisp/ob-R.el (org-babel-R-eoe-indicator):
(org-babel-R-eoe-output): Convert from defvar to defconst.
(org-babel-R-write-object-command): Convert from defvar to defconst.
Add line breaks and indentation.
* lisp/ob-R.el: (ob-R-transfer-variable-table-with-header)
(ob-R-transfer-variable-table-without-header): Add package name to
call of R function `read.table'.
Thus, it now reads `utils::read.table'. This clarifies the call as
well as avoids "could not find function" error in R with the devtools
package. See
<https://github.com/hadley/devtools/issues/336#issuecomment-23517837>.
* lisp/ob-R.el (org-babel-R-evaluate-session): Improve the capturing
of R output.
This uses a built-in facility of R to write the output to a file,
rather than trying to capture it in an emacs buffer using ESS (a
process by which the output can get mixed with other irrelevant text,
such as R command prompts).
* lisp/ob-R.el (org-babel-R-assign-elisp): Strip text properties from
strings.
Before this change, babel would try to format propertized strings
using elisp read syntax. The upshot is that evaluating the following
code block would give an error (in R, not emacs), since the “bar” in
foo-ex gets text properties via font lock:
| #+name: foo-ex
| #+begin_example
| bar
| #+end_example
|
| #+name: foo
| #+begin_src R :var foo=foo-ex
| foo
| #+end_src
* lisp/ob-R.el (org-babel-R-assign-elisp): Add different cases for
transfering integer, float, string and other variables to R so that
integer values are transferred as integers (L) and stored in R as
such. This change is backward compatible as integer values are
numerical values in R.
Moved definition of R functions for transfer of tables into defconst
ob-R-transfer-variable-table-with-header and
ob-R-transfer-variable-table-without-header.
* lisp/ob-R.el (org-babel-R-assign-elisp): Fix variable transfer of
tables by using text connections in R instead of files. Variable
transfer of tables does not depend on files anymore, i.e. works also
when tangling.
* lisp/ob-core.el (org-babel-generate-file-param): New function.
(org-babel-get-src-block-info): Use it.
(org-babel-merge-params): Handle :file-ext.
(org-babel-graphical-output-file): error if no :file or :file-ext.
* testing/lisp/test-ob.el (test-org-babel/file-ext-and-output-dir):
New test.
* doc/org.texi (Specific header arguments): Add doc for :file-ext and
:output-dir header args.
* lisp/ob-R.el (org-babel-expand-body:R): Don’t calculate
graphics-file.
(org-babel-execute:R): Only look for a graphics-file if needed.
* lisp/ob-core.el (org-babel-graphical-output-file): New generic function.
* lisp/ob-R.el (org-babel-R-graphical-output-file): Delete specific version.
(org-babel-expand-body:R): Use generic version.
* lisp/ob-maxima.el (org-babel-maxima-graphical-output-file): Delete
specific version.
(org-babel-maxima-expand): Use generic version.
* lisp/ob-octave.el (org-babel-octave-graphical-output-file): Delete
specific version
(org-babel-execute:octave): Use generic version.
* lisp/ob-R.el (org-babel-expand-body:R): Added the opening of the
tryCatch() wrapper
* lisp/ob-R.el (org-babel-R-construct-graphics-device-call): Added
closing of the wrapper containing the error function.
Added tryCatch() wrapper around the execution of the source block so
that if an error occurs
- the R graphic device is closed even when an error occurs
- a graph containing the error message is created
- the error message is printed in the R session in the form
ERROR : the error message
TINYCHANGE
* lisp/ob-R.el (org-babel-R-graphics-devices): New defvar.
(org-babel-R-construct-graphics-device-call): Use it instead of a
hard-coded list of graphics devices.
The `org-babel-R-graphics-devices' variable now holds the association
between graphics file types and R functions. This allows users by
modifying this alist to choose to use e.g. the Cairo* functions from the
R package “Cairo” or one of several alternative devices for SVG
output (SVGAnnotation, RSVGTipsDevice).
* lisp/ob-R.el (org-babel-R-initiate-session): handle case where the
session buffer exists, but does not have a live process
If the session buffer exists, but the user has exited the R process
manually, then the (R) command will create a new buffer, then try to
rename it over the old buffer, causing an error. The right thing to do
is to start R within the existing buffer.
* ox-latex.el:
(org-latex-image-default-option): Change default value to ""
(org-latex-image-default-width)
(org-latex-image-default-height): Add variables
(org-latex-inline-image-rules): Make .tikz files as exportable with
latex
(org-latex--inline-image): Support tikz images. Also support separate
:width and :height parameters for images.
* ob-R.el (org-babel-R-construct-graphics-device-call): Change file
extension of tikz graphics files to .tikz
Tikz graphics should be exported to LaTeX by \include, not as a link.
This commit changes the file extension used for tikz graphics from .tex
to .tikz, and inserts code for including such images. The :options for
tikz graphics are passed as an optional argument to a tikzpicture
environment.
Also provide :width and :height ATTR_LATEX entries for images. For tikz
graphics, these are implemented with \resizebox; for other image types
they are inserted in the optional arguments to \includegraphics.
* lisp/ob.el (org-babel-result-cond): This function should now be used
by all language backends to handle the processing of raw code block
output into scalar results, table results, or ignored results
depending on the value of result-params.
* lisp/ob-C.el (org-babel-C-execute): Use org-babel-result-cond.
* lisp/ob-R.el (org-babel-R-evaluate-external-process): Use
org-babel-result-cond.
(org-babel-R-evaluate-session): Use org-babel-result-cond.
* lisp/ob-awk.el (org-babel-execute:awk): Use org-babel-result-cond.
* lisp/ob-clojure.el (org-babel-execute:clojure): Use
org-babel-result-cond.
* lisp/ob-emacs-lisp.el (org-babel-execute:emacs-lisp): Use
org-babel-result-cond.
* lisp/ob-fortran.el (org-babel-execute:fortran): Use
org-babel-result-cond.
* lisp/ob-io.el (org-babel-io-evaluate): Use org-babel-result-cond.
* lisp/ob-java.el (org-babel-execute:java): Use org-babel-result-cond.
* lisp/ob-lisp.el (org-babel-execute:lisp): Use org-babel-result-cond.
* lisp/ob-maxima.el (org-babel-execute:maxima): Use
org-babel-result-cond.
* lisp/ob-picolisp.el (org-babel-execute:picolisp): Use
org-babel-result-cond.
* lisp/ob-python.el (org-babel-python-evaluate-external-process): Use
org-babel-result-cond.
(org-babel-python-evaluate-session): Use org-babel-result-cond.
* lisp/ob-scala.el (org-babel-scala-evaluate): Use org-babel-result-cond.
* lisp/ob-sh.el (org-babel-sh-evaluate): Use org-babel-result-cond.
* lisp/ob-shen.el (org-babel-execute:shen): Use org-babel-result-cond.
* lisp/ob-sql.el (org-babel-execute:sql): Use org-babel-result-cond.
* lisp/ob-sqlite.el (org-babel-execute:sqlite): Use
org-babel-result-cond.
* lisp/ob-R.el (org-babel-R-initiate-session): Protect against use of
unbound variable `ess-ask-for-ess-directory´. The default for this
variable is true, so act accordingly if it is found unbound.
* lisp/ob-R.el: Remove initialization with `nil´ from
`ess-ask-for-ess-directory´ and `ess-local-process-name´. Remove
second declaration for `ess-local-process-name´.
* testing/lisp/test-ob-R.el (test-ob-R/simple-session): Bind
`ess-ask-for-ess-directory´ to nil to facilitate batch testing.
* ob-R.el (org-babel-edit-prep:R): Don't set the session.
See the discussion for this issue here:
http://article.gmane.org/gmane.emacs.orgmode/58600
Thanks to Mikhail Titov and to Andrew Young for exploring it.
* lisp/ob-R.el (org-babel-execute:R): Collect and pass along the
result-params.
(org-babel-R-evaluate): Accept result-params and if "scalar" or
"verbatim" don't process output.
(org-babel-R-evaluate-session): Accept result-params and if "scalar"
or "verbatim" don't process output.
Also remove blank lines before the ";;; org*el ends here" declarations.
Having a "Version" header forced us to update every file when releasing a
new version of Org; it also forced us to update every file when merging Org
with Emacs trunk, thus cluttering the diffs between the previously merged
version and the new one with useless information.
Glenn Morris suggested this in emacs-devel:
http://lists.gnu.org/archive/html/emacs-devel/2011-08/msg00322.html
* lisp/ob-R.el (ess-local-process-name): This variable wasn't known to
be defined.
* lisp/ob-lisp.el (org-babel-lisp-dir-fmt): This defcustom now has a
group specified.
* lisp/ob-tangle.el (org-bracket-link-regexp): This variable wasn't
known to be defined.
(org-babel-tangle-combine-named-blocks): Roll my own version of a
forbidden common lisp function.
* lisp/ob.el (org-babel-sha1-hash): Using a non-deprecated version of
called-interactively.
Slight modification of patch by Christophe Rhodes
* lisp/ob-R.el (org-babel-R-write-object-command): Ensure that all
data is written to the results file before Emacs notices that the file
exists.
* lisp/ob-R.el (org-babel-edit-prep:R): Associate the appropriate R
process with the edit buffer when :session is specified.
* lisp/org-src.el (org-edit-src-code): Allow language-specific
edit-buffer preparation by calling the org-babel-edit-prep:lang
function when it is defined.
* lisp/ob-R.el (org-babel-R-write-object-command): Force evaluation of
user code prior to the R exception-handling, so that errors in user
code are unhandled.
":results graphics" is now required in addition to ":file filename" in
order for graphical output to be sent automatically to file. If :file
is supplied, but not ":results graphics", then the default behavior
obtains: i.e., either "value" or "output" results are written to file,
depending on which of those options is in effect.
* lisp/ob-R.el (org-babel-R-graphical-output-file): New function
returns the name of the output file iff R has been instructed to send
graphical output to file by means of the ":results graphics"
directive.
(org-babel-expand-body:R): Use `org-babel-R-graphical-output-file'
when constructing the R code to evaluate, which may be augmented with
code implementing the writing of graohical output to file.
(org-babel-execute:R): Use `org-babel-R-graphical-output-file' to
determine whether R is taking responsibility for writing output to
file; if so, this is signalled to ob.el by returning a nil result.
* lisp/ob-C.el (org-babel-C-execute): removing call to
org-babel-process-params which should no longer be called from
within a language file
* lisp/ob-R.el (org-babel-execute:R): removing call to
org-babel-process-params which should no longer be called from
within a language file
(org-babel-R-variable-assignments): removing call to
org-babel-process-params which should no longer be called from
within a language file
* lisp/ob-asymptote.el (org-babel-execute:asymptote): removing call to
org-babel-process-params which should no longer be called from
within a language file
* lisp/ob-clojure.el (org-babel-execute:clojure): removing call to
org-babel-process-params which should no longer be called from
within a language file
* lisp/ob-dot.el (org-babel-execute:dot): removing call to
org-babel-process-params which should no longer be called from
within a language file
* lisp/ob-emacs-lisp.el (org-babel-expand-body:emacs-lisp): removing
call to org-babel-process-params which should no longer be called
from within a language file
(org-babel-execute:emacs-lisp): removing call to
org-babel-process-params which should no longer be called from
within a language file
* lisp/ob-haskell.el (org-babel-execute:haskell): removing call to
org-babel-process-params which should no longer be called from
within a language file
* lisp/ob-js.el (org-babel-execute:js): removing call to
org-babel-process-params which should no longer be called from
within a language file
* lisp/ob-lisp.el (org-babel-execute:lisp): removing call to
org-babel-process-params which should no longer be called from
within a language file
* lisp/ob-ocaml.el (org-babel-execute:ocaml): removing call to
org-babel-process-params which should no longer be called from
within a language file
* lisp/ob-octave.el (org-babel-execute:octave): removing call to
org-babel-process-params which should no longer be called from
within a language file
* lisp/ob-perl.el (org-babel-execute:perl): removing call to
org-babel-process-params which should no longer be called from
within a language file
* lisp/ob-python.el (org-babel-execute:python): removing call to
org-babel-process-params which should no longer be called from
within a language file
* lisp/ob-ruby.el (org-babel-execute:ruby): removing call to
org-babel-process-params which should no longer be called from
within a language file
* lisp/ob-scheme.el (org-babel-execute:scheme): removing call to
org-babel-process-params which should no longer be called from
within a language file
* lisp/ob-screen.el (org-babel-execute:screen): removing call to
org-babel-process-params which should no longer be called from
within a language file
(org-babel-prep-session:screen): removing call to
org-babel-process-params which should no longer be called from
within a language file
* lisp/ob-sh.el (org-babel-execute:sh): removing call to
org-babel-process-params which should no longer be called from
within a language file
* lisp/ob-sql.el (org-babel-execute:sql): removing call to
org-babel-process-params which should no longer be called from
within a language file
* ob-haskell.el (org-babel-execute:haskell): Remove reference
to processed params
* ob-clojure.el (org-babel-execute:clojure): Remove reference
to processed params
* ob-R.el (org-babel-execute:R): Remove reference to processed
params
* ob-R.el (org-babel-expand-body:R): Use new function
`org-babel-variable-assignments:R'; don't trim body.
(org-babel-execute:R): Respond to changes in
`org-babel-expand-body:R'
(org-babel-prep-session:R): Called function is now named
`org-babel-variable-assignments:R'
(org-babel-variable-assignments:R): Receives processed-params
as new optional argument
* ob-R.el (org-babel-expand-body:R): Refactor: break variable
assignment part out into a separate function
(org-babel-R-variable-assignments): New function constructing
list of variable assignment statements
(org-babel-prep-session:R): Use new function
`org-babel-R-variable-assignments' instead of previous
(incorrect) variable assignment code.