Browse Source

Some more bugs / TODOs, and some unimportant changes.

Dan Davison 16 years ago
parent
commit
42fe3144b7
3 changed files with 162 additions and 45 deletions
  1. 2 2
      lisp/org-babel-table.el
  2. 32 10
      org-babel-ded-worg.org
  3. 128 33
      org-babel.org

+ 2 - 2
lisp/org-babel-table.el

@@ -63,8 +63,8 @@
 (defmacro sbe (source-block &rest variables)
 (defmacro sbe (source-block &rest variables)
   "Return the results of calling SOURCE-BLOCK with all assigning
   "Return the results of calling SOURCE-BLOCK with all assigning
 every variable in VARIABLES.  Each element of VARIABLES should be
 every variable in VARIABLES.  Each element of VARIABLES should be
-a two element list, who's first element is the name of the
-variable and second element is a string of it's value.  The
+a two element list, whose first element is the name of the
+variable and second element is a string of its value.  The
 following call to `sbe' would be equivalent to the following
 following call to `sbe' would be equivalent to the following
 source code block.
 source code block.
 
 

+ 32 - 10
org-babel-ded-worg.org

@@ -16,22 +16,41 @@
   
   
 * Basic org-babel functionality
 * Basic org-babel functionality
 *** Source code execution
 *** Source code execution
-    For interpreted languages such as shell, python, R etc, org-babel
-    allows source blocks to be *executed*: the code is passed to the
+    For interpreted languages such as shell, python, R, etc, org-babel
+    allows source blocks to be executed: the code is passed to the
     interpreter and you have control over what is done with the
     interpreter and you have control over what is done with the
     results of excecution. E.g. place point anywhere in the following
     results of excecution. E.g. place point anywhere in the following
     block and use C-c C-c to run the code:
     block and use C-c C-c to run the code:
 
 
-#+begin_src sh
-    date
-    hostname
-    whoami
+#+begin_src python :results output
+import time
+x = 4
+print("hello\n")
+#print time.ctime()
+print [5, 10]
 #+end_src
 #+end_src
 
 
 #+resname:
 #+resname:
-: Sun Jul  5 18:49:46 EDT 2009
-: Tichodroma
-: dan
+: hello
+: 510
+
+#+begin_src R :results value
+x = 4
+date()
+c(5, 10)
+#+end_src
+
+#+resname:
+|  5 |
+| 10 |
+
+
+
+
+
+
+
+
 
 
 
 
 
 
@@ -57,12 +76,13 @@
 **** Additional :results settings
 **** Additional :results settings
      
      
 
 
-
+     
 *** Arguments to source code blocks
 *** Arguments to source code blocks
     In addition to evaluation of code blocks, org-babel allows them to
     In addition to evaluation of code blocks, org-babel allows them to
     be parameterised (i.e. have arguments). Thus source code blocks
     be parameterised (i.e. have arguments). Thus source code blocks
     now have the status of *functions*.
     now have the status of *functions*.
 
 
+    
 *** Internals
 *** Internals
     For those interested in hacking org-babel, it's worth going
     For those interested in hacking org-babel, it's worth going
     through what actually happened there:
     through what actually happened there:
@@ -95,3 +115,5 @@
     
     
 #+resname:
 #+resname:
 : Sun Jul  5 14:13:07 2009
 : Sun Jul  5 14:13:07 2009
+
+    

+ 128 - 33
org-babel.org

@@ -1913,7 +1913,7 @@ This could probably be added to [[file:lisp/org-babel-script.el][org-babel-scrip
 (see [[* file result types][file result types]])
 (see [[* file result types][file result types]])
 
 
 
 
-* Bugs [17/23]
+* Bugs [17/26]
 ** TODO Allow source blocks to be recognised when #+ are not first characters on the line
 ** TODO Allow source blocks to be recognised when #+ are not first characters on the line
    I think Carsten has recently altered the core so that #+ can have
    I think Carsten has recently altered the core so that #+ can have
    preceding whitespace, at least for literal/code examples. org-babel
    preceding whitespace, at least for literal/code examples. org-babel
@@ -1960,6 +1960,36 @@ even a third"
    org-babel-execute:R. (I never learned how to do this properly: org-R
    org-babel-execute:R. (I never learned how to do this properly: org-R
    jumps all over the place...)
    jumps all over the place...)
 
 
+** TODO are the org-babel-trim s necessary?
+   at the end of e.g. org-babel-R-evaluate, org-babel-python-evaluate, but
+   not org-babel-ruby-evaluate
+** TODO use new merge function [[file:lisp/org-babel-ref.el::t%20nil%20org%20combine%20plists%20args%20nil][here]] and [[file:lisp/org-babel.el::params%20org%20combine%20plists%20params%20third%20info][here]]?
+   And at other occurrences of org-combine-plists?
+
+** TODO #+lob: calls fail if reference has single character name
+*** This doesn't work
+#+lob: R-plot(data=X)
+
+#+tblname: X
+| 1 |     1 |
+| 2 |    .5 |
+| 3 | .3333 |
+| 4 |   .25 |
+| 5 |    .2 |
+| 6 | .1666 |
+
+*** But this is OK
+#+tblname: XX
+| 1 |     1 |
+| 2 |    .5 |
+| 3 | .3333 |
+| 4 |   .25 |
+| 5 |    .2 |
+| 6 | .1666 |
+
+#+lob: R-plot(data=XX)
+
+
 ** DEFERRED weird escaped characters in shell prompt break shell evaluation
 ** DEFERRED weird escaped characters in shell prompt break shell evaluation
    E.g. this doesn't work. Should the shell sessions set a sane prompt
    E.g. this doesn't work. Should the shell sessions set a sane prompt
    when they start up? Or is it a question of altering
    when they start up? Or is it a question of altering
@@ -2129,19 +2159,13 @@ tables
 "schulte"
 "schulte"
 #+end_src
 #+end_src
 
 
+
 #+begin_src R :var num=little-fake
 #+begin_src R :var num=little-fake
 num
 num
 #+end_src
 #+end_src
 
 
 #+resname:
 #+resname:
 : schulte
 : schulte
-: 11
-: 11
-: 11
-: schulte
-: 9
-: 9
-: 11
 
 
 #+srcname: set-debug-on-error
 #+srcname: set-debug-on-error
 #+begin_src emacs-lisp :results silent
 #+begin_src emacs-lisp :results silent
@@ -2153,14 +2177,19 @@ num
 '(1 2 3)
 '(1 2 3)
 #+end_src
 #+end_src
 
 
+
+
+
 #+srcname: bug-R-number-evaluation
 #+srcname: bug-R-number-evaluation
-#+begin_src R :var table=bug-numerical-table :results replace
+#+begin_src R :var table=bug-numerical-table
 mean(mean(table))
 mean(mean(table))
 #+end_src
 #+end_src
 
 
 #+resname:
 #+resname:
 : 2
 : 2
 
 
+
+
 #+tblname: bug-vert-table
 #+tblname: bug-vert-table
 | 1 |
 | 1 |
 | 2 |
 | 2 |
@@ -2260,6 +2289,10 @@ As an example eval the following.  Adding a line to test
 ar.first.first
 ar.first.first
 #+end_src
 #+end_src
 
 
+
+
+
+
 ** DONE space trailing language name
 ** DONE space trailing language name
 fix regexp so it works when there's a space trailing the language name
 fix regexp so it works when there's a space trailing the language name
 
 
@@ -2310,6 +2343,9 @@ recognition of ruby arrays as such.
 | 1 | 2 | 3 | 4 |
 | 1 | 2 | 3 | 4 |
 
 
 
 
+
+
+
 * Tests
 * Tests
 Evaluate all the cells in this table for a comprehensive test of the
 Evaluate all the cells in this table for a comprehensive test of the
 org-babel functionality.
 org-babel functionality.
@@ -2320,38 +2356,38 @@ of these tests may fail.
 #+TBLNAME: org-babel-tests
 #+TBLNAME: org-babel-tests
 | functionality           | block                      | arg |    expected |     results | pass |
 | functionality           | block                      | arg |    expected |     results | pass |
 |-------------------------+----------------------------+-----+-------------+-------------+------|
 |-------------------------+----------------------------+-----+-------------+-------------+------|
-| basic evaluation        |                            |     |             |             |      |
-|-------------------------+----------------------------+-----+-------------+-------------+------|
-| emacs lisp              | basic-elisp                |     |           5 |             |      |
-| shell                   | basic-shell                |     |           6 |             |      |
-| ruby                    | basic-ruby                 |     |   org-babel |             |      |
-| python                  | basic-python               |     | hello world |             |      |
-| R                       | basic-R                    |     |          13 |             |      |
+| basic evaluation        |                            |     |             |             | pass |
 |-------------------------+----------------------------+-----+-------------+-------------+------|
 |-------------------------+----------------------------+-----+-------------+-------------+------|
-| tables                  |                            |     |             |             |      |
+| 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 |
 |-------------------------+----------------------------+-----+-------------+-------------+------|
 |-------------------------+----------------------------+-----+-------------+-------------+------|
-| emacs lisp              | table-elisp                |     |           3 |             |      |
-| ruby                    | table-ruby                 |     |       1-2-3 |             |      |
-| python                  | table-python               |     |           5 |             |      |
-| R                       | table-R                    |     |         3.5 |             |      |
+| tables                  |                            |     |             |             | pass |
 |-------------------------+----------------------------+-----+-------------+-------------+------|
 |-------------------------+----------------------------+-----+-------------+-------------+------|
-| source block references |                            |     |             |             |      |
+| 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 |
 |-------------------------+----------------------------+-----+-------------+-------------+------|
 |-------------------------+----------------------------+-----+-------------+-------------+------|
-| all languages           | chained-ref-last           |     |       Array |             |      |
+| source block references |                            |     |             |             | pass |
 |-------------------------+----------------------------+-----+-------------+-------------+------|
 |-------------------------+----------------------------+-----+-------------+-------------+------|
-| source block functions  |                            |     |             |             |      |
+| all languages           | chained-ref-last           |     |       Array | Array       | pass |
 |-------------------------+----------------------------+-----+-------------+-------------+------|
 |-------------------------+----------------------------+-----+-------------+-------------+------|
-| emacs lisp              | defun-fibb                 |     |       fibbd |             |      |
-| run over                | Fibonacci                  |   0 |           1 |             |      |
-| a                       | Fibonacci                  |   1 |           1 |             |      |
-| variety                 | Fibonacci                  |   2 |           2 |             |      |
-| of                      | Fibonacci                  |   3 |           3 |             |      |
-| different               | Fibonacci                  |   4 |           5 |             |      |
-| arguments               | Fibonacci                  |   5 |           8 |             |      |
+| source block functions  |                            |     |             |             | pass |
 |-------------------------+----------------------------+-----+-------------+-------------+------|
 |-------------------------+----------------------------+-----+-------------+-------------+------|
-| bugs and tasks          |                            |     |             |             |      |
+| 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 |
 |-------------------------+----------------------------+-----+-------------+-------------+------|
 |-------------------------+----------------------------+-----+-------------+-------------+------|
-| simple ruby arrays      | ruby-array-test            |     |           3 |             |      |
+| bugs and tasks          |                            |     |             |             | pass |
+|-------------------------+----------------------------+-----+-------------+-------------+------| |  | 
+| simple ruby arrays      | ruby-array-test            |     |           3 | 3           |      |
 | R number evaluation     | bug-R-number-evaluation    |     |           2 |             |      |
 | R number evaluation     | bug-R-number-evaluation    |     |           2 |             |      |
 | multi-line ruby blocks  | multi-line-ruby-test       |     |           2 |             |      |
 | multi-line ruby blocks  | multi-line-ruby-test       |     |           2 |             |      |
 | forcing vector results  | test-forced-vector-results |     |       Array |             |      |
 | forcing vector results  | test-forced-vector-results |     |       Array |             |      |
@@ -2373,11 +2409,19 @@ of these tests may fail.
 (+ 1 4)
 (+ 1 4)
 #+end_src
 #+end_src
 
 
+
+
+
+
+
 #+srcname: basic-shell
 #+srcname: basic-shell
 #+begin_src sh :results silent
 #+begin_src sh :results silent
 expr 1 + 5
 expr 1 + 5
 #+end_src
 #+end_src
 
 
+
+
+
 #+srcname: date-simple
 #+srcname: date-simple
 #+begin_src sh :results silent
 #+begin_src sh :results silent
 date
 date
@@ -2388,17 +2432,27 @@ date
 "org-babel"
 "org-babel"
 #+end_src
 #+end_src
 
 
+
+
+
 #+srcname: basic-python
 #+srcname: basic-python
 #+begin_src python :results silent
 #+begin_src python :results silent
 'hello world'
 'hello world'
 #+end_src
 #+end_src
 
 
+
+
+
 #+srcname: basic-R
 #+srcname: basic-R
 #+begin_src R :results silent
 #+begin_src R :results silent
 b <- 9
 b <- 9
 b + 4
 b + 4
 #+end_src
 #+end_src
 
 
+
+
+
+
 ** read tables
 ** read tables
 
 
 #+tblname: test-table
 #+tblname: test-table
@@ -2410,21 +2464,34 @@ b + 4
 (length (car table))
 (length (car table))
 #+end_src
 #+end_src
 
 
+
+
+
 #+srcname: table-ruby
 #+srcname: table-ruby
 #+begin_src ruby :results silent :var table=test-table
 #+begin_src ruby :results silent :var table=test-table
 table.first.join("-")
 table.first.join("-")
 #+end_src
 #+end_src
 
 
+
+
+
 #+srcname: table-python
 #+srcname: table-python
 #+begin_src python :var table=test-table
 #+begin_src python :var table=test-table
 table[1][1]
 table[1][1]
 #+end_src
 #+end_src
 
 
+
+
+
 #+srcname: table-R
 #+srcname: table-R
 #+begin_src R :var table=test-table
 #+begin_src R :var table=test-table
 mean(mean(table))
 mean(mean(table))
 #+end_src
 #+end_src
 
 
+
+
+
+
 ** references
 ** references
 
 
 Lets pass a references through all of our languages...
 Lets pass a references through all of our languages...
@@ -2469,6 +2536,10 @@ and Check that it is still a list
 table.class.name
 table.class.name
 #+end_src
 #+end_src
 
 
+
+
+
+
 ** source blocks as functions
 ** source blocks as functions
 
 
 #+srcname: defun-fibb
 #+srcname: defun-fibb
@@ -2476,11 +2547,33 @@ table.class.name
 (defun fibbd (n) (if (< n 2) 1 (+ (fibbd (- n 1)) (fibbd (- n 2)))))
 (defun fibbd (n) (if (< n 2) 1 (+ (fibbd (- n 1)) (fibbd (- n 2)))))
 #+end_src
 #+end_src
 
 
+
+
+
 #+srcname: fibonacci
 #+srcname: fibonacci
 #+begin_src emacs-lisp :results silent :var n=7
 #+begin_src emacs-lisp :results silent :var n=7
 (fibbd n)
 (fibbd n)
 #+end_src
 #+end_src
 
 
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 ** sbe tests (these don't seem to be working...)
 ** sbe tests (these don't seem to be working...)
 Testing the insertion of results into org-mode tables.
 Testing the insertion of results into org-mode tables.
 
 
@@ -2601,6 +2694,8 @@ a + b
 hist(rgamma(20,3,3))
 hist(rgamma(20,3,3))
 #+end_src
 #+end_src
 
 
+
+
 ** org-babel plays with tables
 ** org-babel plays with tables
 Alright, this should demonstrate both the ability of org-babel to read
 Alright, this should demonstrate both the ability of org-babel to read
 tables into a lisp source code block, and to then convert the results
 tables into a lisp source code block, and to then convert the results