I can't set fill-column in reStructuredText mode hook:

(add-hook 'rst-mode-hook
      (setq auto-fill-mode 1)  
      (set-fill-column 60)))

While the auto-fill-mode works, the default fill-column is not changed, is there anything wrong with the code?


Two things.

  1. auto-fill-mode is a function rather than a variable, so do not try to setq it.
  2. It's not immediately obvious why set-fill-column isn't working, but instead, try setqing fill-column rather than using set-fill-column, which works for me.

So, for example:

(defun my-rst-hook ()
  (auto-fill-mode 1)
  (setq fill-column 60))

(add-hook 'rst-mode-hook #'my-rst-hook)
|improve this answer|||||
  • I have tried that earlier it doesn't work. – Basel Shishani Jan 1 '15 at 13:01
  • I'm guessing it's something in your init file, then. Try evaluating this code after running emacs with no init file (emacs -Q). If it works fine (it should), then the problem is something else in your init file. – Dan Jan 1 '15 at 13:04
  • Thanks - it does work as you suggested. Something wrong in my .emacs files, I'll have to comb it out. – Basel Shishani Jan 1 '15 at 13:17
  • I have (desktop-save-mode 1) in my .emacs, and I was testing by shutting down emacs and restarting it, which apparently does not trigger the hook for open files. But if the rst file is closed and reopen then there's no problem. – Basel Shishani Jan 1 '15 at 15:13

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.