Browse Source

DONE LoB is not populated on startup

Eric Schulte 16 years ago
parent
commit
05567124a8
4 changed files with 38 additions and 16 deletions
  1. 6 0
      lisp/org-babel-init.el
  2. 0 8
      lisp/org-babel-lob.el
  3. 8 6
      lisp/org-babel.el
  4. 24 2
      org-babel.org

+ 6 - 0
lisp/org-babel-init.el

@@ -64,5 +64,11 @@
 (require 'org-babel-asymptote)
 (require 'org-babel-sql)
 
+;; load the library of babel
+(org-babel-lob-ingest (expand-file-name
+                       "library-of-babel.org"
+                       (expand-file-name ".."
+                                         (file-name-directory (or load-file-name buffer-file-name)))))
+
 (provide 'org-babel-init)
 ;;; org-babel-init.el ends here

+ 0 - 8
lisp/org-babel-lob.el

@@ -49,18 +49,10 @@ add files to this list use the `org-babel-lob-ingest' command."
     (let ((source-name (intern (org-babel-get-src-block-name)))
           (info (org-babel-get-src-block-info)))
       (when source-name
-        ;; remove :var elements from params
-        ;; (once we have a better way of combining parameter lists then we won't have to do this)
-        (setf (third info) (assq-delete-all :var (third info)))
         (setq org-babel-library-of-babel
               (cons (cons source-name info)
                     (assq-delete-all source-name org-babel-library-of-babel)))))))
 
-(org-babel-lob-ingest ;; actually add the source-blocks defined in library-of-babel.org
- (expand-file-name
-  "library-of-babel.org"
-  (expand-file-name ".." (file-name-directory (or load-file-name buffer-file-name)))))
-
 ;; functions for executing lob one-liners
 
 (defvar org-babel-lob-one-liner-regexp "#\\+lob:[ \t]+\\([^\(\)\n]+\\)\(\\([^\n]*\\)\)[ \t]*\n")

+ 8 - 6
lisp/org-babel.el

@@ -307,12 +307,14 @@ of the following form.  (language body header-arguments-alist)"
 (defmacro org-babel-map-source-blocks (file &rest body)
   "Evaluate BODY forms on each source-block in FILE."
   (declare (indent 1))
-  `(save-window-excursion
-     (find-file ,file) (goto-char (point-min))
-     (while (re-search-forward org-babel-src-block-regexp nil t)
-       (goto-char (match-beginning 0))
-       (save-match-data ,@body)
-       (goto-char (match-end 0)))))
+  `(let ((visited-p (get-buffer (file-name-nondirectory file))))
+     (save-window-excursion
+       (find-file ,file) (goto-char (point-min))
+       (while (re-search-forward org-babel-src-block-regexp nil t)
+         (goto-char (match-beginning 0))
+         (save-match-data ,@body)
+         (goto-char (match-end 0))))
+     (unless visited-p (kill-buffer (file-name-nondirectory file)))))
 
 (defun org-babel-params-from-properties ()
   "Return an association list of any source block params which

+ 24 - 2
org-babel.org

@@ -2704,7 +2704,7 @@ dot("$(2a,0)$",(2,0),N+E);
 *** DONE sh
 
 
-* Bugs [29/39]
+* Bugs [30/39]
 ** 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
@@ -2887,9 +2887,31 @@ the same for the other languages. [Dan]
    at the end of e.g. org-babel-R-evaluate, org-babel-python-evaluate, but
    not org-babel-ruby-evaluate
 
-** TODO LoB is not populated on startup
+** DONE LoB is not populated on startup
    org-babel-library-of-babel is nil for me on startup. I have to
    evaluate the [[file:lisp/org-babel-lob.el::][org-babel-lob-ingest]] line manually.
+
+#+tblname: R-plot-example-data
+| 1 |  2 |
+| 2 |  4 |
+| 3 |  9 |
+| 4 | 16 |
+| 5 | 25 |
+
+#+lob: R-plot(data=R-plot-example-data)
+
+
+
+   I've added a section to [[file:lisp/org-babel-init.el][org-babel-init.el]] which will load the
+   library of babel on startup.
+
+   Note that this needs to be done in [[file:lisp/org-babel-init.el][org-babel-init.el]] rather than in
+   [[file:lisp/org-babel-lob.el][org-babel-lob.el]], not entirely sure why, something about it being
+   required directly?
+
+   Also, I'm now having the file closed if it wasn't being visited by
+   a buffer before being loaded.
+
 ** DONE use new merge function [[file:lisp/org-babel-ref.el::t%20nil%20org%20combine%20plists%20args%20nil][here]]?
    And at other occurrences of org-combine-plists?
 ** DONE creeping blank lines