Mercurial > emacs
comparison lisp/emacs-lisp/shadow.el @ 104021:94f1fe5b7430
(shadows-compare-text-p): Remove leading * from defcustom doc.
(list-load-path-shadows): Optionally, just return shadows as a string.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Wed, 22 Jul 2009 02:34:11 +0000 |
parents | a9dc0e7c3f2b |
children | bd2966850aac |
comparison
equal
deleted
inserted
replaced
104020:48eee3db3afa | 104021:94f1fe5b7430 |
---|---|
1 ;;; shadow.el --- locate Emacs Lisp file shadowings | 1 ;;; shadow.el --- locate Emacs Lisp file shadowings |
2 | 2 |
3 ;; Copyright (C) 1995, 2001, 2002, 2003, 2004, 2005, | 3 ;; Copyright (C) 1995, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, |
4 ;; 2006, 2007, 2008, 2009 Free Software Foundation, Inc. | 4 ;; 2009 Free Software Foundation, Inc. |
5 | 5 |
6 ;; Author: Terry Jones <terry@santafe.edu> | 6 ;; Author: Terry Jones <terry@santafe.edu> |
7 ;; Keywords: lisp | 7 ;; Keywords: lisp |
8 ;; Created: 15 December 1995 | 8 ;; Created: 15 December 1995 |
9 | 9 |
38 ;; undesirable. | 38 ;; undesirable. |
39 ;; | 39 ;; |
40 ;; The `list-load-path-shadows' function was run when you installed | 40 ;; The `list-load-path-shadows' function was run when you installed |
41 ;; this version of emacs. To run it by hand in emacs: | 41 ;; this version of emacs. To run it by hand in emacs: |
42 ;; | 42 ;; |
43 ;; M-x load-library RET shadow RET | |
44 ;; M-x list-load-path-shadows | 43 ;; M-x list-load-path-shadows |
45 ;; | 44 ;; |
46 ;; or run it non-interactively via: | 45 ;; or run it non-interactively via: |
47 ;; | 46 ;; |
48 ;; emacs -batch -l shadow.el -f list-load-path-shadows | 47 ;; emacs -batch -f list-load-path-shadows |
49 ;; | 48 ;; |
50 ;; Thanks to Francesco Potorti` <pot@cnuce.cnr.it> for suggestions, | 49 ;; Thanks to Francesco Potorti` <pot@cnuce.cnr.it> for suggestions, |
51 ;; rewritings & speedups. | 50 ;; rewritings & speedups. |
52 | 51 |
53 ;;; Code: | 52 ;;; Code: |
56 "Locate Emacs Lisp file shadowings." | 55 "Locate Emacs Lisp file shadowings." |
57 :prefix "shadows-" | 56 :prefix "shadows-" |
58 :group 'lisp) | 57 :group 'lisp) |
59 | 58 |
60 (defcustom shadows-compare-text-p nil | 59 (defcustom shadows-compare-text-p nil |
61 "*If non-nil, then shadowing files are reported only if their text differs. | 60 "If non-nil, then shadowing files are reported only if their text differs. |
62 This is slower, but filters out some innocuous shadowing." | 61 This is slower, but filters out some innocuous shadowing." |
63 :type 'boolean | 62 :type 'boolean |
64 :group 'lisp-shadow) | 63 :group 'lisp-shadow) |
65 | 64 |
66 (defun find-emacs-lisp-shadows (&optional path) | 65 (defun find-emacs-lisp-shadows (&optional path) |
163 (and (= (nth 7 (file-attributes f1)) | 162 (and (= (nth 7 (file-attributes f1)) |
164 (nth 7 (file-attributes f2))) | 163 (nth 7 (file-attributes f2))) |
165 (eq 0 (call-process "cmp" nil nil nil "-s" f1 f2)))))))) | 164 (eq 0 (call-process "cmp" nil nil nil "-s" f1 f2)))))))) |
166 | 165 |
167 ;;;###autoload | 166 ;;;###autoload |
168 (defun list-load-path-shadows () | 167 (defun list-load-path-shadows (&optional stringp) |
169 "Display a list of Emacs Lisp files that shadow other files. | 168 "Display a list of Emacs Lisp files that shadow other files. |
169 | |
170 If STRINGP is non-nil, returns any shadows as a string. | |
171 Otherwise, if interactive shows any shadows in a `*Shadows*' buffer; | |
172 else prints messages listing any shadows. | |
170 | 173 |
171 This function lists potential load path problems. Directories in | 174 This function lists potential load path problems. Directories in |
172 the `load-path' variable are searched, in order, for Emacs Lisp | 175 the `load-path' variable are searched, in order, for Emacs Lisp |
173 files. When a previously encountered file name is found again, a | 176 files. When a previously encountered file name is found again, a |
174 message is displayed indicating that the later file is \"hidden\" by | 177 message is displayed indicating that the later file is \"hidden\" by |
198 shadowings. Because a .el file may exist without a corresponding .elc | 201 shadowings. Because a .el file may exist without a corresponding .elc |
199 \(or vice-versa\), these suffixes are essentially ignored. A file | 202 \(or vice-versa\), these suffixes are essentially ignored. A file |
200 XXX.elc in an early directory \(that does not contain XXX.el\) is | 203 XXX.elc in an early directory \(that does not contain XXX.el\) is |
201 considered to shadow a later file XXX.el, and vice-versa. | 204 considered to shadow a later file XXX.el, and vice-versa. |
202 | 205 |
203 When run interactively, the shadowings \(if any\) are displayed in a | 206 Shadowings are located by calling the (non-interactive) companion |
204 buffer called `*Shadows*'. Shadowings are located by calling the | 207 function, `find-emacs-lisp-shadows'." |
205 \(non-interactive\) companion function, `find-emacs-lisp-shadows'." | |
206 | |
207 (interactive) | 208 (interactive) |
208 (let* ((path (copy-sequence load-path)) | 209 (let* ((path (copy-sequence load-path)) |
209 (tem path) | 210 (tem path) |
210 toplevs) | 211 toplevs) |
211 ;; If we can find simple.el in two places, | 212 ;; If we can find simple.el in two places, |
231 (let* ((shadows (find-emacs-lisp-shadows path)) | 232 (let* ((shadows (find-emacs-lisp-shadows path)) |
232 (n (/ (length shadows) 2)) | 233 (n (/ (length shadows) 2)) |
233 (msg (format "%s Emacs Lisp load-path shadowing%s found" | 234 (msg (format "%s Emacs Lisp load-path shadowing%s found" |
234 (if (zerop n) "No" (concat "\n" (number-to-string n))) | 235 (if (zerop n) "No" (concat "\n" (number-to-string n))) |
235 (if (= n 1) " was" "s were")))) | 236 (if (= n 1) " was" "s were")))) |
236 (if (interactive-p) | 237 (with-temp-buffer |
237 (save-excursion | 238 (while shadows |
238 ;; We are interactive. | 239 (insert (format "%s hides %s\n" (car shadows) |
239 ;; Create the *Shadows* buffer and display shadowings there. | 240 (car (cdr shadows)))) |
240 (let ((output-buffer (get-buffer-create "*Shadows*"))) | 241 (setq shadows (cdr (cdr shadows)))) |
241 (display-buffer output-buffer) | 242 (if stringp |
242 (set-buffer output-buffer) | 243 (buffer-string) |
243 (erase-buffer) | 244 (if (interactive-p) |
244 (while shadows | 245 (save-excursion |
245 (insert (format "%s hides %s\n" (car shadows) | 246 ;; We are interactive. |
246 (car (cdr shadows)))) | 247 ;; Create the *Shadows* buffer and display shadowings there. |
247 (setq shadows (cdr (cdr shadows)))) | 248 (let ((string (buffer-string)) |
248 (insert msg "\n"))) | 249 (output-buffer (get-buffer-create "*Shadows*"))) |
249 ;; We are non-interactive, print shadows via message. | 250 (display-buffer output-buffer) |
250 (when shadows | 251 (set-buffer output-buffer) |
251 (message "This site has duplicate Lisp libraries with the same name. | 252 (erase-buffer) |
253 (insert string) | |
254 (insert msg "\n"))) | |
255 ;; We are non-interactive, print shadows via message. | |
256 (unless (zerop n) | |
257 (message "This site has duplicate Lisp libraries with the same name. | |
252 If a locally-installed Lisp library overrides a library in the Emacs release, | 258 If a locally-installed Lisp library overrides a library in the Emacs release, |
253 that can cause trouble, and you should probably remove the locally-installed | 259 that can cause trouble, and you should probably remove the locally-installed |
254 version unless you know what you are doing.\n") | 260 version unless you know what you are doing.\n") |
255 (while shadows | 261 (goto-char (point-min)) |
256 (message "%s hides %s" (car shadows) (car (cdr shadows))) | 262 ;; Mimic the previous behavior of using lots of messages. |
257 (setq shadows (cdr (cdr shadows)))) | 263 ;; I think one single message would look better... |
258 (message "%s" msg)))))) | 264 (while (not (eobp)) |
265 (message "%s" (buffer-substring (line-beginning-position) | |
266 (line-end-position))) | |
267 (forward-line 1)) | |
268 (message "%s" msg)))))))) | |
259 | 269 |
260 (provide 'shadow) | 270 (provide 'shadow) |
261 | 271 |
262 ;; arch-tag: 0480e8a7-62ed-4a12-a9f6-f44ded9b0830 | 272 ;; arch-tag: 0480e8a7-62ed-4a12-a9f6-f44ded9b0830 |
263 ;;; shadow.el ends here | 273 ;;; shadow.el ends here |