aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2009-11-10 08:06:53 +0000
committerGlenn Morris2009-11-10 08:06:53 +0000
commitb16ff465dc11ec819bd3d20dd7003953c69b6178 (patch)
tree7c6d91878a174476e95fa0c4ae217a367f7588bd
parent1fb99a3a639af18a092a9591f577fbec92ca231c (diff)
downloademacs-b16ff465dc11ec819bd3d20dd7003953c69b6178.tar.gz
emacs-b16ff465dc11ec819bd3d20dd7003953c69b6178.zip
(find-emacs-lisp-shadows, list-load-path-shadows): Use dolist.
(list-load-path-shadows): Use with-current-buffer.
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/emacs-lisp/shadow.el53
2 files changed, 27 insertions, 32 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 158e493fde0..5a6d18d35e8 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12009-11-10 Glenn Morris <rgm@gnu.org>
2
3 * emacs-lisp/shadow.el (find-emacs-lisp-shadows)
4 (list-load-path-shadows): Use dolist.
5 (list-load-path-shadows): Use with-current-buffer.
6
12009-11-10 Juri Linkov <juri@jurta.org> 72009-11-10 Juri Linkov <juri@jurta.org>
2 8
3 * minibuffer.el (read-file-name): Support a list of default values 9 * minibuffer.el (read-file-name): Support a list of default values
diff --git a/lisp/emacs-lisp/shadow.el b/lisp/emacs-lisp/shadow.el
index d86718884f3..9111dde7de7 100644
--- a/lisp/emacs-lisp/shadow.el
+++ b/lisp/emacs-lisp/shadow.el
@@ -72,9 +72,6 @@ the file in position 2i+1. Emacs Lisp file suffixes \(.el and .elc\)
72are stripped from the file names in the list. 72are stripped from the file names in the list.
73 73
74See the documentation for `list-load-path-shadows' for further information." 74See the documentation for `list-load-path-shadows' for further information."
75
76 (or path (setq path load-path))
77
78 (let (true-names ; List of dirs considered. 75 (let (true-names ; List of dirs considered.
79 shadows ; List of shadowings, to be returned. 76 shadows ; List of shadowings, to be returned.
80 files ; File names ever seen, with dirs. 77 files ; File names ever seen, with dirs.
@@ -83,11 +80,8 @@ See the documentation for `list-load-path-shadows' for further information."
83 orig-dir ; Where the file was first seen. 80 orig-dir ; Where the file was first seen.
84 files-seen-this-dir ; Files seen so far in this dir. 81 files-seen-this-dir ; Files seen so far in this dir.
85 file) ; The current file. 82 file) ; The current file.
86 83 (dolist (pp (or path load-path))
87 84 (setq dir (directory-file-name (file-truename (or pp "."))))
88 (while path
89
90 (setq dir (directory-file-name (file-truename (or (car path) "."))))
91 (if (member dir true-names) 85 (if (member dir true-names)
92 ;; We have already considered this PATH redundant directory. 86 ;; We have already considered this PATH redundant directory.
93 ;; Show the redundancy if we are interactive, unless the PATH 87 ;; Show the redundancy if we are interactive, unless the PATH
@@ -95,12 +89,12 @@ See the documentation for `list-load-path-shadows' for further information."
95 ;; result of the current working directory, and are therefore 89 ;; result of the current working directory, and are therefore
96 ;; not always redundant). 90 ;; not always redundant).
97 (or noninteractive 91 (or noninteractive
98 (and (car path) 92 (and pp
99 (not (string= (car path) ".")) 93 (not (string= pp "."))
100 (message "Ignoring redundant directory %s" (car path)))) 94 (message "Ignoring redundant directory %s" pp)))
101 95
102 (setq true-names (append true-names (list dir))) 96 (setq true-names (append true-names (list dir)))
103 (setq dir (directory-file-name (or (car path) "."))) 97 (setq dir (directory-file-name (or pp ".")))
104 (setq curr-files (if (file-accessible-directory-p dir) 98 (setq curr-files (if (file-accessible-directory-p dir)
105 (directory-files dir nil ".\\.elc?\\(\\.gz\\)?$" t))) 99 (directory-files dir nil ".\\.elc?\\(\\.gz\\)?$" t)))
106 (and curr-files 100 (and curr-files
@@ -109,9 +103,8 @@ See the documentation for `list-load-path-shadows' for further information."
109 103
110 (setq files-seen-this-dir nil) 104 (setq files-seen-this-dir nil)
111 105
112 (while curr-files 106 (dolist (file curr-files)
113 107
114 (setq file (car curr-files))
115 (if (string-match "\\.gz$" file) 108 (if (string-match "\\.gz$" file)
116 (setq file (substring file 0 -3))) 109 (setq file (substring file 0 -3)))
117 (setq file (substring 110 (setq file (substring
@@ -141,11 +134,7 @@ See the documentation for `list-load-path-shadows' for further information."
141 (append shadows (list base1 base2))))) 134 (append shadows (list base1 base2)))))
142 135
143 ;; Not seen before, add it to the list of seen files. 136 ;; Not seen before, add it to the list of seen files.
144 (setq files (cons (cons file dir) files)))) 137 (setq files (cons (cons file dir) files)))))))
145
146 (setq curr-files (cdr curr-files))))
147 (setq path (cdr path)))
148
149 ;; Return the list of shadowings. 138 ;; Return the list of shadowings.
150 shadows)) 139 shadows))
151 140
@@ -210,11 +199,10 @@ function, `find-emacs-lisp-shadows'."
210 (tem path) 199 (tem path)
211 toplevs) 200 toplevs)
212 ;; If we can find simple.el in two places, 201 ;; If we can find simple.el in two places,
213 (while tem 202 (dolist (tt tem)
214 (if (or (file-exists-p (expand-file-name "simple.el" (car tem))) 203 (if (or (file-exists-p (expand-file-name "simple.el" tt))
215 (file-exists-p (expand-file-name "simple.el.gz" (car tem)))) 204 (file-exists-p (expand-file-name "simple.el.gz" tt)))
216 (setq toplevs (cons (car tem) toplevs))) 205 (setq toplevs (cons tt toplevs))))
217 (setq tem (cdr tem)))
218 (if (> (length toplevs) 1) 206 (if (> (length toplevs) 1)
219 ;; Cut off our copy of load-path right before 207 ;; Cut off our copy of load-path right before
220 ;; the last directory which has simple.el in it. 208 ;; the last directory which has simple.el in it.
@@ -242,16 +230,17 @@ function, `find-emacs-lisp-shadows'."
242 (if stringp 230 (if stringp
243 (buffer-string) 231 (buffer-string)
244 (if (called-interactively-p 'interactive) 232 (if (called-interactively-p 'interactive)
245 (save-excursion 233 ;; We are interactive.
246 ;; We are interactive. 234 ;; Create the *Shadows* buffer and display shadowings there.
247 ;; Create the *Shadows* buffer and display shadowings there. 235 (let ((string (buffer-string)))
248 (let ((string (buffer-string)) 236 (with-current-buffer (get-buffer-create "*Shadows*")
249 (output-buffer (get-buffer-create "*Shadows*"))) 237 (display-buffer (current-buffer))
250 (display-buffer output-buffer) 238 (setq buffer-undo-list t
251 (set-buffer output-buffer) 239 buffer-read-only nil)
252 (erase-buffer) 240 (erase-buffer)
253 (insert string) 241 (insert string)
254 (insert msg "\n"))) 242 (insert msg "\n")
243 (setq buffer-read-only t)))
255 ;; We are non-interactive, print shadows via message. 244 ;; We are non-interactive, print shadows via message.
256 (unless (zerop n) 245 (unless (zerop n)
257 (message "This site has duplicate Lisp libraries with the same name. 246 (message "This site has duplicate Lisp libraries with the same name.