summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Schulte <schulte.eric@gmail.com>2013-06-20 15:53:56 (GMT)
committer Eric Schulte <schulte.eric@gmail.com>2013-06-20 15:53:56 (GMT)
commita79fd4be2863a300c88218b40b1adca23d9e1eb8 (patch)
tree20d73cab74f8acc0e0bc778f541e0620b1250dda
parentbd987e3804eba79d864de929bf5fed9480167741 (diff)
downloadorg-mode-a79fd4be2863a300c88218b40b1adca23d9e1eb8.zip
org-mode-a79fd4be2863a300c88218b40b1adca23d9e1eb8.tar.gz
fix babel merge params bug from commit 693dda67
The `org-babel-params-from-properties' command was calling `org-babel-merge-params', the output of which was then being fed back to another call to `org-babel-merge-params'. The merge params function is not designed to allow this form of recursive calling, and as a result many variables were being set to empty values. The first noticed side effect of this bug was the breakage of the org-babel-load-file command, which relies on default header arguments (namely :tangle), which were overwritten by the bug above. The fix involved having the `org-babel-params-from-properties' function return a list of alists, which may then all be handed to the top-level merge-params call. * lisp/ob-core.el (org-babel-params-from-properties): Now returns a list of alists and does *not* call `org-babel-merge-params'. (org-babel-parse-src-block-match): Handle new list of lists output of `org-babel-params-from-properties'. (org-babel-parse-inline-src-block-match): Handle new list of lists output of `org-babel-params-from-properties'. * lisp/ob-exp.el (org-babel-exp-src-block): Handle new list of lists output of `org-babel-params-from-properties'. (org-babel-exp-non-block-elements): Handle new list of lists output of `org-babel-params-from-properties'. * lisp/ob-lob.el (org-babel-lob-execute): Handle new list of lists output of `org-babel-params-from-properties'.
-rw-r--r--lisp/ob-core.el88
-rw-r--r--lisp/ob-exp.el33
-rw-r--r--lisp/ob-lob.el20
3 files changed, 75 insertions, 66 deletions
diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index d339475..e2cb03b 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -1291,38 +1291,38 @@ portions of results lines."
(defvar org-file-properties)
(defun org-babel-params-from-properties (&optional lang)
"Retrieve parameters specified as properties.
-Return an association list of any source block params which
-may be specified in the properties of the current outline entry."
+Return a list of association lists of source block params
+specified in the properties of the current outline entry."
(save-match-data
- (let* ((lang-props
- (save-match-data
- (org-babel-parse-header-arguments
- (org-entry-get (point) (concat "header-args:" lang)
- 'inherit))))
- (default-props
- (save-match-data
- (org-babel-parse-header-arguments
- (org-entry-get (point) "header-args"
- 'inherit))))
- (props
- (let (val sym)
- (org-babel-parse-multiple-vars
- (delq nil
- (mapcar
- (lambda (header-arg)
- (and (setq val (org-entry-get (point) header-arg t))
- (cons (intern (concat ":" header-arg))
- (org-babel-read val))))
- (mapcar
- #'symbol-name
- (mapcar
- #'car
- (org-babel-combine-header-arg-lists
- org-babel-common-header-args-w-values
- (progn
- (setq sym (intern (concat "org-babel-header-args:" lang)))
- (and (boundp sym) (eval sym))))))))))))
- (org-babel-merge-params props default-props lang-props))))
+ (list
+ ;; header arguments specified as separate property
+ (let (val sym)
+ (org-babel-parse-multiple-vars
+ (delq nil
+ (mapcar
+ (lambda (header-arg)
+ (and (setq val (org-entry-get (point) header-arg t))
+ (cons (intern (concat ":" header-arg))
+ (org-babel-read val))))
+ (mapcar
+ #'symbol-name
+ (mapcar
+ #'car
+ (org-babel-combine-header-arg-lists
+ org-babel-common-header-args-w-values
+ (progn
+ (setq sym (intern (concat "org-babel-header-args:" lang)))
+ (and (boundp sym) (eval sym))))))))))
+ ;; header arguments specified with the header-args property
+ (save-match-data
+ (org-babel-parse-header-arguments
+ (org-entry-get (point) "header-args"
+ 'inherit)))
+ ;; language-specific header arguments
+ (save-match-data
+ (org-babel-parse-header-arguments
+ (org-entry-get (point) (concat "header-args:" lang)
+ 'inherit))))))
(defvar org-src-preserve-indentation)
(defun org-babel-parse-src-block-match ()
@@ -1348,12 +1348,13 @@ may be specified in the properties of the current outline entry."
(insert (org-unescape-code-in-string body))
(unless preserve-indentation (org-do-remove-indentation))
(buffer-string)))
- (org-babel-merge-params
- org-babel-default-header-args
- (when (boundp lang-headers) (eval lang-headers))
- (org-babel-params-from-properties lang)
- (org-babel-parse-header-arguments
- (org-no-properties (or (match-string 4) ""))))
+ (apply #'org-babel-merge-params
+ org-babel-default-header-args
+ (when (boundp lang-headers) (eval lang-headers))
+ (append
+ (org-babel-params-from-properties lang)
+ (list (org-babel-parse-header-arguments
+ (org-no-properties (or (match-string 4) ""))))))
switches
block-indentation)))
@@ -1363,12 +1364,13 @@ may be specified in the properties of the current outline entry."
(lang-headers (intern (concat "org-babel-default-header-args:" lang))))
(list lang
(org-unescape-code-in-string (org-no-properties (match-string 5)))
- (org-babel-merge-params
- org-babel-default-inline-header-args
- (if (boundp lang-headers) (eval lang-headers) nil)
- (org-babel-params-from-properties lang)
- (org-babel-parse-header-arguments
- (org-no-properties (or (match-string 4) "")))))))
+ (apply #'org-babel-merge-params
+ org-babel-default-inline-header-args
+ (if (boundp lang-headers) (eval lang-headers) nil)
+ (append
+ (org-babel-params-from-properties lang)
+ (list (org-babel-parse-header-arguments
+ (org-no-properties (or (match-string 4) "")))))))))
(defun org-babel-balanced-split (string alts)
"Split STRING on instances of ALTS.
diff --git a/lisp/ob-exp.el b/lisp/ob-exp.el
index 7b3e04a..12aa380 100644
--- a/lisp/ob-exp.el
+++ b/lisp/ob-exp.el
@@ -122,11 +122,11 @@ Assume point is at the beginning of block's starting line."
(org-babel-exp-in-export-file lang
(setf (nth 2 info)
(org-babel-process-params
- (org-babel-merge-params
- org-babel-default-header-args
- (if (boundp lang-headers) (eval lang-headers) nil)
- (org-babel-params-from-properties lang)
- raw-params))))
+ (apply #'org-babel-merge-params
+ org-babel-default-header-args
+ (if (boundp lang-headers) (eval lang-headers) nil)
+ (append (org-babel-params-from-properties lang)
+ (list raw-params))))))
(setf hash (org-babel-sha1-hash info)))
(org-babel-exp-do-export info 'block hash)))))
@@ -206,16 +206,19 @@ this template."
(results
(org-babel-exp-do-export
(list "emacs-lisp" "results"
- (org-babel-merge-params
- org-babel-default-header-args
- org-babel-default-lob-header-args
- (org-babel-params-from-properties)
- (org-babel-parse-header-arguments
- (org-no-properties
- (concat ":var results="
- (mapconcat 'identity
- (butlast lob-info)
- " ")))))
+ (apply #'org-babel-merge-params
+ org-babel-default-header-args
+ org-babel-default-lob-header-args
+ (append
+ (org-babel-params-from-properties)
+ (list
+ (org-babel-parse-header-arguments
+ (org-no-properties
+ (concat
+ ":var results="
+ (mapconcat 'identity
+ (butlast lob-info)
+ " ")))))))
"" nil (car (last lob-info)))
'lob))
(rep (org-fill-template
diff --git a/lisp/ob-lob.el b/lisp/ob-lob.el
index a1a65f8..f9b7b4c 100644
--- a/lisp/ob-lob.el
+++ b/lisp/ob-lob.el
@@ -120,14 +120,18 @@ if so then run the appropriate source block from the Library."
(defun org-babel-lob-execute (info)
"Execute the lob call specified by INFO."
(let* ((mkinfo (lambda (p) (list "emacs-lisp" "results" p nil nil (nth 2 info))))
- (pre-params (org-babel-merge-params
- org-babel-default-header-args
- org-babel-default-header-args:emacs-lisp
- (org-babel-params-from-properties)
- (org-babel-parse-header-arguments
- (org-no-properties
- (concat ":var results="
- (mapconcat #'identity (butlast info) " "))))))
+ (pre-params (apply #'org-babel-merge-params
+ org-babel-default-header-args
+ org-babel-default-header-args:emacs-lisp
+ (append
+ (org-babel-params-from-properties)
+ (list
+ (org-babel-parse-header-arguments
+ (org-no-properties
+ (concat
+ ":var results="
+ (mapconcat #'identity (butlast info)
+ " "))))))))
(pre-info (funcall mkinfo pre-params))
(cache-p (and (cdr (assoc :cache pre-params))
(string= "yes" (cdr (assoc :cache pre-params)))))