Reputation: 131
Motivation: Using the defaults, Auto Fill mode seems not as useful as I might have hoped: If I insert a sentence in the middle of a paragraph, only the current line is re-filled. When I insert a sentence, I want the entire paragraph to be re-filled.
Question: How can I set auto-fill-function
(or perhaps
normal-auto-fill-function
) in my .emacs
file so that the paragraph is re-filled whenever a single line overflows?
I tried setting it to fill-paragraph
, but then I cannot insert any spaces at the end of a paragraph (e.g., to add another word).
More details: I primarily use Auto Fill mode in the AUCTeX major mode for LaTeX.
The built-in Emacs documentation for auto-fill-mode
states:
When
auto-fill-mode
is on, theauto-fill-function
variable is non-nil
.The value of
normal-auto-fill-function
specifies the function to use forauto-fill-function
when turning Auto Fill mode on.
The documentation for the normal-auto-fill-function
variable
says that it is the function to use for auto-fill-function
if Auto Fill mode is
turned on, and that the initial value is do-auto-fill
.
Upvotes: 3
Views: 1321
Reputation: 8344
For LaTeX files you can try (requires AUCTeX)
(add-hook 'LaTeX-mode-hook '(lambda ()
(setq auto-fill-function 'LaTeX-fill-paragraph)))
but use it with caution.
Upvotes: 1
Reputation: 28541
You might like to try refill-mode
. But in general, it's just tricky to make such a feature work well. Another approach is to only do the refill as part of the redisplay (i.e. without affecting the buffer's actual content). For that, try setting word-wrap
or enabling visual-line-mode
.
Upvotes: 2