Closed joddie closed 10 years ago
My mistake, I see this is mostly a duplicate of issue #12. Feel free to close it so that any other discussion happens over there.
Hi, @joddie.
You are right this is a duplicate of #12. Trying to use dir-locals in `drupal-detect-drupal-version' was a choice I made a long time ago.
I have been wanting do a cleanup but never got around to it - until now! Thank you for beating me to it!
Please have a look at the feature/no-dir-locals
branch - it doesn't use dir-locals. I'll try out the branch for a few days myself before applying it to develop and creating a new release.
I'll continue the work in #12 (and hope you don't mind I accidentally turned this issue into a pull request against the master branch).
Sorry I took so long to reply to this, but thank you for the fix! This will be really useful to me.
I experience problems trying to set directory-local variables for a Drupal project using a
.dir-locals.el
file when drupal-mode is enabled.Here is a test case: create a
.dir-locals.el
file at the root of a Drupal project with the following contents:This should set the variable
my-test-variable
to the symbolfoo
for files in any mode within the directory. (Becausemy-test-variable
lacks adefvar
declaring it a safe varaiable, Emacs will also pop up a warning whenever these variables are applied).Starting from a new Emacs instance with drupal-mode installed, before any PHP files within the project are visited, the dir-locals are applied as expected (and cause a warning for each file opened). They are also applied the first PHP file visited within the project. However, after this, the dir-locals are not applied to any subsequent files opened within the project (whether they are in PHP or any other mode).
I suspect this problem arises because of the way that drupal-mode's
drupal-detect-drupal-version
uses thedir-locals-set-directory-class
anddir-locals-set-class-variables
functions: the "directory class" set for the directory then takes precedence over the contents of.dir-locals.el
files in the filesystem. If this is the case, a possible fix might be fordrupal-detect-drupal-version
to merge any existing variables fromdir-local-variables-alist
together with its own dir-local values before callingdir-locals-set-class-variables
. If you like, I can try this out and submit a patch. Otherwise, let me know if you can reproduce this or would like more information.Thanks for drupal-mode!