|
@@ -359,3 +359,80 @@ Here is a call line with more than just the results exported.
|
|
|
<<strip-export-1>>
|
|
|
echo "1$i"
|
|
|
#+END_SRC
|
|
|
+
|
|
|
+* use case of reading entry properties
|
|
|
+ :PROPERTIES:
|
|
|
+ :ID: cc5fbc20-bca5-437a-a7b8-2b4d7a03f820
|
|
|
+ :END:
|
|
|
+
|
|
|
+If overriden by caller then use :var from header else use entry property.
|
|
|
+
|
|
|
+** section
|
|
|
+ :PROPERTIES:
|
|
|
+ :a: 1
|
|
|
+ :c: 3
|
|
|
+ :END:
|
|
|
+
|
|
|
+Note: Just export of a property can be done with a macro: {{{property(a)}}}.
|
|
|
+
|
|
|
+#+CALL: src_block_location_shell(dummy_name="sect call")
|
|
|
+#+CALL: src_block_location_elisp[:session sect call]()
|
|
|
+- sect inline call_src_block_location_shell(dummy_name="sect inline")
|
|
|
+- sect inline call_src_block_location_elisp[:session sect inline]()
|
|
|
+
|
|
|
+*** subsection
|
|
|
+ :PROPERTIES:
|
|
|
+ :b: 2
|
|
|
+ :c: 4
|
|
|
+ :END:
|
|
|
+
|
|
|
+#+CALL: src_block_location_shell(dummy_name="sub0 call")
|
|
|
+#+CALL: src_block_location_elisp[:session sub0 call]()
|
|
|
+- sub0 inline call_src_block_location_shell(dummy_name="sub0 inline")
|
|
|
+- sub0 inline call_src_block_location_elisp[:session sub0 inline]()
|
|
|
+
|
|
|
+#+CALL: src_block_location_shell(dummy_name="sub1 call", c=5, e=6)
|
|
|
+#+CALL: src_block_location_elisp[:session sub1 call](c=5, e=6)
|
|
|
+- sub1 inline call_src_block_location_shell(dummy_name="sub1 inline", c=5, e=6)
|
|
|
+- sub1 inline call_src_block_location_elisp[:session sub1 inline](c=5, e=6)
|
|
|
+
|
|
|
+**** function definition
|
|
|
+
|
|
|
+#+NAME: src_block_location_shell
|
|
|
+#+HEADER: :var dummy_name="workaround to get different result blocks"
|
|
|
+#+HEADER: :var a=(or (org-entry-get org-babel-current-src-block-location "a" t) "0")
|
|
|
+#+HEADER: :var b=(or (org-entry-get org-babel-current-src-block-location "b" t) "0")
|
|
|
+#+HEADER: :var c=(or (org-entry-get org-babel-current-src-block-location "c" t) "0")
|
|
|
+#+HEADER: :var d=(or (org-entry-get org-babel-current-src-block-location "d" t) "0")
|
|
|
+#+HEADER: :var e=(or (org-entry-get org-babel-current-src-block-location "e" t) "0")
|
|
|
+#+BEGIN_SRC sh :shebang #!/bin/sh :exports results :results verbatim
|
|
|
+ printf "shell a:$a, b:$b, c:$c, d:$d, e:$e"
|
|
|
+#+END_SRC
|
|
|
+
|
|
|
+#+RESULTS: src_block_location_shell
|
|
|
+
|
|
|
+#+NAME: src_block_location_elisp
|
|
|
+#+HEADER: :var a='nil
|
|
|
+#+HEADER: :var b='nil
|
|
|
+#+HEADER: :var c='nil
|
|
|
+#+HEADER: :var d='nil
|
|
|
+#+HEADER: :var e='nil
|
|
|
+#+BEGIN_SRC emacs-lisp :exports results
|
|
|
+ (setq
|
|
|
+ a (or a (string-to-number
|
|
|
+ (or (org-entry-get org-babel-current-src-block-location "a" t)
|
|
|
+ "0")))
|
|
|
+ b (or b (string-to-number
|
|
|
+ (or (org-entry-get org-babel-current-src-block-location "b" t)
|
|
|
+ "0")))
|
|
|
+ c (or c (string-to-number
|
|
|
+ (or (org-entry-get org-babel-current-src-block-location "c" t)
|
|
|
+ "0")))
|
|
|
+ d (or d (string-to-number
|
|
|
+ (or (org-entry-get org-babel-current-src-block-location "e" t)
|
|
|
+ "0")))
|
|
|
+ e (or e (string-to-number
|
|
|
+ (or (org-entry-get org-babel-current-src-block-location "d" t)
|
|
|
+ "0"))))
|
|
|
+ (format "elisp a:%d, b:%d, c:%d, d:%d, e:%d" a b c d e)
|
|
|
+#+END_SRC
|