aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/files.el
diff options
context:
space:
mode:
authorGlenn Morris <[email protected]>2012-03-05 21:50:28 -0500
committerGlenn Morris <[email protected]>2012-03-05 21:50:28 -0500
commit8f2114eef3d9efca0f5de7076a165d104c47fc1e (patch)
tree845b1fad7f84797eacc30a006bc7f6215b6cff9c /lisp/files.el
parenteb18244605c440f79caf2d46edad2734a438dbb7 (diff)
dir-locals-find-file tweak for "odd" .dir-locals.el (bug#10928)
* lisp/files.el (dir-locals-find-file): Ignore non-readable or non-regular files.
Diffstat (limited to 'lisp/files.el')
-rw-r--r--lisp/files.el14
1 files changed, 12 insertions, 2 deletions
diff --git a/lisp/files.el b/lisp/files.el
index d9a3e4b0f7..fae834daef 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -910,6 +910,10 @@ it is readable, regular, etc., you should test the result."
;; (setq user (nth 2 (file-attributes file)))
;; (and prev-user (not (equal user prev-user))))
(string-match locate-dominating-stop-dir-regexp file)))
+ ;; FIXME? maybe this function should (optionally?)
+ ;; use file-readable-p instead. In many cases, an unreadable
+ ;; FILE is no better than a non-existent one.
+ ;; See eg dir-locals-find-file.
(setq try (file-exists-p (expand-file-name name file)))
(cond (try (setq root file))
((equal file (setq file (file-name-directory
@@ -3569,8 +3573,14 @@ of no valid cache entry."
(locals-file (locate-dominating-file file dir-locals-file-name))
(dir-elt nil))
;; `locate-dominating-file' may have abbreviated the name.
- (if locals-file
- (setq locals-file (expand-file-name dir-locals-file-name locals-file)))
+ (and locals-file
+ (setq locals-file (expand-file-name dir-locals-file-name locals-file))
+ ;; FIXME? is it right to silently ignore an unreadable file?
+ ;; Maybe we'd want to keep searching in that case.
+ ;; That is a locate-dominating-file issue.
+ (or (not (file-readable-p locals-file))
+ (not (file-regular-p locals-file)))
+ (setq locals-file nil))
;; Find the best cached value in `dir-locals-directory-cache'.
(dolist (elt dir-locals-directory-cache)
(when (and (eq t (compare-strings file nil (length (car elt))