The following image shows where the talk is in the schedule for Sun 2026-12-13. Solid lines show talks with Q&A via BigBlueButton. Dashed lines show talks with Q&A via IRC or Etherpad.
You can watch this talk now, ahead of the conference. It will also play on the stream at the scheduled time, but this way, you can start checking out the ideas and then come to the Q&A time with more questions. Q&A will be right after the talk's time on the schedule. This talk's Q&A will start at around 2026-12-13 3:01 PM UTC-0500. It will be on the stream until the next talk starts, but people can continue asking questions and discussing ideas even after the stream moves on to the next talk. Enjoy!
00:00.480 Introduction
00:37.540 What happens when we want to use Org babel with a language that's not supported by default?
01:10.280 Version information
01:29.420 The technique
02:34.780 Budget ob-LANG
03:27.330 Library of Babel
04:42.120 Examples
07:27.560 Serial
09:12.880 Parallel map
09:26.700 Tagle map
10:26.040 Conclusion
Org Babel provides a wonderful literate programming experience that works across dozens of languages, but it requires an Elisp library to teach Org how to "speak" different languages.
Thanks to Org's Library of Babel, the same functionality can be achieved for an arbitrary "runnable" in less than 20 lines of shell script and Elisp!
I'm a physics undergraduate at UIUC and I primarily work with Nix(OS), Zig, and Haskell, all from within Emacs.
I've used Emacs and Org mode to solve CTF challenges, write up my quantum mechanics homework, maintain a blog, and even write a production-worthy runbook or two.
Emacs is also my go-to tool for email, IRC, RSS, music, task management, and even sometimes editing text.
[00:00:00.480]Alright, we have a lot to get through and not awhole lot of time, so I'm just going to prefacethe talk by saying all the materials I use willbe available on the talk page at emacsconf.org.I also encourage you to stop and pause the talkso you can try the demos at home, and of courseyou can ask questions after the talk.Alright, let's get into it!Alright, so Org babel is a very powerful system forliterate programming.There is extensive language support,we can make our code more flexible through theusage of header arguments and variables,we can use noweb syntax to dovetail functions,even those written in different languages,and we can also use TRAMP to execute sourceblocks on remote machines.
[00:00:37.540]What happens when we want to use Org babel with a language that's not supported by default?
[00:00:37.540]What happens when we want to use Org babel with alanguage that's not supported by default?Hmm, no org-babel-execute function for Zig.Well, we could write our own ob-zig.el, but thatwould bring our .emacs.d 100 lines closer to"Emacs bankruptcy",and it would also add a dependency to thisOrg mode document: if you don't have ob-zig,you can't execute the source block.So, in today's talk, I'm going to show you how todefine an arbitrary "runnable"that not only allows you to recover thefunctionality of org-babel-execute-src-block,but do so much more by having an arbitraryfunction on some source code—that could be compiling and running, but it couldalso be other stuff.
[00:01:10.280]So, before we get into things, I do just want toclarify that I'm using a pretty tricked outpersonal build of Emacs and also tecosaur's fork ofOrg mode.But everything I talk about in today's talk youcan use in a version of Emacs from probably thepast 5 years or so.So not to worry, you can run everything at home.(You will need some external packages like, for example, Zig.)
[00:01:29.420]Ok, so here's the technique: it's literally justone line of ELisp.I like to call this "block-code".So, what's going on here?org-babel-expand-noweb-references, andthen org-babel-lob--src-info...all this is doing is taking the name of anOrg babel block, and it's returning the content ofthe source code of that block.We will use this using Org's CALL keyword:we have some runnable code block, we use"block-code", and then we pass in the nameof the code block we want to execute.That's all a little bit abstract, so I think it'seasier to show than tell.Here I have some ELisp test block, just countsthe number of lines in my narrowed buffer.Obviously I can press C-c C-c like I just did,but for the sake of demonstration, let's usea runnable.So here I have "eval", that just evaluates a stringas an S-expression, and here I have "eval","block-code", "elisp-test".So I put my point over this line, I press C-c C-c,and as you can see I get the same thing.So that might be a little underwhelming, we justaccomplished the same thing as ob-elisp.elbut with extra steps.But in the coming examples I'm going to show, I thinkyou will find that "block-code" is smallbut mighty.
[00:02:34.780]Ok, so let's return to the example of Zig fromthe beginning.As a reminder, we cannot useorg-babel-execute-src-block on this.Down here I define a runnable which is only4 lines of code(in fairness, Zig is pulling a lot of weight for us here),and I'm defining this in Bash.You can use things other than Bash and ELisp,anything supported by Org babel by default, but Iwould encourage you to use ELisp or Bashbecause it's the most portable.So we call this down here, and...here we go, we get "Hello, world!"One thing I want to mention is that we'reactually redirecting stderr to stdout, and that'snot a generally desirable thing to do, that mightactually be kind of annoying to do with anormal Org babel flow,but because this is an ad-hoc runnable—it doesn't need to be the most general, it justneeds to fit our use case—we can just add this in.Again, that's kind of a recurring theme for thistalk, molding Org babel to fit your use case,even if it's not the most general thing in the world.
[00:03:27.330]Alright, so the next thing I want to talk aboutis Library of Babel, and to do that I have somecode blocks, these are actually from the Orgdocument I use for job applications/cover lettersand stuff like that,and this is a little more involved than"block-code", but it's doing the same thing in spirit—you can see right here I've got the same thing in spirit.But I'm doing some additional introspection usingELisp to pass variables to this inner code block,and what I want to show here is—let me tangle this real quick—I have some file example.org,which has a block named "lorem-letter", and herein my other file, org_babel_everywhere.org, I canactually use "lorem-letter", I can reference itby prepending the file name to it,"lorem-letter:example.org".So I press C-c C-c here... and I open this up, andwe have some lorem ipsum stuff in the file.So this is a pretty cool technique, that I canuse Org babel's Library of Babel functionality.I will say, there is a feature where you can addOrg files to your personal "Library of Babel"and then reference them without prepending the filename.I'm personally not such a big fan of this becauseit makes it harder for someone else to run thesame Org document on their machine.But maybe it could be useful if you have somecompany-wide Emacs config, that everyone has thesame setup everywhere.
[00:04:42.120]We'll get onto the examples.I just want to emphasize that all of these examplesare real use cases I've actually used,and none of them are contrived.The first one is micro VMs, this is an excerptfrom a kernel pwn writeup I made about a year ago.(I'm just switching the version of Zig that's in my $PATH.)So, this is some kernel exploit(the code is not important, just the context is),it's a vulnerable x86 Linux kernel module.So I'm going to call this runnable"pawny-run-exploit".Ok, we have uid=1337, some stuff,then we get root, that's generally a goodsign for kernel pwn.Just to prove there's no movie magic, let's add acompile error here.Ok, so we get the error in our Org-Babel Error Outputbuffer, just as we'd expect.And also, we can also add"kernel base are belong to us".Run this again—sorry, still have "foobar" here—and we will see output reflected here.So what's actually happening?For the sake of time, I'm going to give a veryhigh level play-by-play.So "pawny-compile-exploit", it's cross-compilingour block of code to x86_64-linux(I'm currently on aarch64-darwin),then "pawny-run-command":ok, so this is going to regenerate an initramfs,it's going to include the exploit we just compiled,it also, based on some Org babel variable,it will change the init shell to be runas root or an unprivileged user, which is reallyuseful for debugging a kernel exploit.Then we're going to run a QEMU micro VM over here,and we're actually communicating bidirectionally withthe shell in the VM and the Bash process runningthis Org babel code block with the power ofUnix sockets and socat.And then we're sending some $shellcmd.And then down here, this is an ELisp block I'm using toclean up the output using Org babel's:post header argument.That's just to get rid of ANSI control codes andboot logs and stuff like that.So, this is a pretty nice workflow!I actually used this to solve this challenge, andwe also get all the trimmings of Org mode:I can use noweb syntax, I can reverse tangle and then Ican use LSP in a proper zig-mode buffer,I can also use Org export and I can export this codeand the results to a PDF or a website.I used ox-hugo to export this exact writeupto my website.Overall, just a really cool technique.And again, to remind you: I can send this Orgdocument to you, and you can run the exact samething on base Emacs(with no extra ELisp packages).You will obviously need QEMU and Zig to run thisstuff, but yeah, that's pretty cool.For the next example, I thought if I can talk toa VM over socat, why not do the same thing usingthe rich functionality of Emacs core?
[00:07:27.560]So I made this little interactive serial REPL,which again, doesn't require any external functionality,it's all in ELisp—30-odd lines of ELisp—which is pretty impressive for something like this.I actually have a board on my desk, I'm doingbring-up on this RISC-V board.So I'm going to CALL this runnable, and it willwait until it hits a U-Boot prompt...Let me turn on the board...and there we go, wehave in our buffer "Pretty cool, huh?".I also added a featureto give me an interactive terminal—it will open the serial device in a term-mode bufferSo, that's pretty neat.(I'll turn this off so the fan doesn't annoy me.)Again, I just want to emphasize, this doesn'thave to be the most general runnable of all time,it really just has to fit my use case.I actually did use this to bring up this RISC-Vboard, it was really useful becausewhen you're debugging a kernel panic, you don't have auserspace and therefore no TRAMP.Ok, the last example I want to talk about isabout higher order functions.If we're passing around code blocks as values,naturally you might think of something like mapas a higher order function.The details I'm going to gloss over because we'reshort on time, but down here I have this "map".I'm mapping the above code block over my 3most recent TRAMP machines.So it's going to open this stuff...it's taking a little bit to think...I will emphasize, the things you pass in, it'sjust a list-of-lists where each child list is thelist of header arguments you pass to thesource block.So here I'm mapping over :dir, but you could just aseasily map over :results, :var, whatever.And then I have some :post header argument tomake the table look nice.
[00:09:12.880]I want to briefly talk about "parallel map",a little experiment I did to try and use Emacs'smultithreading feature to speed up map.Unfortunately, it only works with ELisp,it doesn't work with any external processes.Probably not too useful, but maybe someone outthere will find it interesting.
[00:09:26.700]The last thing I want to talk about is "tangle map".This is essentially mapping a cat runnable over afile, but you can use this in conjunction with"map" to get a kind of devops workflow.(I have to type in my auth-source password for my password-store password.)I'm tangling this to /var/run, so that requires root,which is why I need to add my password.Just to prove that's actually there...So yeah, that's another pretty interestingthing you can do.And then if we're talking about map, of course we have fold.I guess I did not load ob-python, but that's nottoo important.But fold works the same way as map, pretty much.Maybe you could fold a code block multiple timesto take some benchmarking statistics.
[00:10:26.040]So that brings me to the end of my talk.If you take away one thing, I just want toemphasize that you can use a tiny bit of ELispto augment the already very powerful capabilities ofOrg babel.Whether your document is a research paper, blog post,homework assignment, whatever: I encourageyou to get creative and bend Emacs to your will.Happy hacking!