Break that creative block.

Oblique Strategies for Atom

Chris Paul
Hakuna Automata

--

Las week I built oblique-strategies, a tiny package for the Atom editor that will display a random aphorism if there’s a lull in your typing.

The idea is to inspire the user, promote lateral thinking, and break creative blocks — but after using it for a while, I’ve found it’s better at helping me maintain balance and sanity more than anything.

In this post, I’ll talk a bit about the inspiration and my experience developing for and in the Atom editor.

The Deck

Brian Eno and Peter Schmidt published the first Oblique Strategies card deck in 1975. The concept of the card deck is simple: draw a card at random whenever you need inspiration and it will present you with a strategy for thinking about the problem from a different angle.

A deck from 1975.

I first heard about the deck some years ago and have been mildly obsessed with getting it into software as a way of delivering randomized advice without the paper. I considered building a daily quote app, a WordPress plugin, and even a service that texted me on a regular basis. Each of these options felt a bit forced, since the strategies ought to be delivered as needed, not on a schedule.

When I read Kevin Lawler’s Oblique Strategies: Prompts for Programmers earlier this month, the idea solidified: On countless occasions I’ve found myself coded into a corner and in need of a new approach. A card from the deck might’ve been just the catalyst I needed for a quick solution. What better way to deliver them than through an IDE or text editor? I set about to create a plug-in that would do just that.

The Editor

I’ll admit it: I chose Atom because it looks good. Atom is built by GitHub and has been gaining popularity since its debut in 2011 due to its slick-looking interface and extensibility. It’s built on web technologies, including Chromium, node.js, and coffeescript. Justifiably, it’s received some criticism due to performance issues resulting from rendering everything in HTML. In 2014, however, GitHub refactored the editor component to use React, improving rendering speed and stability.

Atom sports many of the same keyboard shortcuts, functionality, and themes of closed-source competitor Sublime Text — however, in my short time with it, Atom feels more polished, particularly in terms of configuration and package management. Atom is also being actively improved, with GitHub releasing weekly updates whereas Sublime Text’s development has been uncertain over the past few years.

The Package

The easiest part about building an Atom package is getting started. The package generator (cmd-shift-p and search for “Generate Package”) creates boilerplate code in all the right places. It took me some time to grow comfortable with the coffeescript syntax, but after a few minutes of tinkering around, I was up and running with a modal that would displaying a random strategy when toggled.

Unfortunately the modal blocked keyboard input (as modals are wont to do). Getting the modal to hide itself upon editor activity was a bit hacky and, to be honest, the appearance and behavior of the modal wasn’t exactly what I was looking for. I wanted something less intrusive… a bit more polite. After doing a bit more digging, I discovered the built-in notification package. Bingo!

I refactored the package to use the notification display and the remaining features I wanted fell into place. However there was one challenging piece I wanted to mention: listening for keyboard input. I tested out a few approaches from Stack Overflow and the Atom forums before settling on the following that I found by following the editor API from the workspace object:

# Detect editor inactivity @subscriptions.add atom.workspace.observeTextEditors (editor) => editor.onDidStopChanging () => # Do something here

Note the use of fat arrows (=>) to bind the ObliqueStrategies object for use in the onDidStopChanging, which allows access to object methods. The scope handling in coffeescript took a bit of getting used to. I realize it is probably intended to address scoping errors common to newer JavaScript developers, but if you know what you’re doing it can feel like it gets in the way at times.

Conclusion

Though not a monumental engineering feat by any means, building oblique-strategies was a great way to get myself back into “creator” mode. Recently, it’s been a struggle to find (make) time for it and this project definitely rekindled my developer flame. It was highly satisfying to learn a bit of coffeescript and get something published — something that people might find useful. I’d like to make these kinds of bite-size weekend projects a regular thing.

In fact, I found myself so engrossed last Sunday that I was startled when my own plugin alerted me to “Take a walk,” after a few hours of coding… which is exactly what I’m going to do now (maybe there ought to be an oblique-strategies plugin for WordPress after all!).

Have you tried out oblique-strategies? What strategies would you add to the list?

--

--