mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2025-01-07 15:06:22 +00:00
* 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.
This commit is contained in:
parent
86e4513969
commit
f0b82b3453
@ -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)))
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user