1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-11-22 07:09:47 +00:00

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'.
This commit is contained in:
Eric Schulte 2013-06-20 09:53:56 -06:00
parent bd987e3804
commit a79fd4be28
3 changed files with 75 additions and 66 deletions

View File

@ -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.

View File

@ -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

View File

@ -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)))))