]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/files.el (dir-locals--all-files): Use completion instead of wildcards
authorArtur Malabarba <bruce.connor.am@gmail.com>
Sat, 16 Jan 2016 08:50:46 +0000 (08:50 +0000)
committerArtur Malabarba <bruce.connor.am@gmail.com>
Sat, 16 Jan 2016 08:53:33 +0000 (08:53 +0000)
(dir-locals-file)
* lisp/files-x.el (modify-dir-local-variable)
* lisp/dos-fns.el (dosified-file-name)
* lisp/help-fns.el (describe-variable): Change accordingly.

lisp/dos-fns.el
lisp/files-x.el
lisp/files.el
lisp/help-fns.el

index 7defb388b74b3c5ad3857e2acc2ae86354265966..0ce2b23527dc5572d5e8f7d73415b0d377d149db 100644 (file)
@@ -201,8 +201,8 @@ that are used in Emacs Lisp sources; any other file name will be
 returned unaltered."
   (cond
    ;; See files.el:dir-locals-file.
-   ((string= file-name ".dir-locals.el")
-    "_dir-locals.el")
+   ((string= file-name ".dir-locals")
+    "_dir-locals")
    (t
     file-name)))
 
index ed3d49df38560e0887bfa611662fb50042b11a75..2e1a728356e4814ac97112ca321ce53e0667143e 100644 (file)
@@ -444,10 +444,8 @@ from the MODE alist ignoring the input argument VALUE."
                    (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)))))
+                  ;; Try to make a proper file-name.
+                  (t (concat dir-locals-file ".el"))))
       ;; 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.
index 9cb46fcd0a9382e07862a14c3fe4aa82465282f3..7c6119b7ef9b98a9de250c4b7c842ed0deb6d6d0 100644 (file)
@@ -3713,7 +3713,7 @@ VARIABLES list of the class.  The list is processed in order.
   applied by recursively following these rules."
   (setf (alist-get class dir-locals-class-alist) variables))
 
-(defconst dir-locals-file ".dir-locals*.el"
+(defconst dir-locals-file ".dir-locals"
   "Pattern for files that contain directory-local variables.
 It has to be constant to enforce uniform values across different
 environments and users.
@@ -3730,16 +3730,19 @@ return a sorted list of all files matching `dir-locals-file' in
 this directory.
 The returned list is sorted by `string<' order."
   (require 'seq)
-  (let ((default-directory (if (file-directory-p file-or-dir)
-                               file-or-dir
-                             default-directory)))
+  (let ((dir (if (file-directory-p file-or-dir)
+                 file-or-dir
+               default-directory))
+        (file (cond ((not (file-directory-p file-or-dir)) file-or-dir)
+                    ((eq system-type 'ms-dos) (dosified-file-name dir-locals-file))
+                    (t dir-locals-file))))
     (seq-filter (lambda (f) (and (file-readable-p f)
-                            (file-regular-p f)))
-                (file-expand-wildcards
-                 (cond ((not (file-directory-p file-or-dir)) file-or-dir)
-                       ((eq system-type 'ms-dos) (dosified-file-name dir-locals-file))
-                       (t dir-locals-file))
-                 'full))))
+                            (file-regular-p f)
+                            (not (file-directory-p f))))
+                (mapcar (lambda (f) (expand-file-name f dir))
+                        (nreverse
+                         (let ((completion-regexp-list '("\\.el\\'")))
+                           (file-name-all-completions file dir)))))))
 
 (defun dir-locals-find-file (file)
   "Find the directory-local variables for FILE.
index bc96601a45c8cde7f6388e7ae350950cfae755cf..13daafb0f2067f876449032adccb8be6fe050014 100644 (file)
@@ -918,25 +918,24 @@ if it is given a local binding.\n"))))
                         ;; If the cache element has an mtime, we
                         ;; assume it came from a file.
                         (if (nth 2 file)
-                            (setq file (expand-file-name
-                                        dir-locals-file (car file)))
+                            ;; (car file) is a directory.
+                            (setq file (dir-locals--all-files (car file)))
                           ;; Otherwise, assume it was set directly.
                           (setq file (car file)
                                 is-directory t)))
                       (if (null file)
                           (princ ".\n")
                         (princ ", set ")
-                        (let ((files (file-expand-wildcards file)))
-                          (princ (substitute-command-keys
-                                  (cond
-                                   (is-directory "for the directory\n  `")
-                                   ;; Many files matched.
-                                   ((cdr files)
-                                    (setq file (file-name-directory (car files)))
-                                    (format "by a file\n  matching `%s' in the directory\n  `"
-                                            dir-locals-file))
-                                   (t (setq file (car files))
-                                      "by the file\n  `"))))
+                        (princ (substitute-command-keys
+                                (cond
+                                 (is-directory "for the directory\n  `")
+                                 ;; Many files matched.
+                                 ((and (consp file) (cdr file))
+                                  (setq file (file-name-directory (car file)))
+                                  (format "by one of the\n  %s files in the directory\n  `"
+                                          dir-locals-file))
+                                 (t (setq file (car file))
+                                    "by the file\n  `"))))
                        (with-current-buffer standard-output
                          (insert-text-button
                           file 'type 'help-dir-local-var-def