14

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.


UPDATE

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?

tobeannounced
  • 1,999
  • 1
  • 20
  • 30
  • Emacs has detailed online documentation. It might be helpful to use `describe-function`, `describe-variable` to find out how you could use a function, a variable. – jfs Dec 18 '10 at 10:13
  • try `describe-variable`, it may show you that `comment-auto-fill-only-comments` is not what you think it is. If that's the case, then possibly there's a hook running after you set the value, that stomps on your value. – Cheeso Dec 21 '10 at 21:49

1 Answers1

13

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)

Rémi
  • 8,172
  • 2
  • 27
  • 32