Skip to content

Conversation

@arnested
Copy link
Owner

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:

((nil
  (my-test-variable . foo)))

This should set the variable my-test-variable to the symbol foo for files in any mode within the directory. (Because my-test-variable lacks a defvar 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 the dir-locals-set-directory-class and dir-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 for drupal-detect-drupal-version to merge any existing variables from dir-local-variables-alist together with its own dir-local values before calling dir-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!

arnested and others added 24 commits November 24, 2013 23:06
In a better way than 4adeb0c.
This way it is easier to also add the mnemonic keys / functions to other
key bindings. I.e. I do the following in my .emacs to map them to the
hyper key:

```
(add-hook 'drupal-mode-hook (lambda ()
                              (dolist (elem drupal-mode-map-alist)
                                (local-set-key `[(hyper ,(car elem))] (cdr elem)))))
```
`whitespace-style` not only decides what kind of whitespace gets
highlighted by `whitespace-mode` but also what kind of whitespace gets
removed by `whitespace-cleanup`.
Updated phpcs patterns to new flycheck format.
Implemented our own versions of `flymake-create-temp-inplace` and
`flymake-create-temp-intemp`.

We need them to ensure better temporary file names to comply well with
Drupal Coder Sniffer.

We need the new `drupal/flymake-phpcs-init` to call our own temporary
file name functions.

Simplified setting `flymake-allowed-file-name-masks`.
@joddie
Copy link
Contributor Author

joddie commented Jan 26, 2014

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.

@arnested
Copy link
Owner

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

@arnested arnested closed this Jan 27, 2014
arnested added a commit that referenced this pull request Jan 28, 2014
arnested added a commit that referenced this pull request Jan 29, 2014
@joddie
Copy link
Contributor Author

joddie commented Feb 18, 2014

Sorry I took so long to reply to this, but thank you for the fix! This will be really useful to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants