emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r107514: dir-locals-find-file tweak f


From: Glenn Morris
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r107514: dir-locals-find-file tweak for "odd" .dir-locals.el (bug#10928)
Date: Mon, 05 Mar 2012 21:50:28 -0500
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 107514
committer: Glenn Morris <address@hidden>
branch nick: trunk
timestamp: Mon 2012-03-05 21:50:28 -0500
message:
  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.
modified:
  lisp/ChangeLog
  lisp/files.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-03-06 02:31:32 +0000
+++ b/lisp/ChangeLog    2012-03-06 02:50:28 +0000
@@ -1,5 +1,8 @@
 2012-03-06  Glenn Morris  <address@hidden>
 
+       * files.el (dir-locals-find-file):
+       Ignore non-readable or non-regular files.  (Bug#10928)
+
        * files.el (locate-dominating-file): Doc fix.
 
 2012-03-06  Adam Spiers  <address@hidden>  (tiny change)

=== modified file 'lisp/files.el'
--- a/lisp/files.el     2012-03-06 02:31:32 +0000
+++ b/lisp/files.el     2012-03-06 02:50:28 +0000
@@ -910,6 +910,10 @@
                     ;;   (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 @@
         (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))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]