From f0b82b34536e6bafbecbd642eee0cb0f534f8647 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sat, 16 Jan 2016 08:50:46 +0000 Subject: [PATCH] * lisp/files.el (dir-locals--all-files): Use completion instead of wildcards (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 | 4 ++-- lisp/files-x.el | 6 ++---- lisp/files.el | 23 +++++++++++++---------- lisp/help-fns.el | 25 ++++++++++++------------- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/lisp/dos-fns.el b/lisp/dos-fns.el index 7defb388b74..0ce2b23527d 100644 --- a/lisp/dos-fns.el +++ b/lisp/dos-fns.el @@ -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))) diff --git a/lisp/files-x.el b/lisp/files-x.el index ed3d49df385..2e1a728356e 100644 --- a/lisp/files-x.el +++ b/lisp/files-x.el @@ -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. diff --git a/lisp/files.el b/lisp/files.el index 9cb46fcd0a9..7c6119b7ef9 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -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. diff --git a/lisp/help-fns.el b/lisp/help-fns.el index bc96601a45c..13daafb0f20 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el @@ -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 -- 2.39.2