annotate lisp/shadow.el @ 312:d1b52dcaa789 r21-0b54

Import from CVS: tag r21-0b54
author cvs
date Mon, 13 Aug 2007 10:43:55 +0200
parents 0e522484dd2a
children 6240c7796c7a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
1 ;;; shadow.el --- Locate Emacs Lisp file shadowings.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
2
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
3 ;; Copyright (C) 1995 Free Software Foundation, Inc.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
4
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
5 ;; Author: Terry Jones <terry@santafe.edu>
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
6 ;; Keywords: lisp
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
7 ;; Created: 15 December 1995
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
8
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
10
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
14 ;; any later version.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
15
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
19 ;; GNU General Public License for more details.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
20
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
24 ;; Boston, MA 02111-1307, USA.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
25
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
26 ;;; Commentary:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
27
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
28 ;; The functions in this file detect (`find-emacs-lisp-shadows')
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
29 ;; and display (`list-load-path-shadows') potential load-path
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
30 ;; problems that arise when Emacs Lisp files "shadow" each other.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
31 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
32 ;; For example, a file XXX.el early in one's load-path will shadow
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
33 ;; a file with the same name in a later load-path directory. When
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
34 ;; this is unintentional, it may result in problems that could have
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
35 ;; been easily avoided. This occurs often (to me) when installing a
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
36 ;; new version of emacs and something in the site-lisp directory
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
37 ;; has been updated and added to the emacs distribution. The old
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
38 ;; version, now outdated, shadows the new one. This is obviously
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
39 ;; undesirable.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
40 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
41 ;; The `list-load-path-shadows' function was run when you installed
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
42 ;; this version of emacs. To run it by hand in emacs:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
43 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
44 ;; M-x load-library RET shadow RET
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
45 ;; M-x list-load-path-shadows
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
46 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
47 ;; or run it non-interactively via:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
48 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
49 ;; emacs -batch -l shadow.el -f list-load-path-shadows
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
50 ;;
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
51 ;; Thanks to Francesco Potorti` <pot@cnuce.cnr.it> for suggestions,
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
52 ;; rewritings & speedups.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
53
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
54 ;;; Code:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
55
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
56 (defun find-emacs-lisp-shadows (&optional path)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
57 "Return a list of Emacs Lisp files that create shadows.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
58 This function does the work for `list-load-path-shadows'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
59
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
60 We traverse PATH looking for shadows, and return a \(possibly empty\)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
61 even-length list of files. A file in this list at position 2i shadows
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
62 the file in position 2i+1. Emacs Lisp file suffixes \(.el and .elc\)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
63 are stripped from the file names in the list.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
64
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
65 See the documentation for `list-load-path-shadows' for further information."
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
66
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
67 (or path (setq path load-path))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
68
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
69 (let (true-names ; List of dirs considered.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
70 shadows ; List of shadowings, to be returned.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
71 files ; File names ever seen, with dirs.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
72 dir ; The dir being currently scanned.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
73 curr-files ; This dir's Emacs Lisp files.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
74 orig-dir ; Where the file was first seen.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
75 files-seen-this-dir ; Files seen so far in this dir.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
76 file) ; The current file.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
77
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
78
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
79 (while path
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
80
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
81 (setq dir (file-truename (or (car path) ".")))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
82 (if (member dir true-names)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
83 ;; We have already considered this PATH redundant directory.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
84 ;; Show the redundancy if we are interactiver, unless the PATH
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
85 ;; dir is nil or "." (these redundant directories are just a
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
86 ;; result of the current working directory, and are therefore
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
87 ;; not always redundant).
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
88 (or noninteractive
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
89 (and (car path)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
90 (not (string= (car path) "."))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
91 (message "Ignoring redundant directory %s" (car path))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
92
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
93 (setq true-names (append true-names (list dir)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
94 (setq dir (or (car path) "."))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
95 (setq curr-files (if (file-accessible-directory-p dir)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
96 (directory-files dir nil ".\\.elc?$" t)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
97 (and curr-files
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
98 (not noninteractive)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
99 (message "Checking %d files in %s..." (length curr-files) dir))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
100
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
101 (setq files-seen-this-dir nil)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
102
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
103 (while curr-files
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
104
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
105 (setq file (car curr-files))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
106 (setq file (substring
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
107 file 0 (if (string= (substring file -1) "c") -4 -3)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
108
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
109 ;; FILE now contains the current file name, with no suffix.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
110 (unless (or (member file files-seen-this-dir)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
111 ;; Ignore these files.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
112 (member file
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
113 '("subdirs"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
114 "auto-autoloads"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
115 "custom-load"
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 217
diff changeset
116 "dumped-lisp"
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 217
diff changeset
117 "_pkg"
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
118 "lpath")))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
119 ;; File has not been seen yet in this directory.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
120 ;; This test prevents us declaring that XXX.el shadows
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
121 ;; XXX.elc (or vice-versa) when they are in the same directory.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
122 (setq files-seen-this-dir (cons file files-seen-this-dir))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
123
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
124 (if (setq orig-dir (assoc file files))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
125 ;; This file was seen before, we have a shadowing.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
126 (setq shadows
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
127 (append shadows
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
128 (list (concat (file-name-as-directory (cdr orig-dir))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
129 file)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
130 (concat (file-name-as-directory dir)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
131 file))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
132
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
133 ;; Not seen before, add it to the list of seen files.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
134 (setq files (cons (cons file dir) files))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
135
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
136 (setq curr-files (cdr curr-files))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
137 (setq path (cdr path)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
138
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
139 ;; Return the list of shadowings.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
140 shadows))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
141
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
142
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
143 ;;;###autoload
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
144 (defun list-load-path-shadows ()
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
145 "Display a list of Emacs Lisp files that shadow other files.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
146
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
147 This function lists potential load-path problems. Directories in the
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
148 `load-path' variable are searched, in order, for Emacs Lisp
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
149 files. When a previously encountered file name is found again, a
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
150 message is displayed indicating that the later file is \"hidden\" by
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
151 the earlier.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
152
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
153 For example, suppose `load-path' is set to
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
154
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
155 \(\"/usr/gnu/emacs/site-lisp\" \"/usr/gnu/emacs/share/emacs/19.30/lisp\"\)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
156
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
157 and that each of these directories contains a file called XXX.el. Then
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
158 XXX.el in the site-lisp directory is referred to by all of:
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
159 \(require 'XXX\), \(autoload .... \"XXX\"\), \(load-library \"XXX\"\) etc.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
160
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
161 The first XXX.el file prevents emacs from seeing the second \(unless
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
162 the second is loaded explicitly via load-file\).
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
163
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
164 When not intended, such shadowings can be the source of subtle
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
165 problems. For example, the above situation may have arisen because the
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
166 XXX package was not distributed with versions of emacs prior to
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
167 19.30. An emacs maintainer downloaded XXX from elsewhere and installed
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
168 it. Later, XXX was updated and included in the emacs distribution.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
169 Unless the emacs maintainer checks for this, the new version of XXX
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
170 will be hidden behind the old \(which may no longer work with the new
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
171 emacs version\).
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
172
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
173 This function performs these checks and flags all possible
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
174 shadowings. Because a .el file may exist without a corresponding .elc
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
175 \(or vice-versa\), these suffixes are essentially ignored. A file
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
176 XXX.elc in an early directory \(that does not contain XXX.el\) is
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
177 considered to shadow a later file XXX.el, and vice-versa.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
178
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
179 When run interactively, the shadowings \(if any\) are displayed in a
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
180 buffer called `*Shadows*'. Shadowings are located by calling the
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
181 \(non-interactive\) companion function, `find-emacs-lisp-shadows'."
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
182
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
183 (interactive)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
184 (let* ((path (copy-sequence load-path))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
185 (tem path)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
186 toplevs)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
187 ;; If we can find simple.el in two places,
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
188 (while tem
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
189 (if (file-exists-p (expand-file-name "simple.el" (car tem)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
190 (setq toplevs (cons (car tem) toplevs)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
191 (setq tem (cdr tem)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
192 (if (> (length toplevs) 1)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
193 ;; Cut off our copy of load-path right before
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
194 ;; the second directory which has simple.el in it.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
195 ;; This avoids loads of duplications between the source dir
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
196 ;; and the dir where these files were copied by installation.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
197 (let ((break (nth (- (length toplevs) 2) toplevs)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
198 (setq tem path)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
199 (while tem
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
200 (if (eq (nth 1 tem) break)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
201 (progn
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
202 (setcdr tem nil)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
203 (setq tem nil)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
204 (setq tem (cdr tem)))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
205
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
206 (let* ((shadows (find-emacs-lisp-shadows path))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
207 (n (/ (length shadows) 2))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
208 (msg (format "%s Emacs Lisp load-path shadowing%s found"
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
209 (if (zerop n) "No" (concat "\n" (number-to-string n)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
210 (if (= n 1) " was" "s were"))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
211 (if (interactive-p)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
212 (save-excursion
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
213 ;; We are interactive.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
214 ;; Create the *Shadows* buffer and display shadowings there.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
215 (let ((output-buffer (get-buffer-create "*Shadows*")))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
216 (display-buffer output-buffer)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
217 (set-buffer output-buffer)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
218 (erase-buffer)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
219 (while shadows
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
220 (insert (format "%s hides %s\n" (car shadows)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
221 (car (cdr shadows))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
222 (setq shadows (cdr (cdr shadows))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
223 (insert msg "\n")))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
224 ;; We are non-interactive, print shadows via message.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
225 (when shadows
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
226 (message "This site has duplicate Lisp libraries with the same name.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
227 If a locally-installed Lisp library overrides a library in the Emacs release,
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
228 that can cause trouble, and you should probably remove the locally-installed
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
229 version unless you know what you are doing.\n")
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
230 (while shadows
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
231 (message "%s hides %s" (car shadows) (car (cdr shadows)))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
232 (setq shadows (cdr (cdr shadows))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
233 (message "%s" msg))))))
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
234
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
235 (provide 'shadow)
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
236
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents:
diff changeset
237 ;;; shadow.el ends here