Inside Emacs: Why the 40-Year-Old Editor Still Can't Shed Its Single Thread
This Uppsala University bachelor’s thesis by Erik J. Karlsson sets out to fill a real documentation gap: while Emacs Lisp is heavily documented, the internal C architecture of the GNU Emacs core is not, which raises the barrier for anyone wanting to study or modernize it. Working from the Emacs 29.3.5 source, the author traverses the code top-down from the entry point—using Emacs itself plus Doxygen and GNU Global to build call and dependency graphs—and organizes the result along Model-View-Controller lines: Lisp primitives and buffer data structures as the model, redisplay and windowing as the view, and the command loop, keymaps, and Lisp environment as the controller.
The technical heart of the work is concurrency, and the verdict is blunt. Emacs has been single-threaded and sequentially executed since the 1980s, so any long-running Lisp task stalls the command loop and freezes the editor. The cooperative Lisp threads added in Emacs 26 are gated behind a Global Interpreter Lock, meaning only one thread ever makes progress at a time; the thesis argues these threads have little practical real-world use because the GIL plus pervasive global state makes correct use extremely hard. Removing the GIL is characterized as a ‘Herculean’ task: the core leans heavily on shared BSS/DATA global and static state (the allocator and garbage collector, the print buffer, block_input signal handling), all of which would need thread-local storage or new mutex-guarded critical sections before true parallelism is safe.
In practice, Karlsson finds, library authors route around the limitation entirely, relying on three recurring tricks—idle timers to defer work until the user pauses, external non-interactive Emacs processes as parallel workers, and generators to yield and resume tasks. The thesis surveys forks pushing on the problem (Commercial Emacs on preemptive scheduling, Emacs NG on a richer dynamic-module API, Guile Emacs on a Scheme-based interpreter) and positions itself as a foundation to reignite community discussion about unlocking the core rather than a solution to it.
Read the full article
Continue reading at Hacker News →This is an AI-generated summary. Read the original for the full story.