From 178d8c7100176561a395d545c193ea36225ab81c Mon Sep 17 00:00:00 2001 From: Michael Brand
Date: Wed, 22 May 2013 18:59:24 +0200 Subject: [PATCH] Entry properties as code block arguments in Babel * doc/org.texi (var): Document loc ("Location Of Call"). * lisp/ob-ref.el (org-babel-ref-resolve): Add `loc' which is set to point as a marker object. * testing/examples/babel.org: Add test entry for ERT. * testing/lisp/test-ob-exp.el: Add expected code block results for ERT. --- doc/org.texi | 9 +++++++++ lisp/ob-ref.el | 4 +++- testing/examples/babel.org | 30 ++++++++++++++++++++++++++++++ testing/lisp/test-ob-exp.el | 8 ++++++++ 4 files changed, 50 insertions(+), 1 deletions(-) diff --git a/doc/org.texi b/doc/org.texi index 290c671..29362cd 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -14381,6 +14381,15 @@ evaluation of the code block body. #+END_SRC @end example +Within Emacs Lisp evaluation the Lisp variable @code{loc} provides the +``Location Of Call'' as a marker object which can be passed for example to +the Lisp function @code{org-entry-get} to read a property from that entry +where the code block has been called: + address@hidden +#+HEADERS: :var todo_state=(org-entry-get loc "TODO" t) address@hidden example + Note that values read from tables and lists will not be evaluated as Emacs Lisp, as shown in the following example. diff --git a/lisp/ob-ref.el b/lisp/ob-ref.el index a2814ea..9645b9e 100644 --- a/lisp/ob-ref.el +++ b/lisp/ob-ref.el @@ -124,7 +124,9 @@ the variable." (save-excursion (let ((case-fold-search t) type args new-refere new-header-args new-referent result - lob-info split-file split-ref index index-row index-col id) + lob-info split-file split-ref index index-row index-col id + ;; For Emacs Lisp evaluation of :var, see Org manual. + (loc (point-marker))) ;; if ref is indexed grab the indices -- beware nested indices (when (and (string-match "\\[\\([^\\[]+\\)\\]$" ref) (let ((str (substring ref 0 (match-beginning 0)))) diff --git a/testing/examples/babel.org b/testing/examples/babel.org index 7c30ab2..8b18c3f 100644 --- a/testing/examples/babel.org +++ b/testing/examples/babel.org @@ -359,3 +359,33 @@ Here is a call line with more than just the results exported. <