summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Schulte <schulte.eric@gmail.com>2010-10-15 18:42:26 -0600
committerDan Davison <davison@stats.ox.ac.uk>2010-10-21 13:06:00 +0100
commit832dc71f31b046bfaf032aa592a71df43082826d (patch)
treed6dbc2663809f5ac0658b073c41a0050294c2ba5
parent3ab7f12792449e28dcc3e298523b1ab1fca26898 (diff)
downloadorg-mode-832dc71f31b046bfaf032aa592a71df43082826d.tar.gz
ob-lob: now working with the new ob-get-src-block-info
ob-get-src-block-info wasn't correctly returning the name of the code block * lisp/ob-lob.el (org-babel-lob-ingest): now returns the count of ingested code blocks * lisp/ob.el (org-babel-get-src-block-info): walks up possible additional header arg lines before checking for the code block name (org-babel-merge-params): can now handle empty variables gracefully
-rw-r--r--lisp/ob-lob.el3
-rw-r--r--lisp/ob.el30
-rw-r--r--testing/lisp/test-ob-lob.el31
3 files changed, 48 insertions, 16 deletions
diff --git a/lisp/ob-lob.el b/lisp/ob-lob.el
index 81533b4..0f9a279 100644
--- a/lisp/ob-lob.el
+++ b/lisp/ob-lob.el
@@ -59,7 +59,8 @@ To add files to this list use the `org-babel-lob-ingest' command."
(assq-delete-all source-name org-babel-library-of-babel))
lob-ingest-count (1+ lob-ingest-count)))))
(message "%d src block%s added to Library of Babel"
- lob-ingest-count (if (> lob-ingest-count 1) "s" ""))))
+ lob-ingest-count (if (> lob-ingest-count 1) "s" ""))
+ lob-ingest-count))
(defconst org-babel-lob-call-aliases '("lob" "call")
"Aliases to call a source block function.
diff --git a/lisp/ob.el b/lisp/ob.el
index c51f68a..aa2552e 100644
--- a/lisp/ob.el
+++ b/lisp/ob.el
@@ -175,22 +175,20 @@ Returns a list
(setq info (org-babel-parse-src-block-match))
(setq indent (car (last info)))
(setq info (butlast info))
- (forward-line -1)
+ (while (and (forward-line -1)
+ (looking-at org-babel-multi-line-header-regexp))
+ (setf (nth 2 info)
+ (org-babel-merge-params
+ (org-babel-parse-header-arguments (match-string 1))
+ (nth 2 info))))
(when (looking-at org-babel-src-name-w-name-regexp)
- (setq name (org-babel-clean-text-properties (match-string 3)))
+ (setq name (org-babel-clean-text-properties (match-string 4)))
(when (match-string 5)
(setf (nth 2 info) ;; merge functional-syntax vars and header-args
(org-babel-merge-params
(mapcar (lambda (ref) (cons :var ref))
(org-babel-ref-split-args (match-string 5)))
- (nth 2 info)))))
- (goto-char head)
- (while (and (forward-line -1)
- (looking-at org-babel-multi-line-header-regexp))
- (setf (nth 2 info)
- (org-babel-merge-params
- (org-babel-parse-header-arguments (match-string 1))
- (nth 2 info)))))
+ (nth 2 info))))))
;; inline source block
(when (save-excursion (re-search-backward "[ \f\t\n\r\v]" nil t)
(looking-at org-babel-inline-src-block-regexp))
@@ -1549,11 +1547,13 @@ parameters when merging lists."
(:var
(let ((name (if (listp (cdr pair))
(cadr pair)
- (string-match
- "^\\([^= \f\t\n\r\v]+\\)[ \t]*="
- (cdr pair))
- (intern (match-string 1 (cdr pair))))))
- (unless (member name (mapcar #'car vars))
+ (and
+ (string-match
+ "^\\([^= \f\t\n\r\v]+\\)[ \t]*="
+ (cdr pair))
+ (intern (match-string 1 (cdr pair)))))))
+ (when (and name
+ (not (member name (mapcar #'car vars))))
(setq vars (cons (cons name (cdr pair)) vars)))))
(:results
(setq results
diff --git a/testing/lisp/test-ob-lob.el b/testing/lisp/test-ob-lob.el
new file mode 100644
index 0000000..5461663
--- /dev/null
+++ b/testing/lisp/test-ob-lob.el
@@ -0,0 +1,31 @@
+;;; test-ob-lob.el
+
+;; Copyright (c) 2010 Eric Schulte
+;; Authors: Eric Schulte
+
+;; Released under the GNU General Public License version 3
+;; see: http://www.gnu.org/licenses/gpl-3.0.html
+
+;;;; Comments:
+
+;; Template test file for Org-mode tests
+
+
+;;; Code:
+(let ((load-path (cons (expand-file-name
+ ".." (file-name-directory
+ (or load-file-name buffer-file-name)))
+ load-path)))
+ (require 'org-test)
+ (require 'org-test-ob-consts))
+
+
+;;; Tests
+(ert-deftest test-ob-lob/ingest ()
+ "Test the ingestion of an org-mode file."
+ (should (< 0 (org-babel-lob-ingest
+ (expand-file-name "babel.org" org-test-example-dir)))))
+
+(provide 'test-ob-lob)
+
+;;; test-ob-lob.el ends here