summaryrefslogtreecommitdiff
path: root/lisp/files-x.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/files-x.el')
-rw-r--r--lisp/files-x.el27
1 files changed, 16 insertions, 11 deletions
diff --git a/lisp/files-x.el b/lisp/files-x.el
index a130ffcf928..dcd495db15a 100644
--- a/lisp/files-x.el
+++ b/lisp/files-x.el
@@ -429,18 +429,23 @@ 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 (file-expand-wildcards 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)
+ (let ((default-directory (car variables-file)))
+ (car (last (file-expand-wildcards dir-locals-file 'full))))
+ (cadr variables-file)))
+ (t 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.