]> code.delx.au - gnu-emacs/blobdiff - lisp/files-x.el
Fix Bug#20637. Do not merge to master
[gnu-emacs] / lisp / files-x.el
index cf9fe914ed49a60fdda527a84c10cbcae6ccc58e..f0102fd83afc0aabe829368b44dbf6824dab4db1 100644 (file)
@@ -1,6 +1,6 @@
 ;;; files-x.el --- extended file handling commands
 
-;; Copyright (C) 2009-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
 
 ;; Author: Juri Linkov <juri@jurta.org>
 ;; Maintainer: emacs-devel@gnu.org
@@ -429,25 +429,18 @@ 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 (and (buffer-file-name)
-                               (not (file-remote-p (buffer-file-name)))
-                               (dir-locals-find-file (buffer-file-name))))
+    (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))
          variables)
-      (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)))))
+      (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))))
       ;; 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.