GNU bug report logs - #12357
24.2; list-load-path-shadow should ignore .dir-locals.el

Previous Next

Package: emacs;

Reported by: Johan Claesson <johanclaesson <at> bredband.net>

Date: Wed, 5 Sep 2012 15:54:02 UTC

Severity: minor

Tags: patch

Found in version 24.2

Fixed in version 24.4

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Xue Fuqiao <xfq <at> gnu.org>
To: 12357 <at> debbugs.gnu.org
Cc: Glenn Morris <rgm <at> gnu.org>, Johan Claesson <johanclaesson <at> bredband.net>
Subject: bug#12357: 24.2; list-load-path-shadow should ignore .dir-locals.el
Date: Wed, 26 Feb 2014 16:49:22 +0800
Johan Claesson <johanclaesson <at> bredband.net> writes:

> A command to search for .dir-local.el shadows could look something like
> below.

Looks fine to me.  I made a patch (and tested it).  Any comments?

(I haven't written the documentation/ChangeLog/NEWS yet.)

=== modified file 'lisp/emacs-lisp/shadow.el'
--- lisp/emacs-lisp/shadow.el	2014-01-01 07:43:34 +0000
+++ lisp/emacs-lisp/shadow.el	2014-02-26 08:38:54 +0000
@@ -115,7 +115,8 @@
 	  ;; FILE now contains the current file name, with no suffix.
 	  (unless (or (member file files-seen-this-dir)
 		      ;; Ignore these files.
-		      (member file '("subdirs" "leim-list")))
+		      (member file '("subdirs" "leim-list"))
+		      (string= file (file-name-sans-extension dir-locals-file)))
 	    ;; File has not been seen yet in this directory.
 	    ;; This test prevents us declaring that XXX.el shadows
 	    ;; XXX.elc (or vice-versa) when they are in the same directory.
@@ -281,6 +282,49 @@
 	      (forward-line 1))
 	    (message "%s" msg)))))))
 
+
+
+(defun list-load-path-dir-locals-shadows ()
+  "Display a list of dir-local files that shadow other files."
+  (interactive)
+  (dir-locals-shadows load-path))
+
+(defun dir-locals-shadows (path)
+  "Display a list of dir-local files that shadow other files under PATH."
+  (when (stringp path)
+    (setq path (list path)))
+  (with-current-buffer (get-buffer-create "*Dir-Locals-Shadows*")
+    (erase-buffer)
+    (dolist (dir path)
+      (dir-locals-shadows-1 dir (dir-locals-find-file (file-name-as-directory dir))))
+    (if (> (point-max) (point-min))
+        (display-buffer (current-buffer))
+      (kill-buffer (current-buffer))
+      (message "No dir-local shadows found."))))
+
+(defun dir-locals-class-name (class)
+  (if (stringp class)
+      class
+    (if (file-name-directory (symbol-name (cadr class)))
+        (concat (car class) dir-locals-file)
+      (format "%s%s (class %s)" (car class) dir-locals-file (cadr class)))))
+
+(defun dir-locals-shadows-1 (dir locals)
+  "Auxiliary function for `dir-locals-shadows'."
+  (dolist (file (directory-files dir nil nil 'no-sort))
+    (let ((subdir (expand-file-name file dir)))
+      (when (and (file-directory-p subdir)
+                 (not (or (string-equal file ".")
+                          (string-equal file "..")
+                          (file-symlink-p subdir))))
+        (let ((subdir-locals (dir-locals-find-file (file-name-as-directory subdir))))
+          (and locals
+               (not (equal locals subdir-locals))
+               (insert (format "%s shadows %s\n"
+                               (dir-locals-class-name subdir-locals)
+                               (dir-locals-class-name locals))))
+          (dir-locals-shadows-1 subdir subdir-locals))))))
+
 (provide 'shadow)
 
 ;;; shadow.el ends here

-- 
http://www.gnu.org/software/emacs/




This bug report was last modified 11 years and 84 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.