virtual-auto-fill
is an Emacs Lisp Package to display unfilled text in a readable way. It wraps the text as if you had inserted line breaks (e.g. using fill-paragraph
or auto-fill-mode
) without actually modifying the underlying buffer. It also indents paragraphs in bullet lists properly.
Internally, Adaptive Wrap Prefix mode mode, Visual Fill Column mode, and Visual Line mode are employed to wrap paragraphs and bullet lists between the wrap prefix and the fill column. If you don't need all of the features provided by Virtual Auto Fill mode, it may be better for you to use a subset of these modes directly. However, if you often switch between filled and unfilled text, Virtual Auto Fill mode catches you when you accidentally invoke fill-paragraph
(by default bound to M-q
) out of habit in a virtually filled buffer. To prevent you from breaking the formatting convention without noticing it, you are asked whether you actually meant to fill the paragraph and if you want to be warned again next time.
A common reason to edit unfilled text in Emacs are mails that are intended to look nice on mobile devices. If the display area is too narrow, filled lines have to be broken up a second time resulting in alternating long and short visual lines (compare this to the same mail viewed in landscape). format=flowed
was meant to fix this, but unfortunately it is neither used by everyone who writes filled mails, nor is it supported by every mail client (e.g. neither iOS Apple Mail nor FastMail support it). When communicating whith people who are likely using a GUI Mail client with a non-monospace font, you may therefore choose to just leave the text unfilled and use Virtual Auto Fill mode to edit it (which is exactly what the popular mail clients do).
Without virtual-auto-fill-mode
, only a small portion of the text file is visible:
virtual-auto-fill
displays the buffer as if you had filled it, but without actually modifying it:
After installation, the command virtual-auto-fill-mode
which enables the mode is autoloaded, you can call it without any additional configuration!
Having set up straight.el, add the following to your .emacs.d/init.el
, then restart your Emacs:
(straight-use-package
'(virtual-auto-fill
:type git
:host github
:repo "luisgerhorst/virtual-auto-fill"))
For a complete example configuration see example-configs/straight/init.el
. You can omit the parts already included in your init.el
.
After adding MELPA to your package-archives
, run M-x package-install virtual-auto-fill
once.
See example-configs/melpa/init.el
for a complete config (copying not recommened thought).
To enable Virtual Auto Fill mode automatically in Markdown files, add the following after also installing markdown-mode
:
(with-eval-after-load 'markdown-mode
(add-hook 'markdown-mode-hook #'virtual-auto-fill-mode))
The following serves as documentation for contributors to easy development. If you just want to use this package as a end user this should not concern you.
Load the example configuration into a vanilla instance of Emacs, this will install straight.el to ./example-config/straight
:
make CONFIG=straight test
Run with CONFIG=melpa
to test the MELPA configuration. Refer to the Makefile
for additional commands that may be useful.