web-mode
web-mode copied to clipboard
Setting web-mode-engines-alist in .dir-locals.el has no effect in Emacs 25.1.1
I have
((web-mode .
((web-mode-engines-alist .
(("django" . "*\\.html\\'"))))))
in my .dir-locals.el and
(setq web-mode-enable-engine-detection t)
In my init.el
Although the web-mode-engines-alist
variable does change in every web-mode buffer under that directory, the engine is not affected. This setup worked in Emacs 24.
@Denommus I am not familiar with this. Could you ask on emacs stackoverflow please
@fxbois It's not really a question. The setup used to work under Emacs 24, but in Emacs 25 it doesn't.
@Denommus ok but I have no clue about this. Try on stackoverflow
Funny enough I have the exact same config in my .dir-locals.el
under Emacs 24.4.1. The variables are set, but the detection is not made.
@Denommus do you know under what version of Emacs/web-mode this worked? I'm using a slightly older version of web-mode from MELPA: 20160422.2337.
I am having the same issue, and I've asked the question over at emacs.SX: https://emacs.stackexchange.com/questions/32585/set-web-mode-engine-per-directory
@Denommus Unless web-mode
uses glob patterns (which I doubt but can't confirm), the asterisk in your regular expression makes it malformed. It should instead read:
((web-mode
. ((web-mode-engines-alist
. (("django" . "\\.html\\'"))))))
See the manual node (emacs) Regexps
for more information on regular expression syntax in Emacs.
This does not necessarily fix the larger issue at hand, though.
My guess is the engine gets set before the file/directory local variables are set. Either set it in a .dir-locals.el
file, or at the beginning of the file using {# -*- web-mode-engine:django -*- #}
, web-mode doesn’t recognise it.
I was investigating this a little and it seems the problem with the dir-locals value is brought by the lexical binding in Emacs to me.
Here is the check for engines-alist: https://github.com/fxbois/web-mode/blob/master/web-mode.el#L13293. It seems to check for the variable value, but when I add debug messages it always prints the global value of the alist. I think this is because of the lexical scoping.
Can someone with more experience look into this as well? How are we supposed to override buffer-local variables under the new lexical scoping?
Good catch, I'm going to investigate as well.
This is still an issue, it shouldn't be closed 😭.
Still an issue, still closed. @fxbois can we reopen this?
I've reopened the issue but I won't work on this because I do not use .dir-locals.el Anyone could propose a path ? (I can provide help)
This is still an issue. It would make things so much easier if web-mode-engine
could be set as a dir local variable. This means all files in that directory/project would automatically open with the correct engine setting.
You can provide a patch. I no not use dir local variable