ob-ref: Properly resolve references in ":post" arguments
commitdf10309489a6f6e1a001866be42480ba8cf9f5af
authorNicolas Goaziou <n.goaziou@gmail.com>
Fri, 14 Mar 2014 14:27:32 +0000 (14 15:27 +0100)
committerNicolas Goaziou <n.goaziou@gmail.com>
Wed, 19 Mar 2014 20:34:56 +0000 (19 21:34 +0100)
treed5112e6d295941c3b566446172325b225e667bc1
parent7527e3a80c157d59cf456153810dc20d16642317
ob-ref: Properly resolve references in ":post" arguments

* lisp/ob-core.el (org-babel-exp-reference-buffer): New variable, as
  a replacement for `org-current-export-file'.
(org-babel-check-confirm-evaluate): Use new variable.
* lisp/ob-exp.el (org-babel-exp-in-export-file): Use new variable.
(org-babel-exp-get-export-buffer): Remove function.
(org-babel-exp-process-buffer): Change signature.
* lisp/ob-ref.el (org-babel-ref-resolve): Use new variable during
  export in order to properly resolve references.
* lisp/ox.el (org-export-execute-babel-code): Use new variable.

* contrib/lisp/org-wikinodes.el (org-wikinodes-process-links-for-export):
  Remove a cond branch as it is always
  false (`org-current-export-file' couldn't be a string).

* testing/lisp/test-ob-lob.el (test-ob-lob/export-lob-lines): Update
  test.
* testing/lisp/test-ob.el (test-ob/eval-header-argument): Update test.
* testing/lisp/test-ob-exp.el (ob-export/reference-in-post-header):
  New test.

During export, Babel executes sequentially all blocks in the buffer
being exported.  This can lead to modifications preventing some
references from being resolved.  As a workaround, Babel stores
a pristine copy of the buffer in a variable so it can always find
needed references.

Before this patch, the variable storing this copy was
`org-current-export-file' and was dynamically bound in "ox.el".  It
was used to resolve noweb references (`org-babel-expand-noweb-references')
but not regular references (`org-babel-ref-resolve').

Now, the variable is `org-babel-exp-reference-buffer' and it is bound
from `org-babel-exp-process-buffer'.  It is used to resolve all
references.  In particular, this allows to use references in :post
header.

Thanks to Jarmo Hurri for reporting it.
contrib/lisp/org-wikinodes.el
lisp/ob-core.el
lisp/ob-exp.el
lisp/ob-ref.el
lisp/ox.el
testing/lisp/test-ob-exp.el
testing/lisp/test-ob-lob.el
testing/lisp/test-ob.el