Skip to content
HN On Hacker News ↗

What's New in Emacs 31.1?

▲ 346 points 119 comments by geospeck 2w ago HN discussion ↗

Pangram verdict · v3.3

We believe this text is mainly human-written, with some AI content.

2 %

AI likelihood · overall

Human
99% human-written 1% AI-generated
SEGMENTS · HUMAN 1 of 1
SEGMENTS · AI 0 of 1
WORD COUNT 1,704
PEAK AI % 1% · §1
Analyzed
Aug 25
backend: pangram/v3.3
Segments scanned
1 windows
avg 1704 words each
Distribution
99 / 1%
human / AI fraction
Verdict
Human
Pangram v3.3

Article text · 1,704 words · 1 segments analyzed

Human AI-generated
§1 Human · 1%

Emacs 31.1 is finally out! Unlike earlier Emacs versions, there is not a singular big-bang feature in this release. From what I could gather, the new garbage collector was possibly planned for inclusion in Emacs 31.1, but it has been postponed to Emacs 32. But more on that in a future post; it’s an interesting subject. Some of the more notable features in Emacs 31.1 are small, quality of life fixes, and one deprecation that marks the end of an era. As always, my book, Mastering Emacs is 31% off for the next week to celebrate the release also. The unexec/pdumper controversy and subsequent deprecation Emacs is… not a normal application. When you compile and link it, you get temacs which is the heart of Emacs but without most of the libraries that ship with it. It’s a bare-bones Emacs with little more than the C core and the interpreter; it’s not really that useful. To get the Emacs binary you know and love, you have to run temacs and tell it to load the standard library into memory. That is slow. There is a lot of elisp and housekeeping that has to happen. It can take several minutes and a fair bit of CPU and ram to start Emacs this way; it’s untenable. This has been a problem that has dogged Emacs for decades. It’s not a huge deal today, but back in the day it could break the back on home computers or even shared multi-user environments if a brace of enthusiastic Emacs users all decide to launch Emacs at the same time in the morning. The solution to this problem? Load it all in once and then literally dump the text/data/bss/etc. segments of Emacs’s memory to a new binary. Do that, and you don’t have to bootstrap all that Emacs lisp state again and again. It feels like a wrestling move almost. You corral a top-heavy Emacs into position and apply The Attitude Adjustment, body slamming Emacs into a new binary, and everything’s all set up and ready to go. It’s a pretty boss move. But to make this, uh, wrestling move work, Emacs depended on a number of snowflake functions in glibc. After a couple of decades of enabling this sort of bad behavior the glibc team called it quits, and Emacs had to find another way of doing it. Daniel Colascione built a much better solution, though not everyone was happy about it, that – put simply – standardizes the serialization of Emacs’s internal structures into something that is not a 1:1 dump of its internal memory structures. The portable dumper’s been the default for a number of years now. It was first introduced around ten years ago, and in keeping with Emacs’s long history of backwards compatibility, the old unexec dumper was kept around ostensibly for the one or two users who found the idea of a portable dumper risible or unworkable. But now it is finally gone for good. The end of an era. User Lisp Directory Classic problem: you git clone or download an Emacs package somewhere and now you want it to work. But how? It’s not that trivial; there are quite a few competing ways of doing it. The simplest one is to tell users to drop their package into the user-lisp/ in your .emacs.d directory and Emacs will sort out loading and setting up autoload (so the right stuff appears in M-x.) Minibuffer and Completions Emacs 30.1 gained completion-preview-mode, a native “pop-up window” system not unlike Company and Corfu, but more attuned to Emacs’s own way of doing things: using the *Completions* window instead of a floating child frame like Company and friends. Emacs 31.1 builds on that with a wide range of customizable options you’re sure to want to customize if you want to go native. Rotating Window Layouts M-x window-layout-rotate-clockwise (see C-x w C-h for the manifold new options) and suchlike rotate your window layouts. Another little UI winner. Exchanging the point and mark without activating the region I’ve talked (mostly in the my book) about how transient-mark-mode is a rather awkward one-size-fits-all that was draped over Emacs’s multitude of “region-affecting” commands, like kill-region (C-w). So C-x C-x, that exchanges point and mark, also activates the region whether you want it to or not. Fixing the mark commands in transient mark mode is an old article of mine where I demonstrate how to do exactly that. But now there’s a builtin option to not have it do that — sweet. Tree-sitter now offers to install its grammars for you Two blockers work in tandem to hold back the wider adoption of tree-sitter in Emacs: The fact that TS demands a special major mode to work; and that said mode is often a thread-bare re-implementation of the original. That installing grammars, especially on Windows, is a giant pain in the neck, as you have to not only thread the needle with the exacting ABI version of the tree-sitter library itself, but also ensure you just the exacting version of each language grammar, or everything goes up in smoke. The former is still a problem, but the latter is now mostly resolved. Emacs can now finally offer to install the right language grammar for TS modes it knows about. Now there’s no excuse not to try out Combobulate: Structured Movement and Editing with Tree-Sitter. and so much more Lots of little tweaks and changes. Have a read. Installation Changes in Emacs 31.1 unexec dumper removed. The traditional unexec dumper, deprecated since Emacs 27, has been removed. The portable dumper now works on m68k a.out targets. As I wrote in the introduction at the top, this is indeed the end of an era. Emacs's old 'ctags' program is no longer built or installed. You are encouraged to use Universal Ctags <https://ctags.io/> instead. For now, to get the old 'ctags' behavior you can can run 'etags --ctags' or use a shell script named 'ctags' that runs 'etags --ctags "$@"'. If you’re a TAGS user you should check with where and make sure you’ve got a newer one installed. (If you don’t know if you use TAGS, you do not.) Changed GCC default options on 32-bit x86 systems. When using GCC 4 or later to build Emacs on 32-bit x86 systems, 'configure' now defaults to using the GCC options '-mfpmath=sse' (if the host system supports SSE2) or '-fno-tree-sra' (if not). These GCC options work around GCC bug 58416, which can cause Emacs to behave incorrectly in rare cases. New configure option '--with-systemduserunitdir'. This allows specifying the directory where the user unit file for systemd is installed; the default is '${prefix}/usr/lib/systemd/user'. You can tell Emacs to install a systemd service to run Emacs’s server that way. I recommend doing this. Startup Changes in Emacs 31.1 In compatible terminals, 'xterm-mouse-mode' is turned on by default. For these terminals the mouse will work by default. A compatible terminal is one that supports Emacs setting and getting the OS selection data (a.k.a. the clipboard) and mouse button and motion events. With 'xterm-mouse-mode' enabled, you must use Emacs keybindings to copy to the OS selection instead of terminal-specific keybindings. You can keep the old behavior by customizing 'xterm-mouse-mode' to nil. Most people do not know this but Emacs added mouse support to terminal Emacs years ago but left it off. Terminal capabilities vary widely so that was a nice and safe decision. But now it just works as you’d expect it to: menus are clickable and so forth. Good stuff. site-start.el is now loaded before the user's early init file. Previously, the order was early-init.el, site-start.el and then the user's regular init file, but now site-start.el comes first. This allows site administrators to customize things that can normally only be done from early-init.el, such as adding to 'package-directory-list'. If you’re on a single user system like your laptop or home computer, this is unlikely to matter much to you. New User Lisp directory feature. If you have a subdirectory "user-lisp/" in your Emacs configuration directory, then Lisp files in it and any subdirectories are now recursively byte-compiled, scraped for autoload cookies and added to 'load-path'. You can disable the feature by setting 'user-lisp-auto-scrape' to nil, and you can customize the option 'user-lisp-directory' to process some other directory instead. There is also a new command 'prepare-user-lisp' that you can invoke at any time. See the Info node "(emacs) User Lisp Directory" for more details. Oh this is so useful. I have been cargo culting the same snippets of code around for 23 years to load directories with my stuff in it; yes use-package helps but it’s still a lot of manual hassle. About time! The first client frame now shows warnings from daemon startup. When there are warnings emitted during Emacs startup, usually due to problems in your initialization file, these are shown in a "*Warnings*" buffer. Until now such warnings were not made visible in the case that Emacs was started as a daemon. Now the first frame after daemon startup will show the "*Warnings*" buffer. So for example, starting Emacs with a command like 'emacsclient -a "" -c' will now show "*Warnings*" just like a plain invocation of 'emacs' would. Bad news. Emacs’s insistence on telling you about every minor stubbed toe in some random package will now plague you even if you’re running Emacs as a daemon. Such a cursed feature. Nobody cares. If it was important it’d be an error. Changes in Emacs 31.1 'line-spacing' now supports specifying spacing above the line. Previously, only spacing below the line could be specified. The user option can now be set to a cons cell to specify spacing both above and below the line, which allows you to vertically center text. This is a global value to all of Emacs, it’s not a face setting, so you cannot use M-x customize-face to change it. Set it with setopt or customize ui. New face 'margin' for the window margin display. A new basic face 'margin' is used by default for text displayed in the left and right margin areas, which are used by various packages for per-line annotations. Its background defaults to the frame default background, so existing behavior is unchanged for