Google man drags Emacs into the 1990s
Adds double-buffered rendering to stop terminal-era flickering
Software developer and Google employee Daniel Colascione has cooked up what he calls “Buttery smooth Emacs” by adding rendering code to the venerable text editor that does away with long-standing flickering and resizing issues.
As a result, “Now you should be able to edit, resize, and introduce bugs in your awful codebase without seeing a partially-rendered buffer or being incited to murder by barely-perceptible white flashes while editing that disappear when you look at them.”
Colascione's Facebook post explains that Emacs uses code called
redisplay that assumes it's in a very resource-constrained environment like a terminal. As you type, the code therefore “essentially diffs the last-known display configuration and what it’s supposed to be displaying right now, then emits a minimal set of terminal control codes needed to change the last-known state to the current-good state.”
On a terminal, this looks tolerable. But on modern systems, or when run inside a GUI, Emacs flickers. Colascione describes its performance as follows:
Emacs flickers like crazy. This flickering is a predictable consequence of the “do what the f*ck I want when I want it” redisplay strategy Emacs uses.
There's a lot more detail about Emacs' innards and why it flickers in his post, but the core of the matter is he found a way to stop the flickers.
“Modern incarnations of the X Window System have a nice extension called
DOUBLE-BUFFER, he writes. “This extension lets a program pretend it’s rendering directly to the user while in fact rendering some intermediate buffer. Under program control, X11 (the GUI, recall) will copy this intermediate buffer to the primary display. This functionality is perfect for Emacs.”
Colascione says his work isn't elegant, but “somehow, it all works.”
“And as a result, Emacs is as smooth and flicker-free as any other modern GUI program, and regular users have no idea what horrors lie beneath.” ®