From a33b96c3d695ef9cd44f7d19a1bc4a7999b9371b Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Fri, 7 Aug 2009 21:17:31 -0600 Subject: [PATCH 01/15] added link to code repo to org-babel-worg.org --- org-babel-worg.org | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/org-babel-worg.org b/org-babel-worg.org index c8646ad2f..ef1a87269 100644 --- a/org-babel-worg.org +++ b/org-babel-worg.org @@ -31,7 +31,12 @@ 3. exportation of source code blocks to files (literate programming) * Getting started - Add the following lines to your .emacs, replacing the path as + Grab the latest code from the git repo at [[http://github.com/eschulte/org-babel/tree/master][github/org-babel]] +#+begin_src sh +git clone git://github.com/eschulte/org-babel.git +#+end_src + + And add the following lines to your .emacs, replacing the path as appropriate. A good place to check that things are up and running would the examples in [[* Basic org-babel functionality][Basic org-babel functionality]]. #+begin_src emacs-lisp From 2f50cb659f107e529d2924897028a6566d11b04b Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Sun, 9 Aug 2009 08:29:06 -0600 Subject: [PATCH 02/15] DONE Allow source blocks to be recognised when #+ are not first characters on the line --- lisp/org-babel.el | 11 ++++++++--- org-babel.org | 28 +++++++++++++++++++++------- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/lisp/org-babel.el b/lisp/org-babel.el index 35c2d0568..63a7f75c7 100644 --- a/lisp/org-babel.el +++ b/lisp/org-babel.el @@ -98,7 +98,7 @@ then run `org-babel-pop-to-session'." (defun org-babel-set-interpreters (var value) (set-default var value) (setq org-babel-src-block-regexp - (concat "#\\+begin_src \\(" + (concat "^[ \t]*#\\+begin_src \\(" (mapconcat 'regexp-quote value "\\|") "\\)[ \t]*" "\\([ \t]+\\([^\n]+\\)\\)?\n" ;; match header arguments @@ -331,9 +331,14 @@ may be specified in the properties of the current outline entry." (defun org-babel-parse-src-block-match () (let* ((lang (org-babel-clean-text-properties (match-string 1))) - (lang-headers (intern (concat "org-babel-default-header-args:" lang)))) + (lang-headers (intern (concat "org-babel-default-header-args:" lang))) + (body (org-babel-clean-text-properties (match-string 4)))) (list lang - (org-babel-strip-protective-commas (org-babel-clean-text-properties (match-string 4))) + (with-temp-buffer ;; get src block body removing properties, protective commas, and indentation + (save-match-data + (insert (org-babel-strip-protective-commas body)) + (org-do-remove-indentation) + (buffer-string))) (org-babel-merge-params org-babel-default-header-args (org-babel-params-from-properties) diff --git a/org-babel.org b/org-babel.org index 1811b2f51..36746f4d1 100644 --- a/org-babel.org +++ b/org-babel.org @@ -2743,7 +2743,7 @@ dot("$(2a,0)$",(2,0),N+E); *** DONE sh -* Bugs [31/40] +* Bugs [32/40] ** TODO export problems when support for a language is missing we should come up with a way to gracefully degrade when support for a specific language is missing @@ -2868,12 +2868,6 @@ even a third" #+begin_src sh size=5 #+end_src - -** 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 - preceding whitespace, at least for literal/code examples. org-babel - should support this. - ** TODO non-orgtbl formatted lists for example @@ -2929,6 +2923,26 @@ the same for the other languages. [Dan] find . \( -path \*/SCCS -o -path \*/RCS -o -path \*/CVS -o -path \*/MCVS -o -path \*/.svn -o -path \*/.git -o -path \*/.hg -o -path \*/.bzr -o -path \*/_MTN -o -path \*/_darcs -o -path \*/\{arch\} \) -prune -o -type f \( -iname \*.el \) -exec grep -i -nH -e org-babel-trim {} \; #+end_src +** DONE 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 + preceding whitespace, at least for literal/code examples. org-babel + should support this. + +#+srcname: testing-indentation + #+begin_src emacs-lisp :results silent + (message "i'm indented") + #+end_src + +#+srcname: testing-non-indentation +#+begin_src emacs-lisp :results silent +(message "I'm not indented") +#+end_src + +#+srcname: i-resolve-references-to-the-indented +#+begin_src emacs-lisp :var speech=testing-indentation :results silent +(message "I said %s" speech) +#+end_src + ** DONE 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 From 9f337b983ca98032a23f63515fbedb291ec695e8 Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Sun, 9 Aug 2009 12:36:10 -0600 Subject: [PATCH 03/15] additions to org-babel-worg.org --- org-babel-worg.org | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/org-babel-worg.org b/org-babel-worg.org index ef1a87269..a2a8e0ee4 100644 --- a/org-babel-worg.org +++ b/org-babel-worg.org @@ -52,17 +52,12 @@ git clone git://github.com/eschulte/org-babel.git results of excecution. E.g. place point anywhere in the following block and use C-c C-c to run the code: -#+begin_src python :results output -import time -x = 4 -print("hello\n") -#print time.ctime() -print [5, 10] +#+begin_src ruby +"This file was last evaluated on #{Date.today}" #+end_src #+resname: -: hello -: 510 +: This file was last evaluated on 2009-08-09 #+begin_src R :results value x = 4 @@ -95,11 +90,32 @@ c(5, 10) users). **** Additional :results settings -*** Arguments to source code blocks +*** QUOTE Arguments to source code blocks In addition to evaluation of code blocks, org-babel allows them to be parameterised (i.e. have arguments). Thus source code blocks now have the status of *functions*. +Inputs for fibonacci-seq + +#+tblname: fibonacci-inputs +| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | +| 2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 | 18 | 20 | + +#+srcname: fibonacci-seq +#+begin_src emacs-lisp :var fib-inputs=fibonacci-inputs + (defun fibonacci (n) + (if (or (= n 0) (= n 1)) + n + (+ (fibonacci (- n 1)) (fibonacci (- n 2))))) + + (mapcar (lambda (row) + (mapcar #'fibonacci row)) fib-inputs) +#+end_src + +#+resname: +| 1 | 1 | 2 | 3 | 5 | 8 | 13 | 21 | 34 | 55 | +| 1 | 3 | 8 | 21 | 55 | 144 | 377 | 987 | 2584 | 6765 | + * A meta-programming language for org-mode * Spreadsheet plugins for org-mode in any language * Library of Babel From f6f514596a3107d004e44321321e5ccf7d009e08 Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Sun, 9 Aug 2009 12:40:23 -0600 Subject: [PATCH 04/15] small changes to org-babel-worg.org --- org-babel-worg.org | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/org-babel-worg.org b/org-babel-worg.org index a2a8e0ee4..ede7b9247 100644 --- a/org-babel-worg.org +++ b/org-babel-worg.org @@ -52,19 +52,23 @@ git clone git://github.com/eschulte/org-babel.git results of excecution. E.g. place point anywhere in the following block and use C-c C-c to run the code: +[[http://www.ruby-lang.org/][Ruby]] source code #+begin_src ruby "This file was last evaluated on #{Date.today}" #+end_src +Results of Ruby evaluation #+resname: : This file was last evaluated on 2009-08-09 +[[http://www.r-project.org/][R]] source code #+begin_src R :results value x = 4 date() c(5, 10) #+end_src +Results of R evaluation #+resname: | 5 | | 10 | @@ -90,7 +94,7 @@ c(5, 10) users). **** Additional :results settings -*** QUOTE Arguments to source code blocks +*** Arguments to source code blocks In addition to evaluation of code blocks, org-babel allows them to be parameterised (i.e. have arguments). Thus source code blocks now have the status of *functions*. From a44766514ebd13f9c3dc2adbfde1a0759e12160d Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Sun, 9 Aug 2009 12:43:59 -0600 Subject: [PATCH 05/15] more changes to og-worg, specifically "* Arguments to source code blocks" --- org-babel-worg.org | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/org-babel-worg.org b/org-babel-worg.org index ede7b9247..7bf8021cb 100644 --- a/org-babel-worg.org +++ b/org-babel-worg.org @@ -105,6 +105,12 @@ Inputs for fibonacci-seq | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | | 2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 | 18 | 20 | +in the Org-mode buffer this looks like +: #+tblname: fibonacci-inputs +: | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | +: | 2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 | 18 | 20 | + +[[http://www.gnu.org/software/emacs/manual/elisp.html][Emacs Lisp]] source code #+srcname: fibonacci-seq #+begin_src emacs-lisp :var fib-inputs=fibonacci-inputs (defun fibonacci (n) @@ -116,6 +122,19 @@ Inputs for fibonacci-seq (mapcar #'fibonacci row)) fib-inputs) #+end_src +in the Org-mode buffer this looks like +: #+srcname: fibonacci-seq +: #+begin_src emacs-lisp :var fib-inputs=fibonacci-inputs +: (defun fibonacci (n) +: (if (or (= n 0) (= n 1)) +: n +: (+ (fibonacci (- n 1)) (fibonacci (- n 2))))) +: +: (mapcar (lambda (row) +: (mapcar #'fibonacci row)) fib-inputs) +: #+end_src + +Results of Emacs Lisp code evaluation #+resname: | 1 | 1 | 2 | 3 | 5 | 8 | 13 | 21 | 34 | 55 | | 1 | 3 | 8 | 21 | 55 | 144 | 377 | 987 | 2584 | 6765 | From 145b6a14a0fc5b6cfd70489f446a74725fb9cd29 Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Sun, 9 Aug 2009 12:49:07 -0600 Subject: [PATCH 06/15] updates to publish information for org-babel-documentation --- publish-babel.org | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/publish-babel.org b/publish-babel.org index e9fc0a159..2441265d5 100644 --- a/publish-babel.org +++ b/publish-babel.org @@ -17,7 +17,7 @@ publishing. Publish a project with =C-c C-e X=. `("org-babel-documentation" :base-directory ,org-babel-dir :base-extension "org" - :exclude "org-babel.org" + :exclude ,(regexp-opt-group '("org-babel.org" "test-export.org" "test-tangle.org" "test-tangle-load.org")) :publishing-directory ,(expand-file-name "doc" org-babel-dir) :index-filename "org-babel-worg.org" :auto-postamble nil From fe0022c1987851858c81043c9f824e6e16997eca Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Sun, 9 Aug 2009 13:25:20 -0600 Subject: [PATCH 07/15] the biblical quote may be too much... I just couldn't help myself --- org-babel-worg.org | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/org-babel-worg.org b/org-babel-worg.org index 7bf8021cb..b69cd553b 100644 --- a/org-babel-worg.org +++ b/org-babel-worg.org @@ -14,12 +14,13 @@ #+end_html From 8fbb932110fed27ae60339c5065241046d56acbf Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Sun, 9 Aug 2009 18:47:00 -0600 Subject: [PATCH 08/15] truncating bible quote --- org-babel-worg.org | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org-babel-worg.org b/org-babel-worg.org index b69cd553b..526e107f1 100644 --- a/org-babel-worg.org +++ b/org-babel-worg.org @@ -15,7 +15,7 @@