web-mode icon indicating copy to clipboard operation
web-mode copied to clipboard

Setting web-mode-engines-alist in .dir-locals.el has no effect in Emacs 25.1.1

Open Denommus opened this issue 8 years ago • 12 comments

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 avatar Sep 28 '16 14:09 Denommus

@Denommus I am not familiar with this. Could you ask on emacs stackoverflow please

fxbois avatar Sep 28 '16 14:09 fxbois

@fxbois It's not really a question. The setup used to work under Emacs 24, but in Emacs 25 it doesn't.

Denommus avatar Sep 29 '16 21:09 Denommus

@Denommus ok but I have no clue about this. Try on stackoverflow

fxbois avatar Sep 30 '16 06:09 fxbois

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.

sshaw avatar Mar 15 '17 00:03 sshaw

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

rschuetzler avatar May 05 '17 17:05 rschuetzler

@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.

basil-conto avatar May 09 '17 19:05 basil-conto

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.

gergelypolonkai avatar Jul 19 '18 11:07 gergelypolonkai

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?

CestDiego avatar Sep 17 '18 00:09 CestDiego

Good catch, I'm going to investigate as well.

Denommus avatar Sep 17 '18 00:09 Denommus

This is still an issue, it shouldn't be closed 😭.

mohkale avatar Mar 06 '20 23:03 mohkale

Still an issue, still closed. @fxbois can we reopen this?

1player avatar Jun 21 '22 14:06 1player

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)

fxbois avatar Jun 21 '22 20:06 fxbois

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.

georgek avatar Oct 19 '23 18:10 georgek

You can provide a patch. I no not use dir local variable

fxbois avatar Oct 19 '23 19:10 fxbois