1

I'd like to turn auto-fill in org-mode. I see that it can be done on a per-file basis, this way, but I'd like to do it altogether.

This answer describes that by default, normal-auto-fill-function is set to org-auto-fill-function. How might I change this?

4
  • By default (try e.g. emacs -Q), auto-fill-mode is off in every mode and every buffer. It is a minor mode, so the user chooses whether to turn it on in a particular buffer or a particular mode. So if it is on in Org mode buffers, it is because you are turning it on. Check the value of org-mode-hook with C-h v org-mode-hook and see if you have added a function to it that turns it on - if so, just don't add that function.
    – NickD
    Commented Apr 29 at 15:48
  • 1
    On the contrary. It's on by default, and it's not in the hook. normal-auto-fill-function is set to org-auto-fill-function. I haven't set it that way. There's nothing in my .emacs mentioning auto-fill outside of the text-mode-hook and the tex-mode-hook.
    – Diagon
    Commented Apr 29 at 15:57
  • Yes, but see my answer.
    – NickD
    Commented Apr 29 at 16:12
  • 1
    BTW, tex-mode is derived from text-mode, so if you turn it on in text-mode-hook, you don't need to turn it on in tex-mode-hook too.
    – NickD
    Commented Apr 29 at 17:14

1 Answer 1

2

Org mode is a derived mode of Text mode: if you turn auto-fill-mode on for Text mode, then you turn it on for all derived modes, including Org mode. If you want it on for Text mode but want it off for Org mode, then you have to turn it off in org-mode-hook:

(with-eval-after-load 'org
   (add-hook 'org-mode-hook (lambda () (auto-fill-mode -1))))

Do C-h f org-mode: near the end you will find this paragraph:

In addition to any hooks its parent mode ‘outline-mode’ might have
run, this mode runs the hook ‘org-mode-hook’, as the final or
penultimate step during initialization.

  Parent mode: ‘outline-mode’.

and if you do the same with C-h f outline-mode, you will find this paragraph:

Turning on outline mode calls the value of ‘text-mode-hook’ and then of
‘outline-mode-hook’, if they are non-nil.

  Parent mode: ‘text-mode’.
1
  • Ah. That is definitely helpful! Effusive thanks! :)
    – Diagon
    Commented Apr 29 at 22:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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