0

So, whenever I open a new buffer, auto-fill-mode is enabled. I have checked my configuration and have verified that I'm not enabling it in the init.el file. How do I find out from where it is getting enabled ?

Also, how do I disable it in a certain mode like html-mode. I tried some suggestions in this thread but this doesn't seem to work for me:

(remove-hook 'html-mode-hook 'turn-on-auto-fill)
3

What I usually do is look at the doc string first and search for "hook". This gives me html-mode-hook and the hooks of its parents. Search for "parent" and this gives me sgml-mode. Keep repeating. I end up with:

  1. html-mode-hook
  2. sgml-mode-hook
  3. text-mode-hook

Still in the *Help* buffer, you can click on all of those and see what's there. In my case, I see turn-on-auto-fill on text-mode-hook. The solution was this:

(add-hook 'html-mode-hook 'turn-off-auto-fill)

Text Mode will have auto-fill enabled and HTML Mode will have auto-fill disabled. You could argue that I probably don't want SGML Mode to have auto-fill enabled, but since I don't use it, I don't care. :)

Looking at Doc Strings: If it's a function, use C-h f. If it's a variable, use C-h v. If you don't know what your major mode is, examine the variable major-mode using C-h v. This should tell you the major mode such as html-mode. This is a function, so you need to use C-h f.

  • Thanks, works perfectly. Can you also add how you see doc strings ? – Sibi Nov 18 '14 at 10:42
  • Sure. No problem. – Alex Schröder Nov 18 '14 at 10:48
5

You can get Emacs to show you a stack trace when the function is called, so that you can figure out what called it.

  1. M-x debug-on-entry RET auto-fill-mode RET
  2. trigger the issue
  3. Check the stack trace. Depending on the details, the exact cause may not be 100% clear, but it should certainly give you a good idea of where to look next.
  4. Use c to continue execution of the function, or q to quit the debugger.
  5. M-x cancel-debug-on-entry RET RET

The documentation for the debugger is in the manual:

C-hig (elisp) Debugger RET

Be sure to read the "Debugger Commands" node.

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.