Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In Emacs (23.4.1), how do I enable a minor mode (e.g. auto-fill-mode) for all files in a major mode (e.g. text-mode) under a directory (recursively)?

It doesn't look like directory-local variables can do ths, but I might be wrong.

share|improve this question

1 Answer 1

You should use a text-mode hook. In your .emacs file:

(defun turn-on-auto-fill-hook ()
  (cond ((string-match "^/home/foo/bar/blat/" buffer-file-name)
         (auto-fill-mode 1))))

(add-hook 'text-mode-hook 'turn-on-auto-fill-hook)

Replace /home/foo/bar/blat with the path to the directory whose files you want to have auto-fill-mode enabled in when visited. Don't remove the caret.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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