From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Charles C. Berry" Subject: Re: Using property values in source code blocks Date: Sat, 16 Jul 2016 09:02:35 -0700 Message-ID: References: , , , , , , , , , , , , , , , , , , , , , , , , , , , , Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35632) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bOS3B-00062S-SJ for emacs-orgmode@gnu.org; Sat, 16 Jul 2016 12:02:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bOS35-0002lW-Rq for emacs-orgmode@gnu.org; Sat, 16 Jul 2016 12:02:44 -0400 Received: from iport-acv2-out.ucsd.edu ([132.239.0.174]:16182) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bOS35-0002lN-FL for emacs-orgmode@gnu.org; Sat, 16 Jul 2016 12:02:39 -0400 In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Joon Ro Cc: "emacs-orgmode@gnu.org" On Fri, 15 Jul 2016, Joon Ro wrote: > > >> >> Example: >> >> --8<---------------cut here---------------start------------->8--- >> >> * Top Heading >> >> #+NAME: get-property >> #+BEGIN_SRC emacs-lisp :noweb yes :var prop="prop" :var pom=0 >> (car (org-entry-get-multivalued-property pom prop)) >> #+END_SRC >> >> ** Subheading >> :PROPERTIES: >> :DUMMY: 100 >> :END: >> >> #+BEGIN_SRC shell :noweb yes >> echo <> >> #+END_SRC >> >> #+RESULTS: >> : 100 >> >> --8<---------------cut here---------------end--------------->8--- >> > > Hi Chuck, > Thank you so much. It definitely works when I evaluate the code block - > but my ultimate goal is to tangle the source code (I want to generate > bunch of script files with a template using property values), and when I > tangle the code block it returns nil. I do not see an easy way to do what you want only with tangle. There are hooks you can define that might enable you to set things up. Maybe you can use `org-babel-pre-tangle-hook' to collect the property values and put them somewhere that `org-babel-post-tangle-hook' can get at them and use them to modify the tangled results accordingly. Or maybe `org-babel-post-tangle-hook' can do it by using methods like those in `org-babel-detangle' to look back at the *.org file. Another alternative is to write all of your code blocks so they will execute to create the code you want as results and then tangle those results. You would use :wrap like this: --8<---------------cut here---------------start------------->8--- #+BEGIN_SRC shell :noweb yes :wrap "src shell :tangle ./tangle-test.sh" echo "echo " <> #+END_SRC --8<---------------cut here---------------end--------------->8--- Execute the src block and then tangle the buffer. In fact, if you go that route it might make more sense to write elisp code blocks to find the prpoerty values and then format the results. Chuck