Browse Source

OK, I'm getting confused in magit and committing only a single hunk
when I intended several. Hence, the commit note for this commit is the
commit note filed with the previous commit: da82dae9391904604a02502cf72d91929f152344

Dan Davison 16 years ago
parent
commit
b300b62b9c
1 changed files with 30 additions and 29 deletions
  1. 30 29
      lisp/org-babel-lob.el

+ 30 - 29
lisp/org-babel-lob.el

@@ -29,43 +29,44 @@
 ;; See org-babel.org in the parent directory for more information
 
 ;;; Code:
-(require 'org)
+(require 'org-babel)
+
+(org-babel-add-interpreter "babel")
 
 (defun org-babel-execute:babel (body params)
   "Execute a library-of-babel block.
 
-  These blocks do not have their own body. Instead they use a :srcname
-  header argument to reference a different source block, whose body
-  they use. Source blocks in the library of babel should use a
-  standard naming scheme for the variable containing the input data
-  for analysis / plotting. E.g. if that variable is always called
-  __data__ then one of these bodyless babel blocks will call a library
-  of babel block using :var __data__=<some reference>
+  These blocks do not have their own body. Instead they use
+  a :srcname header argument to reference a different source
+  block, whose body they use. Source blocks in the library of
+  babel should use a standard naming scheme for the variable
+  containing the input data for analysis / plotting. E.g. if that
+  variable is always called __data__ then one of these bodyless
+  babel blocks will call a library of babel block using :var
+  __data__=<some reference>. The header args from a babel block
+  are appended to the header args from the target block.
 
   This function is called by `org-babel-execute-src-block'."
   (message "executing babel source code block...")
   (save-window-excursion
-    (let ((srcname (cdr (assoc :srcname params))))
-      
-      ;; now locate the source block specified by srcname (it might be
-      ;; in the library of babel), and construct a new source block
-      ;; as follows:
-      ;;
-      ;; 1. The lang is the lang of the referenced source block
-      ;; 2. The header args are those from the current #+begin_src babel block
-      ;; 3. The body is from the reference source block
-
-      ;; If using a library of babel function, then the
-      ;; resposnsibility id on the caller to name the :var arg(s)
-      ;; correctly. We could adopt a standard name such as __data__
-      ;; for the input data for plotting / analysis. Thus in lob
-      ;; source blocks the data variable would be referred to as
-      ;; __data__ in the code, and the babel block would use :var
-      ;; __data__=<some reference>
+    (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)))
 
-      ;; Now execute the constructed source block, ensuring that this
-      ;; buffer receives the appropriate output, and only receives a
-      ;; copy of the referenced source block if requested
-)))
+(defun org-babel-lob-parse-buffer ()
+  "Read all source-code blocks in buffer into memory."
+  (save-excursion
+    (goto-char (point-min))
+    (let ((blocks (make-hash-table)))
+      (while (re-search-forward
+	      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)))
+		 blocks))
+      blocks)))
 
 (provide 'org-babel-lob)