* lisp/ob-java.el (org-babel-execute:java): Restore inspection of
:dir's value to decide whether to run from temporary directory.
My compatibility fix in the previous commit incorrectly changed the
documented and intended behavior for (:dir . nil).
Reported-by: Ian Martins <ianxm@jhu.edu>
lisp/ob-java.el: Allow source block headers to override the java
compiler or runtime commands.
Currently the java compiler and runtime commands are customizable, but
cannot be overridden locally in source block hearders. ob-python
allows overriding the runtime command and I've found it to be useful.
This does the same for ob-java.
* lisp/ob-java.el(org-babel-execute:java): Previously the source file
was always written to the local machine so execution on the remote
machine was not possible. Now we write the source file to the remote
temp directory when the current directory is remote.
* lisp/ob-java.el(org-babel-default-header-args:java): Add :dir
default.
(org-babel-execute:java): Check for existence of :dir in params using
alist-get instead of assq because we want a nil cdr to be false.
* testing/lisp/test-ob-java.el
(ob-java/simple, ob-java/simple-with-bracket)
(ob-java/simple-with-quote, ob-java/simple-return-int)
(ob-java/simple-return-float, ob-java/simple-return-string)
(ob-java/simple-with-main, ob-java/simple-with-two-methods)
(ob-java/simple-with-no-main, ob-java/simple-with-main-args-array)
(ob-java/simple-with-main-whitespace, ob-java/simple-with-class)
(ob-java/simple-with-non-public-class)
(ob-java/simple-with-class-and-package)
(ob-java/simple-with-class-attr)
(ob-java/simple-with-class-attr-with-package, ob-java/one-arg)
(ob-java/args-quoted-string, ob-java/integer-var)
(ob-java/var-with-main, ob-java/var-with-class)
(ob-java/var-with-class-and-package)
(ob-java/var-with-class-and-hanging-curlies, ob-java/two-vars)
(ob-java/string-var, ob-java/multiline-string-var)
(ob-java/return-vector-using-list, ob-java/return-vector-using-array)
(ob-java/read-return-list, ob-java/read-list-return-array)
(ob-java/read-return-list-with-package)
(ob-java/output-list-with-spaces, ob-java/list-var, ob-java/vector-var)
(ob-java/matrix-var, ob-java/matrix-var-with-header)
(ob-java/output-table-with-header, ob-java/inhomogeneous_table)
(ob-java/import_library, ob-java/import_library_inline)
(ob-java/tangle): Set :dir to nil to prevent tests from writing files
outside of temporary directory.
(ob-java/tangle-with-package, ob-java/simple-dir):
(ob-java/simple-dir-with-package): Move :dir param to be consistent
with other tests.
Most languages write tempfiles to babel's temporary directory, but
ob-java originally had to write them to the current directory instead.
I suspect this is because java puts the source file in package
directories, and babel doesn't expect subdirectories in the babel
temporary directory. This change brings back the original behavior.
Reported-by: Jarmo Hurri <jarmo.hurri@iki.fi>
Ref: https://orgmode.org/list/87mtzk9n30.fsf@iki.fi
* lisp/ob-java.el (org-babel-java--package-re)
(org-babel-java--imports-re, org-babel-java--class-re)
(org-babel-java--main-re, org-babel-java--any-method-re):
Updated regexps to allow for more whitespace in the content of java
code blocks. Convert regexps to `rx' to improve clarity.
* testing/lisp/test-ob-java.el (ob-java/simple-with-main-whitespace):
Added test case with excessive whitespace.
Reported-by: Jarmo Hurri <jarmo.hurri@iki.fi>
Ref: https://orgmode.org/list/87o8k68w05.fsf@iki.fi
* lisp/ob-java.el (org-babel-expand-body:java): The code was checking
for existence of a class declaration before wrapping the content of
the code block in a main method, but it should be checking for
existence of a main method.
* lisp/ob-java.el (org-babel-default-header-args:java): Change the
default to scripting mode.
* testing/lisp/test-ob-java.el: Modify the first test to use the
default for `:results' and all others to specify it.
A recent commit added functional mode and made it default, but this
would break java source blocks for anyone that relied on the old
default. This sets the default back to scripting mode.
* lisp/ob-java.el: Use customizable variables for java compiler and
runtime commands. Move variable declarations to fix byte-compile
warnings. Change Author. Change tabs to spaces.
A recent patch replaced `defcustom' with `defvar' for variables that
point to the java compiler and runtime commands, which would break
functionality for anyone who had customized the variable. This
reverts that change.
ob-java is using features not available on older versions of emacs
which org supports. This replaces them with alternatives.
* lisp/ob-java.el: Add support for variables and return values. Write
tempfiles to the `org-babel-temporary-directory'. Make package,
class, and main method definitions optional.
* testing/lisp/test-ob-java.el: Add tests.
ob-java was missing features common to many other org-babel
implementations, such as the ability to accept variables and return a
value. This brings those features to ob-java, making the experience
more consistent across org-babel languages, and expanding the ways
java source blocks interact with org mode buffers.
A simple java program requires boilerplate code to declare a class and
main method. This boilerplate code makes java source blocks more
tedious to write and more effort to read. This is more evident in an
org buffer where there may be many small source blocks. This change
makes that code optional. If it is not provided, the source block
will be wrapped in the boilerplate code just before compilation.
Most org babel implementation write temporary files to the
`org-babel-temporary-directory'. That avoids polluting the current
directory and provides built-in support for tramp. ob-java would
write source files and binaries to the directory containing the org
file by default. This may be unexpected and unwanted, and didn't work
with tramp. This change writes all tempfiles to the
`org-babel-temporary-directory'.
Executing an ob-java source block would always try to compile and run
the code in the source block, so a source block that wasn't
runnable (didn't contain a main method) would error during run. This
change adds a generic main method just before compilation if one isn't
included in the source block so that the run will succeed.
There were no tests for ob-java. This adds tests.
Add changes from Emacs repo that should have been backported with
bb77dd2.
Update copyright year to 2015
7e09ef09a479731d01b1ca46e94ddadd73ac98e3
Paul Eggert
Thu Jan 1 14:26:41 2015 -0800
* 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.
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