From: Michael Brand <michael.ch.brand@gmail.com>
To: Eric Schulte <schulte.eric@gmail.com>
Cc: Org Mode <emacs-orgmode@gnu.org>
Subject: Re: link abbreviation with multiple params, e. g. for geo locations
Date: Wed, 19 Jun 2013 11:39:57 +0200 [thread overview]
Message-ID: <CALn3zogWfdsaQbYtmuLHsX_rRihgm8wN1htaLkRaefuRO0pMpA@mail.gmail.com> (raw)
In-Reply-To: <CALn3zojO==XDKV-_LW2qH0=1DtWUkhAHZ0HTeLoOkb8n4rwTWw@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 280 bytes --]
Hi Eric
On Fri, Jun 14, 2013 at 10:13 PM, Michael Brand
<michael.ch.brand@gmail.com> wrote:
> Is there a better workaround or would you accept :var dummy_name for
> my ERT that I mentioned?
For the variant of :var dummy_name see my attached patch with the updated ERT.
Michael
[-- Attachment #2: 0001-Babel-use-case-of-reading-entry-properties-as-an-ERT.patch.txt --]
[-- Type: text/plain, Size: 6121 bytes --]
From 576cd364262d33bbf614414085cc918ac7ff548b Mon Sep 17 00:00:00 2001
From: Michael Brand <michael.ch.brand@gmail.com>
Date: Wed, 19 Jun 2013 11:36:36 +0200
Subject: [PATCH] Babel: use case of reading entry properties as an ERT
* testing/examples/babel.org: Add test entry for ERT.
* testing/lisp/test-ob-exp.el(ob-exp/use-case-of-reading-entry-properties):
Add expected source block results for ERT.
---
testing/examples/babel.org | 77 +++++++++++++++++++++++++++++++++++++++++++++
testing/lisp/test-ob-exp.el | 42 +++++++++++++++++++++++++
2 files changed, 119 insertions(+)
diff --git a/testing/examples/babel.org b/testing/examples/babel.org
index 15f9717..de1980e 100644
--- a/testing/examples/babel.org
+++ b/testing/examples/babel.org
@@ -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
diff --git a/testing/lisp/test-ob-exp.el b/testing/lisp/test-ob-exp.el
index abfe230..a930c99 100644
--- a/testing/lisp/test-ob-exp.el
+++ b/testing/lisp/test-ob-exp.el
@@ -216,6 +216,48 @@ Here is one at the end of a line. =2=
(should-not (string-match (regexp-quote "<<strip-export-1>>") result))
(should-not (string-match (regexp-quote "i=\"10\"") result)))))
+(ert-deftest ob-exp/use-case-of-reading-entry-properties ()
+ (org-test-at-id "cc5fbc20-bca5-437a-a7b8-2b4d7a03f820"
+ (org-narrow-to-subtree)
+ (let* ((case-fold-search nil)
+ (result (org-test-with-expanded-babel-code (buffer-string)))
+ (sect "a:1, b:0, c:3, d:0, e:0")
+ (sub0 "a:1, b:2, c:4, d:0, e:0")
+ (sub1 "a:1, b:2, c:5, d:0, e:6")
+ (func sub0))
+ ;; entry "section"
+ (should (string-match (concat "\"sect call\".*)\n: shell " sect "\n")
+ result))
+ (should (string-match (concat "sect call\\](.*)\n: elisp " sect "\n")
+ result))
+ (should (string-match (concat "\n- sect inline =shell " sect "=\n")
+ result))
+ (should (string-match (concat "\n- sect inline =elisp " sect "=\n")
+ result))
+ ;; entry "subsection", call without arguments
+ (should (string-match (concat "\"sub0 call\".*)\n: shell " sub0 "\n")
+ result))
+ (should (string-match (concat "sub0 call\\](.*)\n: elisp " sub0 "\n")
+ result))
+ (should (string-match (concat "\n- sub0 inline =shell " sub0 "=\n")
+ result))
+ (should (string-match (concat "\n- sub0 inline =elisp " sub0 "=\n")
+ result))
+ ;; entry "subsection", call with arguments
+ (should (string-match (concat "\"sub1 call\".*)\n: shell " sub1 "\n")
+ result))
+ (should (string-match (concat "sub1 call\\](.*)\n: elisp " sub1 "\n")
+ result))
+ (should (string-match (concat "\n- sub1 inline =shell " sub1 "=\n")
+ result))
+ (should (string-match (concat "\n- sub1 inline =elisp " sub1 "=\n")
+ result))
+ ;; entry "function definition"
+ (should (string-match (concat "_location_shell\n: shell " func "\n")
+ result))
+ (should (string-match (concat "_location_elisp\n: elisp " func "\n")
+ result)))))
+
(ert-deftest ob-exp/export-from-a-temp-buffer ()
:expected-result :failed
(org-test-with-temp-text
--
1.8.3
next prev parent reply other threads:[~2013-06-19 9:40 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-22 17:03 link abbreviation with multiple params, e. g. for geo locations Michael Brand
2013-05-29 16:14 ` Michael Brand
2013-06-05 17:19 ` Michael Brand
2013-06-06 17:01 ` Eric Schulte
2013-06-07 14:53 ` Michael Brand
2013-06-07 15:18 ` Eric Schulte
2013-06-07 19:16 ` Michael Brand
2013-06-07 19:54 ` Vitalie Spinu
2013-06-08 18:05 ` Eric Schulte
2013-06-08 18:52 ` Vitalie Spinu
2013-06-08 19:21 ` Eric Schulte
2013-06-14 17:54 ` Michael Brand
2013-06-14 18:18 ` Eric Schulte
2013-06-14 20:13 ` Michael Brand
2013-06-19 9:39 ` Michael Brand [this message]
2013-06-07 20:10 ` Achim Gratz
2013-06-08 18:03 ` Eric Schulte
2013-06-09 7:56 ` Michael Brand
2013-06-09 8:07 ` Michael Brand
2013-06-09 19:18 ` Eric Schulte
2013-06-09 20:32 ` Michael Brand
2013-06-11 13:12 ` Eric Schulte
-- strict thread matches above, loose matches on Subject: below --
2013-05-05 15:06 Michael Brand
2013-05-06 7:06 ` Christian Moe
2013-05-06 18:42 ` Michael Brand
2013-05-06 22:29 ` Christian Moe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CALn3zogWfdsaQbYtmuLHsX_rRihgm8wN1htaLkRaefuRO0pMpA@mail.gmail.com \
--to=michael.ch.brand@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=schulte.eric@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).