Function: load-path-shadows-find
load-path-shadows-find is a byte-compiled function defined in
shadow.el.gz.
Signature
(load-path-shadows-find &optional PATH)
Documentation
Return a list of Emacs Lisp files that create shadows.
This function does the work for list-load-path-shadows.
We traverse PATH looking for shadows, and return a (possibly empty) even-length list of files. A file in this list at position 2i shadows the file in position 2i+1. Emacs Lisp file suffixes (.el and .elc) are stripped from the file names in the list.
See the documentation for list-load-path-shadows for further information.
Aliases
find-emacs-lisp-shadows (obsolete since 23.3)
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/shadow.el.gz
(defun load-path-shadows-find (&optional path)
"Return a list of Emacs Lisp files that create shadows.
This function does the work for `list-load-path-shadows'.
We traverse PATH looking for shadows, and return a \(possibly empty)
even-length list of files. A file in this list at position 2i shadows
the file in position 2i+1. Emacs Lisp file suffixes \(.el and .elc)
are stripped from the file names in the list.
See the documentation for `list-load-path-shadows' for further information."
(let (true-names ; List of dirs considered.
shadows ; List of shadowings, to be returned.
files ; File names ever seen, with dirs.
dir ; The dir being currently scanned.
dir-case-insensitive ; `file-name-case-insensitive-p' of dir.
curr-files ; This dir's Emacs Lisp files.
orig-dir ; Where the file was first seen.
files-seen-this-dir) ; Files seen so far in this dir.
(dolist (pp (or path load-path))
(setq dir (directory-file-name (file-truename (or pp "."))))
(if (member dir true-names)
;; We have already considered this PATH redundant directory.
;; Show the redundancy if we are interactive, unless the PATH
;; dir is nil or "." (these redundant directories are just a
;; result of the current working directory, and are therefore
;; not always redundant).
(or noninteractive
(and pp
(not (string= pp "."))
(message "Ignoring redundant directory %s" pp)))
(setq true-names (append true-names (list dir)))
(setq dir (directory-file-name (or pp ".")))
(setq curr-files (if (file-accessible-directory-p dir)
(directory-files dir nil
"\\.elc?\\(?:\\.gz\\)?\\'" t)))
(and curr-files
(not noninteractive)
(message "Checking %d files in %s..." (length curr-files) dir))
(setq files-seen-this-dir nil)
;; We assume that case sensitivity of a directory applies to
;; its files.
(setq dir-case-insensitive (file-name-case-insensitive-p dir))
(dolist (file curr-files)
(if (string-match "\\.gz\\'" file)
(setq file (substring file 0 -3)))
(setq file (substring
file 0 (if (string= (substring file -1) "c") -4 -3)))
;; FILE now contains the current file name, with no suffix.
(unless (or (member file files-seen-this-dir)
;; Ignore these files.
(member file
(list "subdirs" "leim-list"
(file-name-sans-extension dir-locals-file)
(concat
(file-name-sans-extension dir-locals-file)
"-2"))))
;; 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.
(setq files-seen-this-dir (cons file files-seen-this-dir))
(if (setq orig-dir
(assoc file files
(when dir-case-insensitive
(lambda (f1 f2)
(eq (compare-strings f1 nil nil
f2 nil nil t)
t)))))
;; This file was seen before, we have a shadowing.
;; Report it unless the files are identical.
(let ((base1 (concat (cdr orig-dir) "/" (car orig-dir)))
(base2 (concat dir "/" file)))
(if (not (and load-path-shadows-compare-text
(load-path-shadows-same-file-or-nonexistent
(concat base1 ".el") (concat base2 ".el"))
;; This is a bit strict, but safe.
(load-path-shadows-same-file-or-nonexistent
(concat base1 ".elc") (concat base2 ".elc"))))
(setq shadows
(append shadows (list base1 base2)))))
;; Not seen before, add it to the list of seen files.
(push (cons file dir) files))))))
;; Return the list of shadowings.
shadows))