Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .