diff options
| author | Glenn Morris | 2013-04-26 00:25:45 -0700 |
|---|---|---|
| committer | Glenn Morris | 2013-04-26 00:25:45 -0700 |
| commit | e6ea1f6c9be4f70fe282a882a6d8e0da6e7098c5 (patch) | |
| tree | bce63077e9f95f9c3c60176b0f5fa341ae3aacb8 | |
| parent | 070ccca42d39cd3634a5d8af0da42e9c985eb0df (diff) | |
| download | emacs-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/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/emacs-lisp/shadow.el | 128 |
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 @@ | |||
| 1 | 2013-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 | |||
| 1 | 2013-04-26 Leo Liu <sdl.web@gmail.com> | 8 | 2013-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 | ||
| 208 | For example, suppose `load-path' is set to | 208 | For 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 | ||
| 212 | and that each of these directories contains a file called XXX.el. Then | 212 | and that each of these directories contains a file called XXX.el. Then |
| 213 | XXX.el in the site-lisp directory is referred to by all of: | 213 | XXX.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 | ||
| 216 | The first XXX.el file prevents Emacs from seeing the second \(unless | 216 | The first XXX.el file prevents Emacs from seeing the second (unless |
| 217 | the second is loaded explicitly via `load-file'\). | 217 | the second is loaded explicitly via `load-file'). |
| 218 | 218 | ||
| 219 | When not intended, such shadowings can be the source of subtle | 219 | When not intended, such shadowings can be the source of subtle |
| 220 | problems. For example, the above situation may have arisen because the | 220 | problems. For example, the above situation may have arisen because the |
| 221 | XXX package was not distributed with versions of Emacs prior to | 221 | XXX package was not distributed with versions of Emacs prior to |
| 222 | 19.30. An Emacs maintainer downloaded XXX from elsewhere and installed | 222 | 24.3. A system administrator downloaded XXX from elsewhere and installed |
| 223 | it. Later, XXX was updated and included in the Emacs distribution. | 223 | it. Later, XXX was updated and included in the Emacs distribution. |
| 224 | Unless the Emacs maintainer checks for this, the new version of XXX | 224 | Unless the system administrator checks for this, the new version of XXX |
| 225 | will be hidden behind the old \(which may no longer work with the new | 225 | will be hidden behind the old (which may no longer work with the new |
| 226 | Emacs version\). | 226 | Emacs version). |
| 227 | 227 | ||
| 228 | This function performs these checks and flags all possible | 228 | This function performs these checks and flags all possible |
| 229 | shadowings. Because a .el file may exist without a corresponding .elc | 229 | shadowings. 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 |
| 231 | XXX.elc in an early directory \(that does not contain XXX.el\) is | 231 | XXX.elc in an early directory (that does not contain XXX.el) is |
| 232 | considered to shadow a later file XXX.el, and vice-versa. | 232 | considered to shadow a later file XXX.el, and vice-versa. |
| 233 | 233 | ||
| 234 | Shadowings are located by calling the (non-interactive) companion | 234 | Shadowings are located by calling the (non-interactive) companion |
| 235 | function, `load-path-shadows-find'." | 235 | function, `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. | ||
| 294 | If a locally-installed Lisp library overrides a library in the Emacs release, | 272 | If a locally-installed Lisp library overrides a library in the Emacs release, |
| 295 | that can cause trouble, and you should probably remove the locally-installed | 273 | that can cause trouble, and you should probably remove the locally-installed |
| 296 | version unless you know what you are doing.\n") | 274 | version 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 | ||