"Paul M." <pmma...@gmail.com> 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


Reply via email to