changeset 19313:04175c55c49b

(list-load-path-shadows): Exclude, from the path we search, all but the first set of directories that include the standard Emacs Lisp files.
author Richard M. Stallman <rms@gnu.org>
date Tue, 12 Aug 1997 05:30:47 +0000
parents d67c0dba233d
children 860783b225b9
files lisp/emacs-lisp/shadow.el
diffstat 1 files changed, 47 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/emacs-lisp/shadow.el	Tue Aug 12 00:58:44 1997 +0000
+++ b/lisp/emacs-lisp/shadow.el	Tue Aug 12 05:30:47 1997 +0000
@@ -173,34 +173,56 @@
 \(non-interactive\) companion function, `find-emacs-lisp-shadows'."
   
   (interactive)
-  (let* ((shadows (find-emacs-lisp-shadows))
-	 (n (/ (length shadows) 2))
-	 (msg (format "%s Emacs Lisp load-path shadowing%s found"
-		      (if (zerop n) "No" (concat "\n" (number-to-string n)))
-		      (if (= n 1) " was" "s were"))))
-    (if (interactive-p)
-	(save-excursion
-	  ;; We are interactive.
-	  ;; Create the *Shadows* buffer and display shadowings there.
-	  (let ((output-buffer (get-buffer-create "*Shadows*")))
-	    (display-buffer output-buffer)
-	    (set-buffer output-buffer)
-	    (erase-buffer)
-	    (while shadows
-	      (insert (format "%s hides %s\n" (car shadows)
-			      (car (cdr shadows))))
-	      (setq shadows (cdr (cdr shadows))))
-	    (insert msg "\n")))
-      ;; We are non-interactive, print shadows via message.
-      (when shadows
-	(message "This site has duplicate Lisp libraries with the same name.
+  (let* ((path (copy-sequence load-path))
+	(tem path)
+	toplevs)
+    ;; If we can find simple.el in two places,
+    (while tem
+      (if (file-exists-p (expand-file-name "simple.el" (car tem)))
+	  (setq toplevs (cons (car tem) toplevs)))
+      (setq tem (cdr tem)))
+    (if (> (length toplevs) 1)
+	;; Cut off our copy of load-path right before
+	;; the second directory which has simple.el in it.
+	;; This avoids loads of duplications between the source dir
+	;; and the dir where these files were copied by installation.
+	(let ((break (nth (- (length toplevs) 2) toplevs)))
+	  (setq tem path)
+	  (while tem
+	    (if (eq (nth 1 tem) break)
+		(progn
+		  (setcdr tem nil)
+		  (setq tem nil)))
+	    (setq tem (cdr tem)))))
+
+    (let* ((shadows (find-emacs-lisp-shadows path))
+	   (n (/ (length shadows) 2))
+	   (msg (format "%s Emacs Lisp load-path shadowing%s found"
+			(if (zerop n) "No" (concat "\n" (number-to-string n)))
+			(if (= n 1) " was" "s were"))))
+      (if (interactive-p)
+	  (save-excursion
+	    ;; We are interactive.
+	    ;; Create the *Shadows* buffer and display shadowings there.
+	    (let ((output-buffer (get-buffer-create "*Shadows*")))
+	      (display-buffer output-buffer)
+	      (set-buffer output-buffer)
+	      (erase-buffer)
+	      (while shadows
+		(insert (format "%s hides %s\n" (car shadows)
+				(car (cdr shadows))))
+		(setq shadows (cdr (cdr shadows))))
+	      (insert msg "\n")))
+	;; We are non-interactive, print shadows via message.
+	(when shadows
+	  (message "This site has duplicate Lisp libraries with the same name.
 If a locally-installed Lisp library overrides a library in the Emacs release,
 that can cause trouble, and you should probably remove the locally-installed
 version unless you know what you are doing.\n"))
-      (while shadows
-	(message "%s hides %s" (car shadows) (car (cdr shadows)))
-	(setq shadows (cdr (cdr shadows))))
-      (message "%s" msg))))
+	(while shadows
+	  (message "%s hides %s" (car shadows) (car (cdr shadows)))
+	  (setq shadows (cdr (cdr shadows))))
+	(message "%s" msg)))))
 
 (provide 'shadow)