Back to the talks Previous by time: A (sort of) REPL for learning SVG Next by time: Column-aligning text in Emacs Track: Development - Watch

Org Babel everywhere

George Huebner (he/him) - IRC: Shorden, https://feyor.sh, george@feyor.sh

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.

Format: 11-min talk ; Q&A: BigBlueButton conference room https://media.emacsconf.org/2026/current/bbb-babel.html
Etherpad: https://pad.emacsconf.org/2026-babel
Discuss on IRC: #emacsconf
Status: Ready to stream

Times in different time zones:
Sunday, Dec 13 2026, ~2:50 PM - 3:05 PM EST (US/Eastern)
which is the same as:
Sunday, Dec 13 2026, ~1:50 PM - 2:05 PM CST (US/Central)
Sunday, Dec 13 2026, ~12:50 PM - 1:05 PM MST (US/Mountain)
Sunday, Dec 13 2026, ~11:50 AM - 12:05 PM PST (US/Pacific)
Sunday, Dec 13 2026, ~7:50 PM - 8:05 PM UTC
Sunday, Dec 13 2026, ~8:50 PM - 9:05 PM CET (Europe/Paris)
Sunday, Dec 13 2026, ~9:50 PM - 10:05 PM EET (Europe/Athens)
Monday, Dec 14 2026, ~1:20 AM - 1:35 AM IST (Asia/Kolkata)
Monday, Dec 14 2026, ~3:50 AM - 4:05 AM +08 (Asia/Singapore)
Monday, Dec 14 2026, ~4:50 AM - 5:05 AM JST (Asia/Tokyo)
Find out how to watch and participate
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

Duration: 10:43 minutes

Description

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.

Transcript

[00:00:00.480] Introduction
[00:00:00.480] Alright, we have a lot to get through and not a whole lot of time, so I'm just going to preface the talk by saying all the materials I use will be available on the talk page at emacsconf.org. I also encourage you to stop and pause the talk so you can try the demos at home, and of course you can ask questions after the talk. Alright, let's get into it! Alright, so Org babel is a very powerful system for literate programming. There is extensive language support, we can make our code more flexible through the usage 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 source blocks 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 a language that's not supported by default? Hmm, no org-babel-execute function for Zig. Well, we could write our own ob-zig.el, but that would bring our .emacs.d 100 lines closer to "Emacs bankruptcy", and it would also add a dependency to this Org 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 to define an arbitrary "runnable" that not only allows you to recover the functionality of org-babel-execute-src-block, but do so much more by having an arbitrary function on some source code— that could be compiling and running, but it could also be other stuff.
[00:01:10.280] Version information
[00:01:10.280] So, before we get into things, I do just want to clarify that I'm using a pretty tricked out personal build of Emacs and also tecosaur's fork of Org mode. But everything I talk about in today's talk you can use in a version of Emacs from probably the past 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] The technique
[00:01:29.420] Ok, so here's the technique: it's literally just one line of ELisp. I like to call this "block-code". So, what's going on here? org-babel-expand-noweb-references, and then org-babel-lob--src-info... all this is doing is taking the name of an Org babel block, and it's returning the content of the 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 name of the code block we want to execute. That's all a little bit abstract, so I think it's easier to show than tell. Here I have some ELisp test block, just counts the 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 use a runnable. So here I have "eval", that just evaluates a string as 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 just accomplished the same thing as ob-elisp.el but with extra steps. But in the coming examples I'm going to show, I think you will find that "block-code" is small but mighty.
[00:02:34.780] Budget ob-LANG
[00:02:34.780] Ok, so let's return to the example of Zig from the beginning. As a reminder, we cannot use org-babel-execute-src-block on this. Down here I define a runnable which is only 4 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 I would encourage you to use ELisp or Bash because 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're actually redirecting stderr to stdout, and that's not a generally desirable thing to do, that might actually be kind of annoying to do with a normal Org babel flow, but because this is an ad-hoc runnable— it doesn't need to be the most general, it just needs to fit our use case— we can just add this in. Again, that's kind of a recurring theme for this talk, molding Org babel to fit your use case, even if it's not the most general thing in the world.
[00:03:27.330] Library of Babel
[00:03:27.330] Alright, so the next thing I want to talk about is Library of Babel, and to do that I have some code blocks, these are actually from the Org document I use for job applications/cover letters and 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 using ELisp 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 here in my other file, org_babel_everywhere.org, I can actually use "lorem-letter", I can reference it by prepending the file name to it, "lorem-letter:example.org". So I press C-c C-c here... and I open this up, and we have some lorem ipsum stuff in the file. So this is a pretty cool technique, that I can use Org babel's Library of Babel functionality. I will say, there is a feature where you can add Org 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 because it makes it harder for someone else to run the same Org document on their machine. But maybe it could be useful if you have some company-wide Emacs config, that everyone has the same setup everywhere.
[00:04:42.120] Examples
[00:04:42.120] We'll get onto the examples. I just want to emphasize that all of these examples are real use cases I've actually used, and none of them are contrived. The first one is micro VMs, this is an excerpt from 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 good sign for kernel pwn. Just to prove there's no movie magic, let's add a compile error here. Ok, so we get the error in our Org-Babel Error Output buffer, 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 very high level play-by-play. So "pawny-compile-exploit", it's cross-compiling our 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 run as root or an unprivileged user, which is really useful for debugging a kernel exploit. Then we're going to run a QEMU micro VM over here, and we're actually communicating bidirectionally with the shell in the VM and the Bash process running this Org babel code block with the power of Unix sockets and socat. And then we're sending some $shellcmd. And then down here, this is an ELisp block I'm using to clean up the output using Org babel's :post header argument. That's just to get rid of ANSI control codes and boot logs and stuff like that. So, this is a pretty nice workflow! I actually used this to solve this challenge, and we also get all the trimmings of Org mode: I can use noweb syntax, I can reverse tangle and then I can use LSP in a proper zig-mode buffer, I can also use Org export and I can export this code and the results to a PDF or a website. I used ox-hugo to export this exact writeup to my website. Overall, just a really cool technique. And again, to remind you: I can send this Org document to you, and you can run the exact same thing on base Emacs (with no extra ELisp packages). You will obviously need QEMU and Zig to run this stuff, but yeah, that's pretty cool. For the next example, I thought if I can talk to a VM over socat, why not do the same thing using the 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 doing bring-up on this RISC-V board. So I'm going to CALL this runnable, and it will wait until it hits a U-Boot prompt... Let me turn on the board... and there we go, we have in our buffer "Pretty cool, huh?". I also added a feature to give me an interactive terminal— it will open the serial device in a term-mode buffer So, that's pretty neat. (I'll turn this off so the fan doesn't annoy me.) Again, I just want to emphasize, this doesn't have 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-V board, it was really useful because when you're debugging a kernel panic, you don't have a userspace and therefore no TRAMP. Ok, the last example I want to talk about is about higher order functions. If we're passing around code blocks as values, naturally you might think of something like map as a higher order function. The details I'm going to gloss over because we're short on time, but down here I have this "map". I'm mapping the above code block over my 3 most 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's just a list-of-lists where each child list is the list of header arguments you pass to the source block. So here I'm mapping over :dir, but you could just as easily map over :results, :var, whatever. And then I have some :post header argument to make the table look nice.
[00:09:12.880] Parallel map
[00:09:12.880] I want to briefly talk about "parallel map", a little experiment I did to try and use Emacs's multithreading 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 out there will find it interesting.
[00:09:26.700] Tagle map
[00:09:26.700] The last thing I want to talk about is "tangle map". This is essentially mapping a cat runnable over a file, 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 interesting thing 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 not too important. But fold works the same way as map, pretty much. Maybe you could fold a code block multiple times to take some benchmarking statistics.
[00:10:26.040] Conclusion
[00:10:26.040] So that brings me to the end of my talk. If you take away one thing, I just want to emphasize that you can use a tiny bit of ELisp to augment the already very powerful capabilities of Org babel. Whether your document is a research paper, blog post, homework assignment, whatever: I encourage you to get creative and bend Emacs to your will. Happy hacking!

Captioner: George Huebner

Questions or comments? Please e-mail george@feyor.sh

Back to the talks Previous by time: A (sort of) REPL for learning SVG Next by time: Column-aligning text in Emacs Track: Development - Watch