The joy of presenting in Emacs (User group presentation III)

Considering I understood decorators before starting the presentation, I didn’t do a lot of research in terms of “learning new stuff”. What I mainly needed were code samples and practical uses, to make a bit of an argument for using decorators at all. So the research was mainly just reading a bunch of articles online and being sad when the coolest one - automatic timeouts for potentially long functions - wouldn’t work on Windows.

No, the real fun part of preparing the presentation was the software side. I decided pretty quickly that if I was going to give a presentation to a bunch of programmers, I may as well show off a bit - so I’d do the presentation in Emacs. If I used Org mode, I could then export the presentation to a wide variety of formats, theoretically with very little effort. I had found a few packages via ELPA for handling presentations (I have a terrible thing for periodically reading the full list of available packages). Sacha had some information on her blog, too. I settled on org-present, because it was simple enough for me to understand as an Org-mode beginner, without preventing me from editing on the fly.

org-present worked flawlessly, so I don’t have a lot to say about it. Though I do wish it could step into some second-level headings (something like Sacha’s code, which I think uses tags, would be more flexible).

The other fun part of this equation was Org Babel - a built-in part of Org that allows you to execute code snippets and embed the results in your document. It does some other neat things for literate programming, which seems cool, but that’s beside the point. The one little thing about Babel is that, normally, you use it to execute the code snippet that your cursor is inside. Because org-present uses narrowing, I knew that each slide would only have one code block, and I didn’t want to manually move my cursor while presenting. Solution: a macro! Incremental search for an opening parens, hit the keys for Babel execution, and switch to an output buffer. I was pretty happy when I got it working.

One small issue with Babel is how it interacts with the Python interpreter. It’s not bad, it’s just… surprising. Babel lets you create an ongoing, dedicated interpreter session so that variables and functions can continue across multiple discrete code blocks. If you don’t do that, everything works the way you’d expect. If you turn it on, suddenly you may get errors due to invisible whitespace and other dumb junk. If you use the session argument and the :results output option (basically, give me whatever the interpreter prints), you unfortunately wind up receiving the interpreter’s prompt and some other junk in your results.

Luckily, a recent addition to Babel allows you to set a function or block of code to perform post-processing on your results. So I wrote a bit of Emacs Lisp to do a regex-replace of “>>>” (the default prompt) - check the org source in the presentation repo if you’re interested.

Also, if you’re using fgallina’s python mode (the default as of version 24.3), I’d also recommend not editing code directly within your Org buffer - use C-c ' org-edit-src-code instead. I had an issue where it would continually indent my code, causing the interpreter to spit out errors,and various other buggy behaviour - and it worked fine if I used org-edit-src-code. So do that.

In sum

I know that doesn’t sound like a whole lot of fun. And why didn’t I just make a slideshow like a normal person? Here’s a few completely biased reasons for doing things this way:

  • I didn’t have to touch PowerPoint or fiddle with Prezi (those are the only two things I’ve made presentations in before, and they’re both time-consuming in their own ways - when I started, I didn’t know about slid.es, which everyone else seems to use)
  • I didn’t have to worry about formatting my code or getting syntax highlighting, or embedding screenshots from my editor
  • I got live code evaluation, which I think is inherently great for presenting code - “here’s some code, this is what it’s supposed to do, now let’s see the results”
  • I got free export to a wide variety of formats
  • My presentation is just a plain text file, and it’s easy to search through (for me in the future as a reference, or for others who find it on GitHub)
  • I learned a bunch about Org and a smattering of Emacs Lisp
  • My presentation didn’t look exactly like the other two presentations that were given (the default theme for reveal.js is practically the only good one, but hey, you can have custom transitions so your presentation looks a little bit different from everyone else)

So I’ll admit that those aren’t convincing arguments for why anyone else should present in Emacs, but it’s good enough for me. And you really can’t ignore the emotional value of having a slideshow that didn’t involve PowerPoint.