I have tried
(set (make-local-variable 'comment-auto-fill-only-comments) t)
and also
(auto-fill-mode 0)
Though amazingly, neither of those work after emacs is restarted.
I am using eschulte's emacs starter kit
Toggling it works fine with M-x auto-fill-mode.
Using a combination of (thanks Rémi):
(auto-fill-mode 1)
(setq comment-auto-fill-only-comments t)
It works perfectly within programming files, where there are comments. However, in text mode, it auto-fills everywhere.
How can I turn off auto-fill-mode completely when inside text documents?
The key to triggering the auto-completion in emacs is the Tab key. You will get a list of suggestions from the compiler. To select something from the list of suggestions, we recommend you to use C-n and C-p, but the down and up arrow keys can be used as well.
Auto Fill mode is a minor mode which is enabled or disabled for each buffer individually. See section Minor Modes. In Auto Fill mode, lines are broken automatically at spaces when they get longer than the desired width. Line breaking and rearrangement takes place only when you type SPC or RET .
Auto Fill mode is a buffer-local minor mode (see Minor Modes) in which lines are broken automatically when the line becomes too wide and you type SPC or RET . M-x auto-fill-mode. Enable or disable Auto Fill mode.
If you want Emacs to auto-fill comments you must not make comment-auto-fill-only-comments a local variable:
(setq comment-auto-fill-only-comments t)
If you want it only in some mode but not all you have to add it to the correct hook:
(add-hook 'ruby-mode-hook
(lambda () ((set (make-local-variable 'comment-auto-fill-only-comments) t)))
UPDATE answer
To remove auto-fill from text mode, you have to use hook:
(add-hook 'text-mode-hook
(lambda () (auto-fill-mode -1)))
Note that this will change also the auto-fill state in mode deriving off text-mode (latex-mode is one examples, there are a lot of other such mode)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With