Browse Source

Correcting errors in previously untested code.

Dan Davison 16 years ago
parent
commit
81ee8944ae
3 changed files with 58 additions and 14 deletions
  1. 45 4
      library-of-babel.org
  2. 10 6
      lisp/org-babel-lob.el
  3. 3 4
      lisp/org-babel.el

+ 45 - 4
library-of-babel.org

@@ -3,18 +3,59 @@
 #+OPTIONS: H:3 num:nil toc:t
 #+STARTUP: odd hideblocks
 
+[[http://downlode.org/Etext/library_of_babel.html][Full text of the Borges short story]]
+
 (setq lob (org-babel-lob-parse-buffer))
 (setq x (gethash 'plot lob))
 (hash-table-count lob)
 (maphash (lambda (key val) (insert key)) lob)
 
-[[http://downlode.org/Etext/library_of_babel.html][Full text of the Borges short story]]
+
 
 * Plotting code
   Plot column 2 (y axis) against column 1 (x axis). Columns 3 and beyond, if present, are ignored.
 #+srcname: plot
-#+begin_src R :var xy=__data__
-plot(xy)
+#+begin_src R
+plot(data)
+#+end_src
+
+#+begin_src babel :srcname plot :var data=10
+#+end_src
+
+#+srcname: plot
+#+begin_src R
+plot(__data__)
+#+end_src
+
+
+
+
+
+#+srcname: plot
+#+begin_src R
+plot(__data__)
+#+end_src
+
+#+resname: plot
+: org_babel_R_eoe
+: org_babel_R_eoe
+
+
+
+
+
+
+
+
+
+
+
+
+#+begin_src R
+79
 #+end_src
 
-[[file:/tmp/tmp.org][tem org file]]
+#+resname:
+: 79
+: 78
+: 77

+ 10 - 6
lisp/org-babel-lob.el

@@ -50,10 +50,14 @@
   (message "executing babel source code block...")
   (save-window-excursion
     (save-excursion
-      (org-babel-goto-srcname (cdr (assoc :srcname params))))
-    (forward-line 1)
-    (insert (match-string 0))
-    (org-babel-execute-src-block nil nil params)))
+      (org-babel-find-named-block (cdr (assoc :srcname params))))
+    (let ((block (match-string 0)))
+      (search-forward "#+end_src" nil t)
+      (forward-line 1)
+      (insert "\n")
+      (insert block)
+      (beginning-of-line)
+      (org-babel-execute-src-block nil nil params))))
 
 (defun org-babel-lob-parse-buffer ()
   "Read all source-code blocks in buffer into memory."
@@ -64,8 +68,8 @@
 	      org-babel-named-src-block-regexp nil t)
 	(puthash (match-string-no-properties 1)        ;; srcname
 		 (list (cons :lang (match-string-no-properties 2))
-		       (cons :body (match-string-no-properties 3))
-		       (cons :params (match-string-no-properties 4)))
+		       (cons :body (match-string-no-properties 5))
+		       (cons :params (match-string-no-properties 3)))
 		 blocks))
       blocks)))
 

+ 3 - 4
lisp/org-babel.el

@@ -231,18 +231,17 @@ If the point is not on a source block then return nil."
 
 (defun org-babel-find-named-block (name)
   "Find a named source-code block.
-
 Return the location of the source block identified by
 #+srcname NAME, or nil if no such block exists. Set match data
 according to org-babel-named-src-block-regexp."
   (save-excursion
     (let ((case-fold-search t)
-	  (regexp (org-babel-named-src-block-regexp name)) msg)
+	  (regexp (org-babel-named-src-block-regexp-for-name name)) msg)
       (unless (or (re-search-forward regexp nil t)
 		  (re-search-backward regexp nil t))
 	(progn (setq msg (format "source-code block '%s' not found in this buffer" name))
-	       (message msg) (error msg)))))
-  (point))
+	       (message msg) (error msg))))
+    (point)))
 
 (defun org-babel-find-named-result (name)
   "Return the location of the result named NAME in the current