aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2013-04-26 00:25:45 -0700
committerGlenn Morris2013-04-26 00:25:45 -0700
commite6ea1f6c9be4f70fe282a882a6d8e0da6e7098c5 (patch)
treebce63077e9f95f9c3c60176b0f5fa341ae3aacb8
parent070ccca42d39cd3634a5d8af0da42e9c985eb0df (diff)
downloademacs-e6ea1f6c9be4f70fe282a882a6d8e0da6e7098c5.tar.gz
emacs-e6ea1f6c9be4f70fe282a882a6d8e0da6e7098c5.zip
list-load-path-shadows simplification
* lisp/emacs-lisp/shadow.el (list-load-path-shadows): No longer necessary to check for duplicate simple.el, since 2012-07-07 change to init_lread to not include installation lisp directories in load-path when running uninstalled. Fixes: debbugs:14270
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/emacs-lisp/shadow.el128
2 files changed, 60 insertions, 75 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index e7c374e1e96..b8c0f629042 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
12013-04-26 Glenn Morris <rgm@gnu.org>
2
3 * emacs-lisp/shadow.el (list-load-path-shadows):
4 No longer necessary to check for duplicate simple.el, since
5 2012-07-07 change to init_lread to not include installation lisp
6 directories in load-path when running uninstalled. (Bug#14270)
7
12013-04-26 Leo Liu <sdl.web@gmail.com> 82013-04-26 Leo Liu <sdl.web@gmail.com>
2 9
3 * progmodes/octave.el (octave-submit-bug-report): Obsolete. 10 * progmodes/octave.el (octave-submit-bug-report): Obsolete.
diff --git a/lisp/emacs-lisp/shadow.el b/lisp/emacs-lisp/shadow.el
index b12fba17027..d0e3c5763b5 100644
--- a/lisp/emacs-lisp/shadow.el
+++ b/lisp/emacs-lisp/shadow.el
@@ -207,101 +207,79 @@ the earlier.
207 207
208For example, suppose `load-path' is set to 208For example, suppose `load-path' is set to
209 209
210\(\"/usr/gnu/emacs/site-lisp\" \"/usr/gnu/emacs/share/emacs/19.30/lisp\"\) 210\(\"/usr/share/emacs/site-lisp\" \"/usr/share/emacs/24.3/lisp\")
211 211
212and that each of these directories contains a file called XXX.el. Then 212and that each of these directories contains a file called XXX.el. Then
213XXX.el in the site-lisp directory is referred to by all of: 213XXX.el in the site-lisp directory is referred to by all of:
214\(require 'XXX\), \(autoload .... \"XXX\"\), \(load-library \"XXX\"\) etc. 214\(require 'XXX), (autoload .... \"XXX\"), (load-library \"XXX\") etc.
215 215
216The first XXX.el file prevents Emacs from seeing the second \(unless 216The first XXX.el file prevents Emacs from seeing the second (unless
217the second is loaded explicitly via `load-file'\). 217the second is loaded explicitly via `load-file').
218 218
219When not intended, such shadowings can be the source of subtle 219When not intended, such shadowings can be the source of subtle
220problems. For example, the above situation may have arisen because the 220problems. For example, the above situation may have arisen because the
221XXX package was not distributed with versions of Emacs prior to 221XXX package was not distributed with versions of Emacs prior to
22219.30. An Emacs maintainer downloaded XXX from elsewhere and installed 22224.3. A system administrator downloaded XXX from elsewhere and installed
223it. Later, XXX was updated and included in the Emacs distribution. 223it. Later, XXX was updated and included in the Emacs distribution.
224Unless the Emacs maintainer checks for this, the new version of XXX 224Unless the system administrator checks for this, the new version of XXX
225will be hidden behind the old \(which may no longer work with the new 225will be hidden behind the old (which may no longer work with the new
226Emacs version\). 226Emacs version).
227 227
228This function performs these checks and flags all possible 228This function performs these checks and flags all possible
229shadowings. Because a .el file may exist without a corresponding .elc 229shadowings. Because a .el file may exist without a corresponding .elc
230\(or vice-versa\), these suffixes are essentially ignored. A file 230\(or vice-versa), these suffixes are essentially ignored. A file
231XXX.elc in an early directory \(that does not contain XXX.el\) is 231XXX.elc in an early directory (that does not contain XXX.el) is
232considered to shadow a later file XXX.el, and vice-versa. 232considered to shadow a later file XXX.el, and vice-versa.
233 233
234Shadowings are located by calling the (non-interactive) companion 234Shadowings are located by calling the (non-interactive) companion
235function, `load-path-shadows-find'." 235function, `load-path-shadows-find'."
236 (interactive) 236 (interactive)
237 (let* ((path (copy-sequence load-path)) 237 (let* ((shadows (load-path-shadows-find load-path))
238 (tem path) 238 (n (/ (length shadows) 2))
239 toplevs) 239 (msg (format "%s Emacs Lisp load-path shadowing%s found"
240 ;; If we can find simple.el in two places, 240 (if (zerop n) "No" (concat "\n" (number-to-string n)))
241 (dolist (tt tem) 241 (if (= n 1) " was" "s were"))))
242 (if (or (file-exists-p (expand-file-name "simple.el" tt)) 242 (with-temp-buffer
243 (file-exists-p (expand-file-name "simple.el.gz" tt))) 243 (while shadows
244 (setq toplevs (cons tt toplevs)))) 244 (insert (format "%s hides %s\n" (car shadows)
245 (if (> (length toplevs) 1) 245 (car (cdr shadows))))
246 ;; Cut off our copy of load-path right before 246 (setq shadows (cdr (cdr shadows))))
247 ;; the last directory which has simple.el in it. 247 (if stringp
248 ;; This avoids loads of duplications between the source dir 248 (buffer-string)
249 ;; and the dir where these files were copied by installation. 249 (if (called-interactively-p 'interactive)
250 (let ((break (car toplevs))) 250 ;; We are interactive.
251 (setq tem path) 251 ;; Create the *Shadows* buffer and display shadowings there.
252 (while tem 252 (let ((string (buffer-string)))
253 (if (eq (nth 1 tem) break) 253 (with-current-buffer (get-buffer-create "*Shadows*")
254 (progn 254 (display-buffer (current-buffer))
255 (setcdr tem nil) 255 (load-path-shadows-mode) ; run after-change-major-mode-hook
256 (setq tem nil))) 256 (let ((inhibit-read-only t))
257 (setq tem (cdr tem))))) 257 (erase-buffer)
258 258 (insert string)
259 (let* ((shadows (load-path-shadows-find path)) 259 (insert msg "\n")
260 (n (/ (length shadows) 2)) 260 (while (re-search-backward "\\(^.*\\) hides \\(.*$\\)"
261 (msg (format "%s Emacs Lisp load-path shadowing%s found" 261 nil t)
262 (if (zerop n) "No" (concat "\n" (number-to-string n))) 262 (dotimes (i 2)
263 (if (= n 1) " was" "s were")))) 263 (make-button (match-beginning (1+ i))
264 (with-temp-buffer 264 (match-end (1+ i))
265 (while shadows 265 'type 'load-path-shadows-find-file
266 (insert (format "%s hides %s\n" (car shadows) 266 'shadow-file
267 (car (cdr shadows)))) 267 (match-string (1+ i)))))
268 (setq shadows (cdr (cdr shadows)))) 268 (goto-char (point-max)))))
269 (if stringp 269 ;; We are non-interactive, print shadows via message.
270 (buffer-string) 270 (unless (zerop n)
271 (if (called-interactively-p 'interactive) 271 (message "This site has duplicate Lisp libraries with the same name.
272 ;; We are interactive.
273 ;; Create the *Shadows* buffer and display shadowings there.
274 (let ((string (buffer-string)))
275 (with-current-buffer (get-buffer-create "*Shadows*")
276 (display-buffer (current-buffer))
277 (load-path-shadows-mode) ; run after-change-major-mode-hook
278 (let ((inhibit-read-only t))
279 (erase-buffer)
280 (insert string)
281 (insert msg "\n")
282 (while (re-search-backward "\\(^.*\\) hides \\(.*$\\)"
283 nil t)
284 (dotimes (i 2)
285 (make-button (match-beginning (1+ i))
286 (match-end (1+ i))
287 'type 'load-path-shadows-find-file
288 'shadow-file
289 (match-string (1+ i)))))
290 (goto-char (point-max)))))
291 ;; We are non-interactive, print shadows via message.
292 (unless (zerop n)
293 (message "This site has duplicate Lisp libraries with the same name.
294If a locally-installed Lisp library overrides a library in the Emacs release, 272If a locally-installed Lisp library overrides a library in the Emacs release,
295that can cause trouble, and you should probably remove the locally-installed 273that can cause trouble, and you should probably remove the locally-installed
296version unless you know what you are doing.\n") 274version unless you know what you are doing.\n")
297 (goto-char (point-min)) 275 (goto-char (point-min))
298 ;; Mimic the previous behavior of using lots of messages. 276 ;; Mimic the previous behavior of using lots of messages.
299 ;; I think one single message would look better... 277 ;; I think one single message would look better...
300 (while (not (eobp)) 278 (while (not (eobp))
301 (message "%s" (buffer-substring (line-beginning-position) 279 (message "%s" (buffer-substring (line-beginning-position)
302 (line-end-position))) 280 (line-end-position)))
303 (forward-line 1)) 281 (forward-line 1))
304 (message "%s" msg)))))))) 282 (message "%s" msg)))))))
305 283
306(provide 'shadow) 284(provide 'shadow)
307 285