Posts
-
Emacs Prelude: Redux
Programmers know the benefits of everything and the tradeoffs of nothing.
– Rich Hickey
Earlier today I wrote about Emacs Redux turning 13. That felt like the perfect occasion to also ship something I’ve been working towards for a while – Emacs Prelude 2.0.
Read More -
Happy 13th Birthday, Emacs Redux!
13 is my lucky number, so I’m not going to worry about it.1
– Taylor Swift
Exactly 13 years ago today I published the first Emacs Redux post and kicked off what has become one of the longest running projects in my life. Time flies!
Read More-
Same here I guess, given I was born on the 13th. ↩
-
-
Reloading Emacs Lisp Code
While working on erlang-ts-mode recently, someone asked me how I reload the mode’s code while developing it. I realized that while the answer is obvious to me after years of Emacs Lisp hacking, it’s not obvious at all to people who are just getting started with Emacs Lisp development. So here’s a short practical guide.
Read More -
super-save 0.5: Modernized and Better Than Ever
It’s been a while since the last super-save release. The last time I wrote about it was back in 2018, when I boldly proclaimed:
It seems that now super-save is beyond perfect, so don’t expect the next release any time soon!
Famous last words. There was a 0.4 release in 2023 (adding a predicate system, buffer exclusions, silent saving, and trailing whitespace cleanup), but I never got around to writing about it. The package has been rock solid for years and I just didn’t pay it much attention – it quietly did its job, which is kind of the whole point of an auto-save package.
A Bit of History
The idea behind
super-savegoes all the way back to a blog post I wrote in 2012 about auto-saving buffers on buffer and window switches. I had been using IntelliJ IDEA for Java development and loved that it would save your files automatically whenever the editor lost focus. No manualC-x C-s, no thinking about it. I wanted the same behavior in Emacs.Back then, the implementation was crude –
defadviceonswitch-to-buffer,other-window, and thewindmovecommands. That code lived in Emacs Prelude for a few years before I extracted it into a standalone package in 2015.super-savewas born.What Prompted This Release
Yesterday I stumbled upon buffer-guardian.el, a package with very similar goals to
super-save. Its README has a comparison with super-save that highlighted some valid points – mainly thatsuper-savewas still relying on advising specific commands for buffer-switch detection, while newer Emacs hooks likewindow-buffer-change-functionsandwindow-selection-change-functionscould do the job more reliably.The thing is, those hooks didn’t exist when
super-savewas created, and I didn’t rush to adopt them while Emacs 27 was still new and I wanted to support older Emacsen. But it’s 2026 now – Emacs 27.1 is ancient history. Time to modernize!What’s New in 0.5
This is the biggest
super-saverelease in years! Here are the highlights:Modern buffer/window switch detection
Buffer and window switches are now detected via
window-buffer-change-functionsandwindow-selection-change-functions, controlled by the newsuper-save-when-buffer-switchedoption (enabled by default). This catches all buffer switches – keyboard commands, mouse clicks, custom functions – unlike the old approach of advising individual (yet central) commands.Modern focus handling
Frame focus loss is now detected via
after-focus-change-functioninstead of the obsoletefocus-out-hook, controlled bysuper-save-when-focus-lost(also enabled by default).Soft-deprecated trigger system
With the new hooks in place, both
super-save-triggersandsuper-save-hook-triggersnow default tonil. You can still use them for edge cases, but for the vast majority of users, the built-in hooks cover everything.org-src and edit-indirect support
super-savenow knows how to saveorg-srcedit buffers (viaorg-edit-src-save) andedit-indirectbuffers (viaedit-indirect--commit). Both are enabled by default and controlled bysuper-save-handle-org-srcandsuper-save-handle-edit-indirect.Safer predicates
Two new default predicates prevent data loss:
verify-visited-file-modtimeavoids overwriting files modified outside Emacs, and a directory existence check prevents errors when a file’s parent directory has been removed. Predicate evaluation is also wrapped incondition-casenow, so a broken custom predicate logs a warning instead of silently disabling all auto-saving.Emacs 27.1 required
This allowed cleaning up the code and relying on modern APIs.
Upgrading
For most users, upgrading is seamless – the new defaults just work. If you had a custom
super-save-triggerslist for buffer-switching commands, you can probably remove it entirely:;; Before: manually listing every command that switches buffers (setq super-save-triggers '(switch-to-buffer other-window windmove-up windmove-down windmove-left windmove-right next-buffer previous-buffer)) ;; After: the window-system hooks catch all of these automatically ;; Just delete the above and use the defaults!If you need to add triggers for commands that don’t involve a buffer switch (like
ace-window),super-save-triggersis still available for that.A clean 0.5 setup looks something like this:
(use-package super-save :ensure t :config ;; Save buffers automatically when Emacs is idle (setq super-save-auto-save-when-idle t) ;; Don't display "Wrote file..." messages in the echo area (setq super-save-silent t) ;; Disable the built-in auto-save (backup files) since super-save handles it (setq auto-save-default nil) (super-save-mode +1))It’s also worth noting that Emacs 26.1 introduced
auto-save-visited-mode, which saves file-visiting buffers to their actual files after an idle delay. This overlaps withsuper-save-auto-save-when-idle, so if you prefer using the built-in for idle saves, you can combine the two:(use-package super-save :ensure t :config ;; Don't display "Wrote file..." messages in the echo area (setq super-save-silent t) ;; Disable the built-in auto-save (backup files) (setq auto-save-default nil) (super-save-mode +1)) ;; Let the built-in auto-save-visited-mode handle idle saves (auto-save-visited-mode +1)Burst-Driven Development Strikes Again
Most of my Emacs packages are a fine example of what I like to call burst-driven development – long periods of stability punctuated by short intense bursts of activity. I hadn’t touched
super-savein years, then spent a few hours modernizing the internals, adding a test suite, improving the documentation, and cutting a release. It was fun to revisit the package after all this time and bring it up to 2026 standards.If you’ve been using
super-save, update to 0.5 and enjoy the improvements. If you haven’t tried it yet – give it a shot. Your poor fingers might thanks for you this, as pressingC-x C-snon-stop is hard work!That’s all I have for you today. Keep hacking!
-
Tree-sitter Font-Lock and Indentation in Comint Buffers
If you maintain a tree-sitter major mode that has a REPL (comint) companion, you’ve probably wondered: can the REPL input get the same syntax highlighting and indentation as source buffers? The answer is yes – and the infrastructure has been in Emacs since 29.1. It’s just not widely known yet.
Read More
Subscribe via RSS | View Older Posts