Function: read-dir-locals-file

read-dir-locals-file is a byte-compiled function defined in files-x.el.gz.

Signature

(read-dir-locals-file)

Documentation

Read a dir-locals filename using completion.

Intended to be used in the interactive spec of add-dir-local-variable, delete-dir-local-variable and copy-file-locals-to-dir-locals.

Returns the filename, expanded.

Source Code

;; Defined in /usr/src/emacs/lisp/files-x.el.gz
(defun read-dir-locals-file ()
  "Read a dir-locals filename using completion.
Intended to be used in the `interactive' spec of `add-dir-local-variable',
`delete-dir-local-variable' and `copy-file-locals-to-dir-locals'.

Returns the filename, expanded."
  (let* ((pri dir-locals-file)
         (sec (replace-regexp-in-string ".el$" "-2.el" dir-locals-file))
         (dir (or (locate-dominating-file default-directory pri)
                  (locate-dominating-file default-directory sec))))
    (expand-file-name
     (read-file-name
      "File: "
      (cond (dir)
            ((when-let ((proj (and (featurep 'project) (project-current))))
               (project-root proj))))
      nil
      (lambda (fname)
        (member (file-name-nondirectory fname) (list pri sec)))
      dir-locals-file))))