0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-09-12 09:09:54 +00:00

fixed problem with new ruby sessions sometimes not initializing

This commit is contained in:
Eric Schulte 2009-06-14 09:12:19 -07:00
parent 8931657abf
commit f31b3b2af2
2 changed files with 58 additions and 51 deletions

View file

@ -85,7 +85,11 @@ Emacs-lisp table, otherwise return the results as a string."
(defun org-babel-ruby-initiate-session (&optional session)
"If there is not a current inferior-process-buffer in SESSION
then create. Return the initialized session."
(save-window-excursion (run-ruby nil session) (current-buffer)))
(let ((session-buffer (save-window-excursion (run-ruby nil session) (current-buffer))))
(if (org-babel-comint-buffer-livep session-buffer)
session-buffer
(sit-for .5)
(org-babel-ruby-initiate-session session))))
(defvar org-babel-ruby-last-value-eval "_"
"When evaluated by Ruby this returns the return value of the last statement.")

View file

@ -1718,10 +1718,7 @@ This could probably be added to [[file:lisp/org-babel-script.el][org-babel-scrip
(see [[* file result types][file result types]])
* Bugs [12/16]
** TODO ruby fails on first call to non-default session
* Bugs [13/16]
** TODO non-orgtbl formatted lists
for example
@ -1753,6 +1750,12 @@ even a third"
E.g. the pie chart example. Despite the save-window-excursion in
org-babel-execute:R. (I never learned how to do this properly: org-R
jumps all over the place...)
** DONE ruby fails on first call to non-default session
#+srcname: bug-new-session
#+begin_src ruby :session is-new
:patton
#+end_src
** DONE when reading results from =#+resname= line
@ -2013,50 +2016,50 @@ org-babel functionality.
of these tests may fail.
#+TBLNAME: org-babel-tests
| functionality | block | arg | expected | results | pass |
|-------------------------+----------------------------+-----+-------------+-------------+----------------------------------|
| basic evaluation | | | | | pass |
|-------------------------+----------------------------+-----+-------------+-------------+----------------------------------|
| emacs lisp | basic-elisp | | 5 | 5 | pass |
| shell | basic-shell | | 6 | 6 | pass |
| ruby | basic-ruby | | org-babel | org-babel | pass |
| python | basic-python | | hello world | hello world | pass |
| R | basic-R | | 13 | 13 | pass |
|-------------------------+----------------------------+-----+-------------+-------------+----------------------------------|
| tables | | | | | pass |
|-------------------------+----------------------------+-----+-------------+-------------+----------------------------------|
| emacs lisp | table-elisp | | 3 | 3 | pass |
| ruby | table-ruby | | 1-2-3 | 1-2-3 | pass |
| python | table-python | | 5 | 5 | pass |
| R | table-R | | 3.5 | 3.5 | pass |
|-------------------------+----------------------------+-----+-------------+-------------+----------------------------------|
| source block references | | | | | pass |
|-------------------------+----------------------------+-----+-------------+-------------+----------------------------------|
| all languages | chained-ref-last | | Array | Array | pass |
|-------------------------+----------------------------+-----+-------------+-------------+----------------------------------|
| source block functions | | | | | pass |
|-------------------------+----------------------------+-----+-------------+-------------+----------------------------------|
| emacs lisp | defun-fibb | | fibbd | fibbd | pass |
| run over | Fibonacci | 0 | 1 | 1 | pass |
| a | Fibonacci | 1 | 1 | 1 | pass |
| variety | Fibonacci | 2 | 2 | 2 | pass |
| of | Fibonacci | 3 | 3 | 3 | pass |
| different | Fibonacci | 4 | 5 | 5 | pass |
| arguments | Fibonacci | 5 | 8 | 8 | pass |
|-------------------------+----------------------------+-----+-------------+-------------+----------------------------------|
| bugs and tasks | | | | | pass |
|-------------------------+----------------------------+-----+-------------+-------------+----------------------------------|
| simple ruby arrays | ruby-array-test | | 3 | 3 | pass |
| R number evaluation | bug-R-number-evaluation | | 2 | 2 | pass |
| multi-line ruby blocks | multi-line-ruby-test | | 2 | 2 | pass |
| forcing vector results | test-forced-vector-results | | Array | Array | pass |
|-------------------------+----------------------------+-----+-------------+-------------+----------------------------------|
| sessions | | | | | pass |
|-------------------------+----------------------------+-----+-------------+-------------+----------------------------------|
| set ruby session | set-ruby-session-var | | :set | #ERROR | expected ":set" but was "#ERROR" |
| get from ruby session | get-ruby-session-var | | 3 | nil | expected "3" but was "nil" |
| set python session | set-python-session-var | | set | set | pass |
| get from python session | get-python-session-var | | 4 | 4 | pass |
| functionality | block | arg | expected | results | pass |
|-------------------------+----------------------------+-----+-------------+-------------+------|
| basic evaluation | | | | | pass |
|-------------------------+----------------------------+-----+-------------+-------------+------|
| emacs lisp | basic-elisp | | 5 | 5 | pass |
| shell | basic-shell | | 6 | 6 | pass |
| ruby | basic-ruby | | org-babel | org-babel | pass |
| python | basic-python | | hello world | hello world | pass |
| R | basic-R | | 13 | 13 | pass |
|-------------------------+----------------------------+-----+-------------+-------------+------|
| tables | | | | | pass |
|-------------------------+----------------------------+-----+-------------+-------------+------|
| emacs lisp | table-elisp | | 3 | 3 | pass |
| ruby | table-ruby | | 1-2-3 | 1-2-3 | pass |
| python | table-python | | 5 | 5 | pass |
| R | table-R | | 3.5 | 3.5 | pass |
|-------------------------+----------------------------+-----+-------------+-------------+------|
| source block references | | | | | pass |
|-------------------------+----------------------------+-----+-------------+-------------+------|
| all languages | chained-ref-last | | Array | Array | pass |
|-------------------------+----------------------------+-----+-------------+-------------+------|
| source block functions | | | | | pass |
|-------------------------+----------------------------+-----+-------------+-------------+------|
| emacs lisp | defun-fibb | | fibbd | fibbd | pass |
| run over | Fibonacci | 0 | 1 | 1 | pass |
| a | Fibonacci | 1 | 1 | 1 | pass |
| variety | Fibonacci | 2 | 2 | 2 | pass |
| of | Fibonacci | 3 | 3 | 3 | pass |
| different | Fibonacci | 4 | 5 | 5 | pass |
| arguments | Fibonacci | 5 | 8 | 8 | pass |
|-------------------------+----------------------------+-----+-------------+-------------+------|
| bugs and tasks | | | | | pass |
|-------------------------+----------------------------+-----+-------------+-------------+------|
| simple ruby arrays | ruby-array-test | | 3 | 3 | pass |
| R number evaluation | bug-R-number-evaluation | | 2 | 2 | pass |
| multi-line ruby blocks | multi-line-ruby-test | | 2 | 2 | pass |
| forcing vector results | test-forced-vector-results | | Array | Array | pass |
|-------------------------+----------------------------+-----+-------------+-------------+------|
| sessions | | | | | pass |
|-------------------------+----------------------------+-----+-------------+-------------+------|
| set ruby session | set-ruby-session-var | | :set | :set | pass |
| get from ruby session | get-ruby-session-var | | 3 | 3 | pass |
| set python session | set-python-session-var | | set | set | pass |
| get from python session | get-python-session-var | | 4 | 4 | pass |
#+TBLFM: $5='(if (= (length $3) 1) (progn (message (format "running %S" '(sbe $2 (n $3)))) (sbe $2 (n $3))) (sbe $2))::$6='(if (string= $4 $5) "pass" (format "expected %S but was %S" $4 $5))
** basic tests
@ -2216,13 +2219,13 @@ triv.class.name
** sessions
#+srcname: set-ruby-session-var
#+begin_src ruby :session rb-testing
#+begin_src ruby :session rb-new-testing :results silent
var = [1, 2, 3]
:set
#+end_src
#+srcname: get-ruby-session-var
#+begin_src ruby :session rb-testing
#+begin_src ruby :session rb-new-testing :results silent
var.size
#+end_src