I wanted to have wc-mode (a minor mode) enabled when I edit any markdown file in a specific directory. So, I created a .dir-locals.el file and added the following to it:

((markdown . ((wc-mode . t))))

But when I open a markdown file, it still does not have wc-mode enabled.

What am I doing wrong? How do I set it right?

  • 2
    You probably want ((markdown . ((mode . wc)))).
    – theldoria
    Commented Jun 5, 2018 at 6:53
  • 2
    Or you may try ((markdown . ((eval . (wc-mode)))))
    – theldoria
    Commented Jun 5, 2018 at 7:00

1 Answer 1


To elaborate on theldoria's comments:

If wc-mode is a major mode then either:

((markdown-mode . ((mode . wc))))


((markdown-mode . ((eval . (wc-mode)))))

If wc-mode is a minor mode, then:

((markdown-mode . ((eval . (wc-mode 1)))))

I have assumed that markdown was an error, and have substituted markdown-mode.

  • Perfect. Thanks. I realized that I could have mentioned that wc-mode is a minor mode. I have edited the question to reflect this.
    – deshmukh
    Commented Jun 5, 2018 at 16:00
  • For eval to work update of safe-local-eval-forms might be required.
    – gavenkoa
    Commented Jan 29, 2021 at 21:10

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.