From a0d03014ab41e9e2354763ea3ab05f60fa0c54ea Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Sat, 31 Oct 2009 12:20:41 -0400 Subject: [PATCH] org-babel: internal change: defer breaking up of info list in org-babel-exp.el --- contrib/babel/lisp/org-babel-exp.el | 50 ++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/contrib/babel/lisp/org-babel-exp.el b/contrib/babel/lisp/org-babel-exp.el index e4a30fa6..7c5eecdd 100644 --- a/contrib/babel/lisp/org-babel-exp.el +++ b/contrib/babel/lisp/org-babel-exp.el @@ -59,7 +59,7 @@ none ----- do not display either code or results upon export" (org-babel-params-from-properties) (org-babel-parse-header-arguments (mapconcat #'identity (cdr headers) " "))))) - (org-babel-exp-do-export lang body params 'block))) + (org-babel-exp-do-export (list lang body params) 'block))) (defun org-babel-exp-inline-src-blocks (start end) "Process inline src blocks between START and END for export. @@ -72,8 +72,7 @@ options and are taken from `org-babel-defualt-inline-header-args'." (re-search-forward org-babel-inline-src-block-regexp end t)) (let* ((info (save-match-data (org-babel-parse-inline-src-block-match))) (replacement (save-match-data - (org-babel-exp-do-export - (first info) (second info) (third info) 'inline)))) + (org-babel-exp-do-export info 'inline)))) (setq end (+ end (- (length replacement) (length (match-string 1))))) (replace-match replacement t t nil 1))))) @@ -90,38 +89,42 @@ options are taken from `org-babel-default-header-args'." (setq replacement (save-match-data (org-babel-exp-do-export - "emacs-lisp" "results" - (org-babel-merge-params - org-babel-default-header-args - (org-babel-parse-header-arguments - (org-babel-clean-text-properties - (concat ":var results=" - (mapconcat #'identity (org-babel-lob-get-info) " "))))) + (list "emacs-lisp" "results" + (org-babel-merge-params + org-babel-default-header-args + (org-babel-parse-header-arguments + (org-babel-clean-text-properties + (concat ":var results=" + (mapconcat #'identity (org-babel-lob-get-info) " ")))))) 'lob))) (setq end (+ end (- (length replacement) (length (match-string 0))))) (replace-match replacement t t))))) -(defun org-babel-exp-do-export (lang body params type) - (case (intern (or (cdr (assoc :exports params)) "code")) +(defun org-babel-exp-do-export (info type) + (case (intern (or (cdr (assoc :exports (third info))) "code")) ('none "") - ('code (org-babel-exp-code lang body params type)) - ('results (org-babel-exp-results lang body params type)) - ('both (concat (org-babel-exp-code lang body params type) + ('code (org-babel-exp-code info type)) + ('results (org-babel-exp-results info type)) + ('both (concat (org-babel-exp-code info type) "\n\n" - (org-babel-exp-results lang body params type))))) + (org-babel-exp-results info type))))) -(defun org-babel-exp-code (lang body params type) +(defun org-babel-exp-code (info type) + (let ((lang (first info)) + (body (second info))) (case type - ('inline (format "=%s=" body)) + ('inline (format "=%s=" (second info))) ('block (format "#+BEGIN_SRC %s\n%s%s\n#+END_SRC" lang body (if (string-match "\n$" body) "" "\n"))) ('lob (save-excursion (re-search-backward org-babel-lob-one-liner-regexp) (format "#+BEGIN_SRC org-babel-lob\n%s\n#+END_SRC" - (first (org-babel-lob-get-info))))))) + (first (org-babel-lob-get-info)))))))) -(defun org-babel-exp-results (lang body params type) - (let ((params +(defun org-babel-exp-results (info type) + (let ((lang (first info)) + (body (second info)) + (params ;; lets ensure that we lookup references in the original file (mapcar (lambda (pair) (if (and org-current-export-file @@ -130,11 +133,12 @@ options are taken from `org-babel-default-header-args'." `(:var . ,(concat (match-string 1 (cdr pair)) "=" org-current-export-file ":" (match-string 2 (cdr pair)))) - pair)) params))) + pair)) + (third info)))) (case type ('inline (let ((raw (org-babel-execute-src-block - nil (list lang body params) '((:results . "silent")))) + nil info '((:results . "silent")))) (result-params (split-string (cdr (assoc :results params))))) (cond ;; respect the value of the :results header argument ((member "file" result-params) -- 2.11.4.GIT