Commit Graph

65 Commits

Author SHA1 Message Date
Dan Davison ec0b3892b9 babel: New function to process file names for use in external processes
* ob.el (org-babel-process-file-name): New function
	(org-babel-maybe-remote-file): Delete function

	* ob-sql.el (org-babel-execute:sql):
	Use org-babel-process-file-name

	* ob-scheme.el (org-babel-execute:scheme):
	Use org-babel-process-file-name

	* ob-sass.el (org-babel-execute:sass):
	Use org-babel-process-file-name

	* ob-ruby.el (org-babel-ruby-evaluate):
	Use org-babel-process-file-name

	* ob-python.el (org-babel-python-evaluate-external-process):
	Use org-babel-process-file-name
	(org-babel-python-evaluate-session):
	Use org-babel-process-file-name

	* ob-plantuml.el (org-babel-execute:plantuml):
	Use org-babel-process-file-name

	* ob-perl.el (org-babel-perl-evaluate):
	Use org-babel-process-file-name

	* ob-octave.el (org-babel-octave-evaluate-external-process):
	Use org-babel-process-file-name
	(org-babel-octave-evaluate-session):
	Use org-babel-process-file-name,
	don't use org-babel-maybe-remote-file

	* ob-lisp.el (org-babel-execute:lisp):
	Use org-babel-process-file-name

	* ob-ledger.el (org-babel-execute:ledger):
	Use org-babel-process-file-name

	* ob-js.el (org-babel-execute:js):
	Use org-babel-process-file-name

	* ob-haskell.el (org-babel-haskell-export-to-lhs):
	Use org-babel-process-file-name

	* ob-gnuplot.el (org-babel-execute:gnuplot):
	Use org-babel-process-file-name

	* ob-eval.el (org-babel-eval-read-file): Don't use
	org-babel-maybe-remote-file

	* ob-dot.el (org-babel-execute:dot):
	Use org-babel-process-file-name

	* ob-ditaa.el (org-babel-execute:ditaa):
	Use org-babel-process-file-name

	* ob-clojure.el (org-babel-clojure-evaluate-external-process):
	Use org-babel-process-file-name

	* ob-asymptote.el (org-babel-execute:asymptote):
	Use org-babel-process-file-name

	* ob-R.el (org-babel-R-assign-elisp): Don't use
	org-babel-maybe-remote-file, use org-babel-process-file-name
	(org-babel-R-evaluate-external-process):
	Use org-babel-process-file-name
	(org-babel-R-evaluate-session):
	Use org-babel-process-file-name

	* ob-C.el (org-babel-C-execute):
	Use org-babel-process-file-name

In addition to passing the file path through `expand-file-name',
tramp-style remote file names are converted to conventional (local)
file paths. The reason is that, if a tramp file name was in use in
emacs, then the shell command will be executing on the remote machine
in question. Further, by default the file name is passed through
`shell-quote-argument'.
2010-09-22 22:10:13 +01:00
Eric Schulte 7b00073f2d Babel now cleans up any temporary files created using org-babel-temp-file
* lisp/ob.el (org-babel-temporary-directory): variable to hold the
  value of the Babel temporary directory

  (org-babel-temp-file): replacement for make-temp-file with cleanup
  on exit of Emacs

  (org-babel-remove-temporary-directory): cleanup function run on exit
  of Emacs

  (kill-emacs-hook): now includes babel cleanup function

* lisp/ob-C.el (org-babel-C-execute): using org-babel-temp-file
  instead of make-temp-file

* lisp/ob-R.el (org-babel-R-assign-elisp): using `org-babel-temp-file'
  instead of `make-temp-file'

  (org-babel-R-evaluate-external-process): using `org-babel-temp-file'
  instead of `make-temp-file'

  (org-babel-R-evaluate-session): using `org-babel-temp-file' instead of
  `make-temp-file'

* lisp/ob-asymptote.el (org-babel-execute:asymptote): using
  `org-babel-temp-file' instead of `make-temp-file'

* lisp/ob-clojure.el (org-babel-clojure-evaluate-external-process):
  using `org-babel-temp-file' instead of `make-temp-file'

* lisp/ob-ditaa.el (org-babel-execute:ditaa): using
  `org-babel-temp-file' instead of `make-temp-file'

* lisp/ob-dot.el (org-babel-execute:dot): using `org-babel-temp-file'
  instead of `make-temp-file'

* lisp/ob-gnuplot.el (org-babel-gnuplot-process-vars): using
  `org-babel-temp-file' instead of `make-temp-file'

  (org-babel-execute:gnuplot): using `org-babel-temp-file' instead of
  `make-temp-file'

* lisp/ob-haskell.el (org-babel-load-session:haskell): using
  `org-babel-temp-file' instead of `make-temp-file'

  (org-babel-haskell-export-to-lhs): using `org-babel-temp-file' instead
  of `make-temp-file'

* lisp/ob-latex.el (org-babel-execute:latex): using
  `org-babel-temp-file' instead of `make-temp-file'

* lisp/ob-ledger.el (org-babel-execute:ledger): using
  `org-babel-temp-file' instead of `make-temp-file'

* lisp/ob-lisp.el (org-babel-execute:lisp): using
  `org-babel-temp-file' instead of `make-temp-file'

* lisp/ob-octave.el (org-babel-octave-evaluate-external-process):
  using `org-babel-temp-file' instead of `make-temp-file'

  (org-babel-octave-evaluate-session): using `org-babel-temp-file'
  instead of `make-temp-file'

  (org-babel-octave-import-elisp-from-file): using `org-babel-temp-file'
  instead of `make-temp-file'

* lisp/ob-perl.el (org-babel-perl-evaluate): using
  `org-babel-temp-file' instead of `make-temp-file'

* lisp/ob-python.el (org-babel-python-evaluate): using
  `org-babel-temp-file' instead of `make-temp-file'
  using `org-babel-temp-file' instead of `make-temp-file'

* lisp/ob-ruby.el (org-babel-ruby-evaluate): using
  `org-babel-temp-file' instead of `make-temp-file'
  using `org-babel-temp-file' instead of `make-temp-file'

* lisp/ob-sass.el (org-babel-execute:sass): using
  `org-babel-temp-file' instead of `make-temp-file'

* lisp/ob-sh.el (org-babel-sh-evaluate): using `org-babel-temp-file'
  instead of `make-temp-file'

* lisp/ob-sql.el (org-babel-execute:sql): using `org-babel-temp-file'
  instead of `make-temp-file'

* lisp/ob-sqlite.el (org-babel-execute:sqlite): using
  `org-babel-temp-file' instead of `make-temp-file'

  (org-babel-sqlite-expand-vars): using `org-babel-temp-file' instead of
   `make-temp-file'
2010-08-25 14:47:47 -06:00
Dan Davison 9978dcf21f babel: octave/matlab: use dlmwrite to write delimited text
2010-08-03  Dan Davison  <davison@stats.ox.ac.uk>

	* ob-octave.el (org-babel-octave-wrapper-method): use dlmwrite
	to write delimited text instead of save -ascii
	(org-babel-octave-import-elisp-from-file): specify that data
	written to file is tab-delimited
2010-08-03 23:54:24 -04:00
Dan Davison 876b115259 babel: octave: allow remote files
2010-08-02  Dan Davison  <davison@stats.ox.ac.uk>

	* ob-octave.el (org-babel-octave-evaluate-external-process):
	allow remote files
2010-08-02 22:08:47 -04:00
Juan Pechiar 743a7b8293 From: Juan <Pechiar@computer.org>
Hi,

I'm starting to work with ob-octave and found several problems:

The first, for which I have a fix (see patch below) is that octave's
output was passed on as a string instead of being interpreted as a table:

[diff removed]

Now this works:

8<------------------------------------------------------------
#+source: test_output
#+begin_src octave :results value vector
[[1 2 3];[4 5 6]]
#+end_src

#+results: test_output
| 1.00000000e+00 | 2.00000000e+00 | 3.00000000e+00 |
| 4.00000000e+00 | 5.00000000e+00 | 6.00000000e+00 |
8<------------------------------------------------------------

(before the patch you'd get a single table element with something like
"1 2 3\n 4 5 6\n" inside).

The second problem is that if I use octave table output as input to
another block, it gets interpreted as a string instead of a vector:

8<------------------------------------------------------------
#+results: test_output
| 1.25000000e+00 |

#+source: check_input
#+begin_src octave :var input=test_output() :results output
ischar( input )
size( input )
#+end_src

#+results: check_input
: input = 1.25000000e+00
: ans =  1
: ans =
:     1   14
8<------------------------------------------------------------

This has to do with the EXP notation. The 'e+00' suffix makes the
whole table into a string. The problem is with "%S" in the formatting
inside org-babel-octave-var-to-octave.

The following patch seems to fix it (and makes it possible to work with
complex numbers inside the tables)::

[diff removed]

A third problem is with org-babel-octave-var-to-octave.

For example:

: (org-babel-octave-var-to-octave '( ( 1 2 3 ) ( 4 5 6 ) ))
: ->  "[[1, 2, 3], [4, 5, 6]]"

This is not a 2x3 matrix, but a 1x6 vector:

: octave-3.2.3:1> [[1,2,3],[4,5,6]]
: ans =
:    1   2   3   4   5   6

a semicolon ';' or '\n' is needed between rows instead of a comma.

To sum up:
   - 2 patches for prepare-session and importing the results back as
   org-tables (I don't know if these patches break anything).

   - 1 problem with matrix notation in org-babel-octave-var-to-octave.
   I'll try to provide a patch for this today.

2010-08-01  Juan Pechiar  <Pechiar@computer.org>

	* ob-octave.el (org-babel-octave-evaluate-external-process):
	use `org-babel-octave-import-elisp-from-file' instead of
	`org-babel-eval-read-file'.
	(org-babel-octave-var-to-octave): separate matrix rows with
	';', and use '%s' as format specifier instead of '%S'
2010-08-01 18:09:24 -04:00
Dan Davison 7b80fff974 babel: matlab/octave: only (require 'matlab) when necessary
2010-08-01  Dan Davison  <davison@stats.ox.ac.uk>

	* ob-octave.el only (require 'matlab) when necessary
	(org-babel-octave-initiate-session) (require) octave-inf or
	matlab as appropriate
	(org-babel-execute:matlab): remove (require)
	(org-babel-prep-session:matlab): remove (require)
	(org-babel-matlab-initiate-session): remove (require)
2010-08-01 14:34:28 -04:00
Dan Davison a5f0bb404f babel: octave: Fix formal argument list
2010-08-01  Dan Davison  <davison@stats.ox.ac.uk>

	* ob-octave.el (org-babel-octave-evaluate): Fix formal
	argument list
2010-08-01 12:17:47 -04:00
Carsten Dominik 6268cceec3 Mention release 7.01 on the website, push release number to 7.01trans 2010-07-19 08:33:24 +02:00
Tom Dye 272aefce83 Finished editing Babel docstrings 2010-07-13 16:20:08 -07:00
Eric Schulte c53fc7d246 babel: consolidate execution messaging into ob.el
* lisp/ob.el (org-babel-execute-src-block): consolidate execution
  messaging into ob.el rather than spread out amongst all the language
  files
2010-07-12 22:26:25 -07:00
Eric Schulte baa6e1d3d7 babel: absolutely no babel related compiler warnings
had to nest an argument in a trivial `or' to trick the compiler in
  the large ob-comint macro.
2010-07-05 11:14:51 -07:00
Eric Schulte 1e43fa0413 babel: updated ob-octave.el to work with the new ob-eval.el functions
Note, the session based evaluation has *not* be updated, mainly
  because I don't have a working octave install with which to test the
  changes.
2010-07-05 11:14:50 -07:00
Eric Schulte 15b36e2380 ext: prefix on external file names 2010-07-05 11:14:50 -07:00
Eric Schulte 6c2e35003f babel: all languages compiling cleanly (but R has a small problem)
For some reason ob-R refuses to compile when it requires ob-comint.

  When (require 'ob-comint) is not included in  ob-R.el everything
  compiles without error, but warnings are thrown because the
  arguments to a macro defined in ob-comint are mis-interpreted as
  functions.

  When (require 'ob-comint) is added to ob-R.el then it throws errors
  complaining that the last argument to a function is nil and should
  be a string.  I don't understand this error at all and can't fix it.
2010-07-05 11:14:50 -07:00
Eric Schulte d7b7025eac flattening out lisp directory structure
all babel and babel/langs files now live in the base of the lisp directory.
2010-07-05 11:14:49 -07:00
Renamed from lisp/babel/langs/ob-octave.el (Browse further)