From: Thorsten Jolitz <tjolitz@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: Treat node or subtree as source block?
Date: Sat, 05 Mar 2016 19:22:18 +0100 [thread overview]
Message-ID: <87egbo4wf9.fsf@gmail.com> (raw)
In-Reply-To: CABoaWcViPN5VOjvetazvUSk0k1rVtTPJxswWveUYXMQdo-6gQA@mail.gmail.com
"Paul M." <pmmagic@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
prev parent reply other threads:[~2016-03-05 18:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-15 18:05 Treat node or subtree as source block? Paul M.
2016-03-05 18:22 ` Thorsten Jolitz [this message]
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=87egbo4wf9.fsf@gmail.com \
--to=tjolitz@gmail.com \
--cc=emacs-orgmode@gnu.org \
/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).