Automatically turn on olivetti-mode when the window is wide

Ashton Wiersdorf via public-inbox

10 months ago
10 months ago


Automatically enable olivetti-mode when the window is wide

Source: https://sr.ht/~ashton314/auto-olivetti/


Olivetti is a wonderful mode. So wonderful, in fact, that I wish it came on automatically. This package does just that.

auto-olivetti in acton


Until I get this on MELPA or the like, you can just clone this repository, and put the following in your init.el:

(load-file "path/to/auto-olivetti.el")

If you use use-package with Elpaca, you can install like so:

(use-package auto-olivetti
  :elpaca (auto-olivetti :host sourcehut :repo "ashton314/auto-olivetti")


It's a good idea to start by customizing the value of olivetti-body-width. Set this as part of your olivetti configuration or with setq-default like so:

(use-package olivetti
  (olivetti-body-width 130))

;; OR

(setq-default olivetti-body-width 130)

(use-package auto-olivetti

(The Customize interface should work as well.)

#Auto-Olivetti customization options

  • auto-olivetti-enabled-modes

    List of modes for which to enable olivetti-mode automatically. Defaults to '(text-mode). '(text-mode prog-mode) is pleasant.

  • auto-olivetti-threshold-fraction

    Fraction of olivetti-body-width at which to enable olivetti-mode.

  • auto-olivetti-threshold-absolute

    Number of columns at which to enable olivetti-mode.

  • auto-olivetti-threshold-method Choose between the fractional and absolute methods.


  • perfect-margin

    I used perfect-margin for a little while and liked it. I found it too aggressive though, and wanted something simpler and cleaner, which is why I built this package.