diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2018-06-23 23:04:45 +0200 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2018-06-23 23:04:45 +0200 |
commit | 8e54cafeb286ea5eb25565a637b121a2f597c48b (patch) | |
tree | 60229850eef46e307abe0e69ef7e426bda8e08ca | |
parent | 1bdee35231e26cc5f0c5979523ad81350030f91e (diff) | |
download | org-mode-8e54cafeb286ea5eb25565a637b121a2f597c48b.tar.gz |
Fix noweb expansion during export
* lisp/ob-core.el (org-babel-sha1-hash): Add optional argument to
specify context.
(org-babel-execute-src-block): Use new argument.
* lisp/ob-exp.el (org-babel-exp-src-block): Use new argument.
(org-babel-exp-results): Fix context.
Reported-by: Ken Mankoff <mankoff@gmail.com>
<http://lists.gnu.org/r/emacs-orgmode/2018-06/msg00117.html>
-rw-r--r-- | lisp/ob-core.el | 16 | ||||
-rw-r--r-- | lisp/ob-exp.el | 4 |
2 files changed, 12 insertions, 8 deletions
diff --git a/lisp/ob-core.el b/lisp/ob-core.el index 4c82140..3b4a883 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -645,7 +645,7 @@ block." (let* ((params (nth 2 info)) (cache (let ((c (cdr (assq :cache params)))) (and (not arg) c (string= "yes" c)))) - (new-hash (and cache (org-babel-sha1-hash info))) + (new-hash (and cache (org-babel-sha1-hash info :eval))) (old-hash (and cache (org-babel-current-result-hash))) (current-cache (and new-hash (equal new-hash old-hash)))) (cond @@ -1221,11 +1221,14 @@ the current subtree." (widen)))) ;;;###autoload -(defun org-babel-sha1-hash (&optional info) - "Generate an sha1 hash based on the value of info." +(defun org-babel-sha1-hash (&optional info context) + "Generate a sha1 hash based on the value of INFO. +CONTEXT specifies the context of evaluation. It can be `:eval', +`:export', `:tangle'. A nil value means `:eval'." (interactive) (let ((print-level nil) - (info (or info (org-babel-get-src-block-info)))) + (info (or info (org-babel-get-src-block-info))) + (context (or context :eval))) (setf (nth 2 info) (sort (copy-sequence (nth 2 info)) (lambda (a b) (string< (car a) (car b))))) @@ -1253,8 +1256,9 @@ the current subtree." ;; expanded body (lang (nth 0 info)) (params (nth 2 info)) - (body (if (org-babel-noweb-p params :eval) - (org-babel-expand-noweb-references info) (nth 1 info))) + (body (if (org-babel-noweb-p params context) + (org-babel-expand-noweb-references info) + (nth 1 info))) (expand-cmd (intern (concat "org-babel-expand-body:" lang))) (assignments-cmd (intern (concat "org-babel-variable-assignments:" lang))) diff --git a/lisp/ob-exp.el b/lisp/ob-exp.el index 0b7a1da..9ab93ec 100644 --- a/lisp/ob-exp.el +++ b/lisp/ob-exp.el @@ -107,7 +107,7 @@ Assume point is at block opening line." (symbol-value lang-headers)) (append (org-babel-params-from-properties lang) (list raw-params))))))) - (setf hash (org-babel-sha1-hash info))) + (setf hash (org-babel-sha1-hash info :export))) (org-babel-exp-do-export info 'block hash))))) (defcustom org-babel-exp-call-line-template @@ -376,7 +376,7 @@ block will be evaluated. Optional argument SILENT can be used to inhibit insertion of results into the buffer." (unless (and hash (equal hash (org-babel-current-result-hash))) (let ((lang (nth 0 info)) - (body (if (org-babel-noweb-p (nth 2 info) :eval) + (body (if (org-babel-noweb-p (nth 2 info) :export) (org-babel-expand-noweb-references info org-babel-exp-reference-buffer) (nth 1 info))) |