Making The Results Block Executable

Over at the Emacs Stack Exchange, shackra asks how he can make the RESULTS block of an Org babel SRC block executable by the shell. In other words, he wants to build a shell script in one block and be able to execute the resulting shell script in another.

That turns out to be really easy and Xu Chunyang provides a very nice answer: simply use the :wrap keyword in the first block to wrap the RESULTS block in a new Org src code block. Follow the above link to see the exact details. As I say, it’s easy and can be very convenient. Needless to say, you can make the results executable by any of the supported languages, not just shell.

When I read the Stack Exchange query, I remembered that I once knew about :wrap but had completely forgotten about it. Then I thought that I vaguely remembered writing about it but I couldn’t find any mention of it in my archives so perhaps I’m imagining the whole thing. In any event, if you’re a Babel user, it’s worth knowing about the :wrap keyword. If you like the idea of programs writing programs, here’s a great technique for doing so from within Org-mode. Very nice indeed.

This entry was posted in General and tagged , . Bookmark the permalink.