The persist-text-scale Emacs package provides persist-text-scale-mode
, which ensures that all adjustments made with text-scale-increase
and text-scale-decrease
are persisted and restored across sessions. As a result, the text size in each buffer remains consistent, even after restarting Emacs.
(By default, persist-text-scale-mode
saves the text scale individually for each file-visiting buffer and applies a custom text scale for each special buffer. This behavior can be further customized by assigning a function to the persist-text-scale-buffer-category-function
variable. The function determines how buffers are categorized by returning a category identifier based on the buffer’s context. Buffers within the same category will share the same text scale.)
Features
- Automatically persists and restores the text scale for all buffers.
- Periodically autosaves at intervals defined by
persist-text-scale-autosave-interval
(can be set to nil to disable or specified in seconds to enable). - Supports unified text scaling across buffer categories.
- Offers fully customizable logic for categorizing buffers based on text scale.
- Lightweight and efficient, requiring minimal configuration.
- Enables custom buffer categorization by specifying a function for the
persist-text-scale-buffer-category-function
variable, ensuring that groups of buffers share the same persisted and restored text scale.
Installation: Emacs: Install with straight (Emacs version < 30)
To install persist-text-scale with straight.el:
- It if hasn’t already been done, add the straight.el bootstrap code to your init file.
- Add the following code to the Emacs init file:
(use-package persist-text-scale
:ensure t
:straight (persist-text-scale
:type git
:host github
:repo "jamescherti/persist-text-scale.el")
:custom
(persist-text-scale-autosave-interval (* 7 60))
:config
(persist-text-scale-mode))
Code language: JavaScript (javascript)
Alternative installation 1: Emacs: Installing with use-package and :vc (Built-in feature in Emacs version >= 30)
To install persist-text-scale with use-package and :vc (Emacs >= 30):
(use-package persist-text-scale
:ensure t
:vc (:url "https://github.com/jamescherti/persist-text-scale.el"
:rev :newest)
:custom
(persist-text-scale-autosave-interval (* 7 60))
:config
(persist-text-scale-mode))
Code language: JavaScript (javascript)
Alternative installation 2: Doom Emacs
Here is how to install persist-text-scale on Doom Emacs:
- Add to the ~/.doom.d/packages.el file:
(package! persist-text-scale
:recipe
(:host github :repo "jamescherti/persist-text-scale.el"))
Code language: JavaScript (javascript)
- Add to ~/.doom.d/config.el:
;; TODO: Load the mode here
(after! persist-text-scale
(setq persist-text-scale-autosave-interval (* 7 60))
(persist-text-scale-mode))
- Run the
doom sync
command:
doom sync