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)))
(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.
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.
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.
;; 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