1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-11-25 07:27:57 +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) (defvar org-file-properties)
(defun org-babel-params-from-properties (&optional lang) (defun org-babel-params-from-properties (&optional lang)
"Retrieve parameters specified as properties. "Retrieve parameters specified as properties.
Return an association list of any source block params which Return a list of association lists of source block params
may be specified in the properties of the current outline entry." specified in the properties of the current outline entry."
(save-match-data (save-match-data
(let* ((lang-props (list
(save-match-data ;; header arguments specified as separate property
(org-babel-parse-header-arguments (let (val sym)
(org-entry-get (point) (concat "header-args:" lang) (org-babel-parse-multiple-vars
'inherit)))) (delq nil
(default-props (mapcar
(save-match-data (lambda (header-arg)
(org-babel-parse-header-arguments (and (setq val (org-entry-get (point) header-arg t))
(org-entry-get (point) "header-args" (cons (intern (concat ":" header-arg))
'inherit)))) (org-babel-read val))))
(props (mapcar
(let (val sym) #'symbol-name
(org-babel-parse-multiple-vars (mapcar
(delq nil #'car
(mapcar (org-babel-combine-header-arg-lists
(lambda (header-arg) org-babel-common-header-args-w-values
(and (setq val (org-entry-get (point) header-arg t)) (progn
(cons (intern (concat ":" header-arg)) (setq sym (intern (concat "org-babel-header-args:" lang)))
(org-babel-read val)))) (and (boundp sym) (eval sym))))))))))
(mapcar ;; header arguments specified with the header-args property
#'symbol-name (save-match-data
(mapcar (org-babel-parse-header-arguments
#'car (org-entry-get (point) "header-args"
(org-babel-combine-header-arg-lists 'inherit)))
org-babel-common-header-args-w-values ;; language-specific header arguments
(progn (save-match-data
(setq sym (intern (concat "org-babel-header-args:" lang))) (org-babel-parse-header-arguments
(and (boundp sym) (eval sym)))))))))))) (org-entry-get (point) (concat "header-args:" lang)
(org-babel-merge-params props default-props lang-props)))) 'inherit))))))
(defvar org-src-preserve-indentation) (defvar org-src-preserve-indentation)
(defun org-babel-parse-src-block-match () (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)) (insert (org-unescape-code-in-string body))
(unless preserve-indentation (org-do-remove-indentation)) (unless preserve-indentation (org-do-remove-indentation))
(buffer-string))) (buffer-string)))
(org-babel-merge-params (apply #'org-babel-merge-params
org-babel-default-header-args org-babel-default-header-args
(when (boundp lang-headers) (eval lang-headers)) (when (boundp lang-headers) (eval lang-headers))
(org-babel-params-from-properties lang) (append
(org-babel-parse-header-arguments (org-babel-params-from-properties lang)
(org-no-properties (or (match-string 4) "")))) (list (org-babel-parse-header-arguments
(org-no-properties (or (match-string 4) ""))))))
switches switches
block-indentation))) 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)))) (lang-headers (intern (concat "org-babel-default-header-args:" lang))))
(list lang (list lang
(org-unescape-code-in-string (org-no-properties (match-string 5))) (org-unescape-code-in-string (org-no-properties (match-string 5)))
(org-babel-merge-params (apply #'org-babel-merge-params
org-babel-default-inline-header-args org-babel-default-inline-header-args
(if (boundp lang-headers) (eval lang-headers) nil) (if (boundp lang-headers) (eval lang-headers) nil)
(org-babel-params-from-properties lang) (append
(org-babel-parse-header-arguments (org-babel-params-from-properties lang)
(org-no-properties (or (match-string 4) ""))))))) (list (org-babel-parse-header-arguments
(org-no-properties (or (match-string 4) "")))))))))
(defun org-babel-balanced-split (string alts) (defun org-babel-balanced-split (string alts)
"Split STRING on instances of 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 (org-babel-exp-in-export-file lang
(setf (nth 2 info) (setf (nth 2 info)
(org-babel-process-params (org-babel-process-params
(org-babel-merge-params (apply #'org-babel-merge-params
org-babel-default-header-args org-babel-default-header-args
(if (boundp lang-headers) (eval lang-headers) nil) (if (boundp lang-headers) (eval lang-headers) nil)
(org-babel-params-from-properties lang) (append (org-babel-params-from-properties lang)
raw-params)))) (list raw-params))))))
(setf hash (org-babel-sha1-hash info))) (setf hash (org-babel-sha1-hash info)))
(org-babel-exp-do-export info 'block hash))))) (org-babel-exp-do-export info 'block hash)))))
@ -206,16 +206,19 @@ this template."
(results (results
(org-babel-exp-do-export (org-babel-exp-do-export
(list "emacs-lisp" "results" (list "emacs-lisp" "results"
(org-babel-merge-params (apply #'org-babel-merge-params
org-babel-default-header-args org-babel-default-header-args
org-babel-default-lob-header-args org-babel-default-lob-header-args
(org-babel-params-from-properties) (append
(org-babel-parse-header-arguments (org-babel-params-from-properties)
(org-no-properties (list
(concat ":var results=" (org-babel-parse-header-arguments
(mapconcat 'identity (org-no-properties
(butlast lob-info) (concat
" "))))) ":var results="
(mapconcat 'identity
(butlast lob-info)
" ")))))))
"" nil (car (last lob-info))) "" nil (car (last lob-info)))
'lob)) 'lob))
(rep (org-fill-template (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) (defun org-babel-lob-execute (info)
"Execute the lob call specified by INFO." "Execute the lob call specified by INFO."
(let* ((mkinfo (lambda (p) (list "emacs-lisp" "results" p nil nil (nth 2 info)))) (let* ((mkinfo (lambda (p) (list "emacs-lisp" "results" p nil nil (nth 2 info))))
(pre-params (org-babel-merge-params (pre-params (apply #'org-babel-merge-params
org-babel-default-header-args org-babel-default-header-args
org-babel-default-header-args:emacs-lisp org-babel-default-header-args:emacs-lisp
(org-babel-params-from-properties) (append
(org-babel-parse-header-arguments (org-babel-params-from-properties)
(org-no-properties (list
(concat ":var results=" (org-babel-parse-header-arguments
(mapconcat #'identity (butlast info) " ")))))) (org-no-properties
(concat
":var results="
(mapconcat #'identity (butlast info)
" "))))))))
(pre-info (funcall mkinfo pre-params)) (pre-info (funcall mkinfo pre-params))
(cache-p (and (cdr (assoc :cache pre-params)) (cache-p (and (cdr (assoc :cache pre-params))
(string= "yes" (cdr (assoc :cache pre-params))))) (string= "yes" (cdr (assoc :cache pre-params)))))