Expected behaviour
More control over location of and workflow around dir-locals-files.
In this issue I wish to:
- Draw attention to some of the more obvious limitations of the command
projectile-edit-dir-locals.
- Clarify in what way and to what extent Projectile aims to support per-directory local variables.
Actual behaviour
Limitations of command projectile-edit-dir-locals:
-
The dir-locals-file name is currently hard-coded as ".dir-locals.el", which does not take dir-locals-file-2 or MS-DOS limitations into account.
-
The dir-locals-file is expanded relative to (projectile-project-root) and thus does not support nested dir-locals-files.
Steps to reproduce the problem
;; Create project root
C-x C-f test-project/.projectile
C-o C-x C-s y
;; Create root `dir-locals-file'
C-x C-f .dir-locals.el
C-o C-x C-s
;; Create leaf `dir-locals-file'
C-x C-f lisp/.dir-locals.el
C-o C-x C-s y
;; Create project source file
C-x C-f foo.el
C-o C-x C-s
$ tree -a ~/test-project/
test-project/
├── .dir-locals.el
├── lisp
│ ├── .dir-locals.el
│ └── foo.el
└── .projectile
1 directory, 4 files
;; Edit `dir-locals-file' via Projectile
M-x package-initialize
M-x projectile-edit-dir-locals
;; Check current file
M-: (abbreviate-file-name (buffer-file-name)) ; => "~/test-project/.dir-locals.el"
Environment & Version information
Projectile version information
ELISP> (projectile-version)
"20170416.148"
$ cd /path/to/projectile/repo/
$ git describe --abbrev=0 --tags # latest tag
v0.14.0
Emacs version
ELISP> (emacs-version)
"GNU Emacs 26.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
of 2017-03-26"
Operating system
$ uname --kernel-name --kernel-release --machine --operating-system
Linux 4.9.0-2-amd64 x86_64 GNU/Linux
$ cat /etc/debian_version
9.0
Request for Comments
The following suggestions address some of the aforementioned limitations.
- Projectile could first try to find the nearest
dir-locals-file by default, e.g.
;; Note: this does not stop at (projectile-project-root)
(let ((locals (dir-locals-find-file default-directory)))
(when locals
(find-file (car (last (dir-locals--all-files
(or (car-safe locals) locals)))))))
-
The user could be offered a list of all dir-locals-files found between default-directory and (projectile-project-root).
-
A customisation variable could determine whether to prefer the root vs nearest dir-locals-file found, whether to ask the user or whether to offer possible completions.
-
If no dir-locals-files are found, the user could be prompted for a directory in which to create one.
I would appreciate feedback on the given issues and suggestions. I would also be happy to work on a patch for any ensuing decisions, if I am given some initial pointers.
Thank you for this excellent and useful package!
Expected behaviour
More control over location of and workflow around
dir-locals-files.In this issue I wish to:
projectile-edit-dir-locals.Actual behaviour
Limitations of command
projectile-edit-dir-locals:The
dir-locals-filename is currently hard-coded as".dir-locals.el", which does not takedir-locals-file-2or MS-DOS limitations into account.The
dir-locals-fileis expanded relative to(projectile-project-root)and thus does not support nesteddir-locals-files.Steps to reproduce the problem
Environment & Version information
Projectile version information
Emacs version
Operating system
Request for Comments
The following suggestions address some of the aforementioned limitations.
dir-locals-fileby default, e.g.The user could be offered a list of all
dir-locals-files found betweendefault-directoryand(projectile-project-root).A customisation variable could determine whether to prefer the root vs nearest
dir-locals-filefound, whether to ask the user or whether to offer possible completions.If no
dir-locals-files are found, the user could be prompted for a directory in which to create one.I would appreciate feedback on the given issues and suggestions. I would also be happy to work on a patch for any ensuing decisions, if I am given some initial pointers.
Thank you for this excellent and useful package!