summaryrefslogtreecommitdiff
path: root/lisp/files-x.el
diff options
context:
space:
mode:
authorArtur Malabarba <bruce.connor.am@gmail.com>2015-11-07 13:54:56 +0000
committerArtur Malabarba <bruce.connor.am@gmail.com>2015-11-10 13:04:31 +0000
commit2e8488858c7b8df40610c1cd3038348fdc9bf3ed (patch)
tree071562f68f773d55bd40a4f861a0d90c5f4c9ddf /lisp/files-x.el
parentcbaa04014e0c9efdfc6393bccde0e6579b5d7051 (diff)
downloademacs-2e8488858c7b8df40610c1cd3038348fdc9bf3ed.tar.gz
* lisp/files.el (dir-locals-file): Allow wildcards
(dir-locals-find-file, dir-locals-collect-variables) (dir-locals-read-from-file): Update accordingly. (hack-dir-local-variables): Rename a local variable. * lisp/files-x.el (modify-dir-local-variable): Update accordingly * lisp/help-fns.el (describe-variable): Update accordingly * .gitignore: Add .dir-locals?.el
Diffstat (limited to 'lisp/files-x.el')
-rw-r--r--lisp/files-x.el29
1 files changed, 18 insertions, 11 deletions
diff --git a/lisp/files-x.el b/lisp/files-x.el
index a130ffcf928..cf9fe914ed4 100644
--- a/lisp/files-x.el
+++ b/lisp/files-x.el
@@ -429,18 +429,25 @@ from the MODE alist ignoring the input argument VALUE."
(catch 'exit
(unless enable-local-variables
(throw 'exit (message "Directory-local variables are disabled")))
- (let ((variables-file (or (and (buffer-file-name)
- (not (file-remote-p (buffer-file-name)))
- (dir-locals-find-file (buffer-file-name)))
- dir-locals-file))
+ (let ((variables-file (and (buffer-file-name)
+ (not (file-remote-p (buffer-file-name)))
+ (dir-locals-find-file (buffer-file-name))))
variables)
- (if (consp variables-file) ; result from cache
- ;; If cache element has an mtime, assume it came from a file.
- ;; Otherwise, assume it was set directly.
- (setq variables-file (if (nth 2 variables-file)
- (expand-file-name dir-locals-file
- (car variables-file))
- (cadr variables-file))))
+ (setq variables-file
+ ;; If there are several .dir-locals, the user probably
+ ;; wants to edit the last one (the highest priority).
+ (cond ((stringp variables-file)
+ (car (last (dir-locals--all-files variables-file))))
+ ((consp variables-file) ; result from cache
+ ;; If cache element has an mtime, assume it came from a file.
+ ;; Otherwise, assume it was set directly.
+ (if (nth 2 variables-file)
+ (car (last (dir-locals--all-files (car variables-file))))
+ (cadr variables-file)))
+ ;; Try to make a proper file-name. This doesn't cover all
+ ;; wildcards, but it covers the default value of `dir-locals-file'.
+ (t (replace-regexp-in-string
+ "\\*" "" (replace-regexp-in-string "\\?" "-" dir-locals-file)))))
;; I can't be bothered to handle this case right now.
;; Dir locals were set directly from a class. You need to
;; directly modify the class in dir-locals-class-alist.