I have web-mode (which is awesome, by the way). The following line: (add-to-list 'auto-mode-alist '("\\.html\\'" . web-mode)) every time when a .html file is loaded, web-mode will be enabled.

But I would like when web-mode is loading in .html-files, then the zencoding-mode (a minor mode) will be also enabled by default. I tried various ways to get this worked.

For example (add-hook 'web-mode-hook 'zencoding-mode)will not work.

And (add-to-list 'auto-mode-alist '("\\.html\\'" . zencoding-mode)) gives problems. Then web-mode is not being loaded, but zencoding mode is being loaded (because that's the last line to be evaluated, so replaces web-mode when a html-file is being opened.

Any suggestions? I would be genuinely thankful.

  • You say "every time when a .html file is loaded". Did you mean visited in Emacs or loaded?
    – Drew
    Apr 21 '15 at 20:20
  • Visited in Emacs.
    – ReneFroger
    Apr 21 '15 at 21:23

Your problem appears to be only that you have not loaded both of those Lisp files. I downloaded those files and loaded them both, then did what you did, and had no problem.

(require 'web-mode)
(require 'zencoding-mode)
(add-to-list 'auto-mode-alist '("\\.html\\'" . web-mode))
(add-hook 'web-mode-hook 'zencoding-mode)

You of course need to put the directory that contains those files in your load-path:

(add-to-list 'load-path "/the/location/of/those/files/")
  • I use package.el. It enables me to not require the packages. It's being loaded before the file with the config above is being loaded. And it's still not working. Any ideas?
    – ReneFroger
    Apr 21 '15 at 21:28
  • I think we must require the packages sometimes dispite the doc.
    – Ehvince
    Apr 21 '15 at 21:43
  • Did you do (package-initialize)? If not, do it. You don't show all that you've done, so it makes this a bit of a guessing game. If you want good help then you owe it to yourself to make it easy to help others help you.
    – Drew
    Apr 21 '15 at 22:11
  • Drew, yes, I have (require 'package) (package-initialize) declared at the top of my dot.emacs configuration file. What for else information do you need in order to debug this, you think?
    – ReneFroger
    Apr 22 '15 at 10:19
  • I cannot repro the problem here, when I start from emacs -Q (no init file). What happens when you do that? If no problem that way, the recursively bisect your init file to find out what introduces the problem. Use comment-region to comment out progressively larger sections of your init file (1/2, 3/4, 7/8, 15/16...). You can use C-u with comment-region to uncomment the region. Probably something in your init file is leading to the problem - you just need to identify it.
    – Drew
    Apr 22 '15 at 13: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.