From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thorsten Jolitz Subject: Re: Treat node or subtree as source block? Date: Sat, 05 Mar 2016 19:22:18 +0100 Message-ID: <87egbo4wf9.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47235) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1acGqT-0006RT-7k for emacs-orgmode@gnu.org; Sat, 05 Mar 2016 13:22:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1acGqQ-0005nE-0A for emacs-orgmode@gnu.org; Sat, 05 Mar 2016 13:22:29 -0500 Received: from plane.gmane.org ([80.91.229.3]:56038) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1acGqP-0005n8-Pe for emacs-orgmode@gnu.org; Sat, 05 Mar 2016 13:22:25 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1acGqO-0003Ss-K7 for emacs-orgmode@gnu.org; Sat, 05 Mar 2016 19:22:24 +0100 Received: from f050195076.adsl.alicedsl.de ([78.50.195.76]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 05 Mar 2016 19:22:24 +0100 Received: from tjolitz by f050195076.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 05 Mar 2016 19:22:24 +0100 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org "Paul M." writes: Hi, > I'm interested in treating an entire node or subtree as a source block > for the purposes of tangling. > > Is there some way to specify that, say with properties, without having > to explicitly surround text to be tangled with > "#+BEGIN_SRC...#+END_SRC" ? It depends what you want. Tangling actually is for removing the Org text from Org-mode files, just leaving the content of source blocks, so your whole idea is a bit against the flow. If you want to conserve the whole node you probably need to wrap it in #+BEGIN_SRC org ... #+END_SRC. If you want to transform it to a source block you could use org-dp.el: #+BEGIN_SRC elisp (defun tj/node-to-src-block () "Transform node to src block." (interactive) (org-dp-rewire 'src-block t 'append nil nil :language '(lambda (old elem) (car (org-element-property :tags elem))) :parameters '(lambda (old elem) (format ":exports %s" (cadr (org-element-property :tags elem)))) :value '(lambda (old elem) (org-dp-contents 'elem t t)))) #+END_SRC #+results: : tj/node-to-src-block Calling this function with point on the following headline appends the (working) src-block that results from transforming the headline: * Hello World :elisp:results: (print "Hello World") #+BEGIN_SRC elisp :exports results (print "Hello World") #+END_SRC -- cheers, Thorsten