forked from mirrors/org-mode
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
This commit is contained in:
parent
3ab7f12792
commit
832dc71f31
|
@ -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.
|
||||
|
|
32
lisp/ob.el
32
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)
|
||||
(when (looking-at org-babel-src-name-w-name-regexp)
|
||||
(setq name (org-babel-clean-text-properties (match-string 3)))
|
||||
(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))))
|
||||
(when (looking-at org-babel-src-name-w-name-regexp)
|
||||
(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))))))
|
||||
;; 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
|
||||
|
|
31
testing/lisp/test-ob-lob.el
Normal file
31
testing/lisp/test-ob-lob.el
Normal file
|
@ -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
|
Loading…
Reference in a new issue