From: Xue Fuqiao <xfq@gnu.org>
To: 12357@debbugs.gnu.org
Subject: bug#12357: 24.2; list-load-path-shadow should ignore .dir-locals.el
Date: Wed, 26 Feb 2014 16:49:22 +0800 [thread overview]
Message-ID: <87y50yqmwd.fsf@gnu.org> (raw)
In-Reply-To: <871ui1lrtk.fsf@bredband.net> (Johan Claesson's message of "Sun, 16 Sep 2012 20:56:39 +0200")
Johan Claesson <johanclaesson@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)))))))
+\f
+
+(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/
next prev parent reply other threads:[~2014-02-26 8:49 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-05 13:38 bug#12357: 24.2; list-load-path-shadow should ignore .dir-locals.el Johan Claesson
2012-09-05 16:23 ` Johan Claesson
2012-09-08 1:13 ` Glenn Morris
2012-09-08 14:08 ` Johan Claesson
2012-09-16 18:56 ` Johan Claesson
2014-02-26 8:49 ` Xue Fuqiao [this message]
2014-03-02 22:14 ` Johan Claesson
2014-03-02 22:36 ` Xue Fuqiao
2014-03-04 22:29 ` Johan Claesson
2014-03-05 0:54 ` Leo Liu
2014-03-05 7:09 ` Johan Claesson
2014-03-06 2:07 ` Glenn Morris
2014-03-06 21:58 ` Johan Claesson
2014-03-05 7:25 ` Johan Claesson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y50yqmwd.fsf@gnu.org \
--to=xfq@gnu.org \
--cc=12357@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).