2

I have set autofill to 80 with C-x f and autofill-mode is enabled (I see Fill in the modeline), but it doesn't return automatically after 80 characters.

How can I make it works ?

2

From the auto-fill-mode docs:

When Auto Fill mode is enabled, inserting a space at a column beyond `current-fill-column' automatically breaks the line at a previous space.

So if you e.g., type a continuous string starting from column 1 to column 100, it will not break at 80 even if you set fill-column to 80. However, if you enter a space at any point after column 80, any text you type after that should go on the next line automatically.

Update:

The OP was having this issue in c-mode, which contains the variablec-ignore-auto-fill which is a

List of contexts in which automatic filling never occurs. If Auto Fill mode is active, it will be temporarily disabled if point is in any context on this list.

By default (for me) it is set to (string cpp code) which means that it will ignore auto-fill-mode in the following contexts:

string -- inside a string or character literal

cpp -- inside a preprocessor directive

code -- anywhere else, i.e. in normal code

If you put (setq c-ignore-auto-fill nil) in your init file, it should work as you want it to. However, I don't have any experience in the c language, and am not sure if there will be consequences to this setting. I assume, because of these defaults, that there may be some consequences...

  • I don't know why but it doesn't work, it continue to write after, even if I put more than one words after. – Nicolas Scotto Di Perto Jan 6 '16 at 19:58
  • What kind of buffer are you using it in? If it is a text-mode buffer or one related to it, you might have to call toggle-text-mode-auto-fill as well. I tested things out starting emacs with the -Q option, setting fill-column to 80 with C-x f and then turning on auto-fill-mode. This was all done in a scratch buffer in lisp-interaction-mode – elethan Jan 6 '16 at 20:04
  • 1
    It's a C buffer. Why using -Q ? I saw it's quick mode but I don't know what it brings. – Nicolas Scotto Di Perto Jan 6 '16 at 21:03
  • @NicolasScottoDiPerto The -Q option will load emacs without your init file and site-wide startup file among other things. This allows you to kind of start emacs with a blank slate. If it works fine with -Q or -q the issue is probably caused somewhere in your init file – elethan Jan 6 '16 at 21:06
  • @NicolasScottoDiPerto If you are in c-mode, try customizing the variable c-ignore-auto-fill. This is probably what is causing your issue – elethan Jan 6 '16 at 21:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.