From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Xue Fuqiao Newsgroups: gmane.emacs.bugs Subject: bug#12357: 24.2; list-load-path-shadow should ignore .dir-locals.el Date: Wed, 26 Feb 2014 16:49:22 +0800 Organization: The Church of Emacs Message-ID: <87y50yqmwd.fsf@gnu.org> References: <87harcsi6n.fsf@bredband.net> <87ipbor4jg.fsf@bredband.net> <871ui1lrtk.fsf@bredband.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1393404602 19474 80.91.229.3 (26 Feb 2014 08:50:02 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 26 Feb 2014 08:50:02 +0000 (UTC) To: 12357@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Feb 26 09:50:11 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WIaBt-0005bz-KD for geb-bug-gnu-emacs@m.gmane.org; Wed, 26 Feb 2014 09:50:09 +0100 Original-Received: from localhost ([::1]:39139 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WIaBt-0000po-9Z for geb-bug-gnu-emacs@m.gmane.org; Wed, 26 Feb 2014 03:50:09 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52231) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WIaBo-0000jK-OJ for bug-gnu-emacs@gnu.org; Wed, 26 Feb 2014 03:50:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WIaBn-0003N2-P4 for bug-gnu-emacs@gnu.org; Wed, 26 Feb 2014 03:50:04 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:39158) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WIaBn-0003Mc-LN for bug-gnu-emacs@gnu.org; Wed, 26 Feb 2014 03:50:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1WIaBn-0004ig-0f for bug-gnu-emacs@gnu.org; Wed, 26 Feb 2014 03:50:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Xue Fuqiao Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 26 Feb 2014 08:50:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12357 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 12357-submit@debbugs.gnu.org id=B12357.139340457218097 (code B ref 12357); Wed, 26 Feb 2014 08:50:02 +0000 Original-Received: (at 12357) by debbugs.gnu.org; 26 Feb 2014 08:49:32 +0000 Original-Received: from localhost ([127.0.0.1]:40340 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WIaBH-0004hp-Vm for submit@debbugs.gnu.org; Wed, 26 Feb 2014 03:49:32 -0500 Original-Received: from fencepost.gnu.org ([208.118.235.10]:37596) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WIaBF-0004ha-QP for 12357@debbugs.gnu.org; Wed, 26 Feb 2014 03:49:30 -0500 Original-Received: from [123.114.125.233] (port=45821 helo=xfq-ThinkPad-X1-Carbon) by fencepost.gnu.org with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1WIaBD-00011R-68; Wed, 26 Feb 2014 03:49:28 -0500 In-Reply-To: <871ui1lrtk.fsf@bredband.net> (Johan Claesson's message of "Sun, 16 Sep 2012 20:56:39 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:86241 Archived-At: Johan Claesson 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/