comparison lisp/emacs-lisp/shadow.el @ 88155:d7ddb3e565de

sync with trunk
author Henrik Enberg <henrik.enberg@telia.com>
date Mon, 16 Jan 2006 00:03:54 +0000
parents 0d8b17d428b5
children
comparison
equal deleted inserted replaced
88154:8ce476d3ba36 88155:d7ddb3e565de
1 ;;; shadow.el --- locate Emacs Lisp file shadowings 1 ;;; shadow.el --- locate Emacs Lisp file shadowings
2 2
3 ;; Copyright (C) 1995 Free Software Foundation, Inc. 3 ;; Copyright (C) 1995, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
4 4
5 ;; Author: Terry Jones <terry@santafe.edu> 5 ;; Author: Terry Jones <terry@santafe.edu>
6 ;; Keywords: lisp 6 ;; Keywords: lisp
7 ;; Created: 15 December 1995 7 ;; Created: 15 December 1995
8 8
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details. 19 ;; GNU General Public License for more details.
20 20
21 ;; You should have received a copy of the GNU General Public License 21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the 22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, 23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02111-1307, USA. 24 ;; Boston, MA 02110-1301, USA.
25 25
26 ;;; Commentary: 26 ;;; Commentary:
27 27
28 ;; The functions in this file detect (`find-emacs-lisp-shadows') 28 ;; The functions in this file detect (`find-emacs-lisp-shadows')
29 ;; and display (`list-load-path-shadows') potential load-path 29 ;; and display (`list-load-path-shadows') potential load-path
102 (message "Ignoring redundant directory %s" (car path)))) 102 (message "Ignoring redundant directory %s" (car path))))
103 103
104 (setq true-names (append true-names (list dir))) 104 (setq true-names (append true-names (list dir)))
105 (setq dir (directory-file-name (or (car path) "."))) 105 (setq dir (directory-file-name (or (car path) ".")))
106 (setq curr-files (if (file-accessible-directory-p dir) 106 (setq curr-files (if (file-accessible-directory-p dir)
107 (directory-files dir nil ".\\.elc?$" t))) 107 (directory-files dir nil ".\\.elc?\\(\\.gz\\)?$" t)))
108 (and curr-files 108 (and curr-files
109 (not noninteractive) 109 (not noninteractive)
110 (message "Checking %d files in %s..." (length curr-files) dir)) 110 (message "Checking %d files in %s..." (length curr-files) dir))
111 111
112 (setq files-seen-this-dir nil) 112 (setq files-seen-this-dir nil)
113 113
114 (while curr-files 114 (while curr-files
115 115
116 (setq file (car curr-files)) 116 (setq file (car curr-files))
117 (if (string-match "\\.gz$" file)
118 (setq file (substring file 0 -3)))
117 (setq file (substring 119 (setq file (substring
118 file 0 (if (string= (substring file -1) "c") -4 -3))) 120 file 0 (if (string= (substring file -1) "c") -4 -3)))
119 121
120 ;; FILE now contains the current file name, with no suffix. 122 ;; FILE now contains the current file name, with no suffix.
121 (unless (or (member file files-seen-this-dir) 123 (unless (or (member file files-seen-this-dir)
159 (or (equal (file-truename f1) (file-truename f2)) 161 (or (equal (file-truename f1) (file-truename f2))
160 ;; As a quick test, avoiding spawning a process, compare file 162 ;; As a quick test, avoiding spawning a process, compare file
161 ;; sizes. 163 ;; sizes.
162 (and (= (nth 7 (file-attributes f1)) 164 (and (= (nth 7 (file-attributes f1))
163 (nth 7 (file-attributes f2))) 165 (nth 7 (file-attributes f2)))
164 (zerop (call-process "cmp" nil nil nil "-s" f1 f2)))))))) 166 (eq 0 (call-process "cmp" nil nil nil "-s" f1 f2))))))))
165 167
166 ;;;###autoload 168 ;;;###autoload
167 (defun list-load-path-shadows () 169 (defun list-load-path-shadows ()
168 "Display a list of Emacs Lisp files that shadow other files. 170 "Display a list of Emacs Lisp files that shadow other files.
169 171
207 (let* ((path (copy-sequence load-path)) 209 (let* ((path (copy-sequence load-path))
208 (tem path) 210 (tem path)
209 toplevs) 211 toplevs)
210 ;; If we can find simple.el in two places, 212 ;; If we can find simple.el in two places,
211 (while tem 213 (while tem
212 (if (file-exists-p (expand-file-name "simple.el" (car tem))) 214 (if (or (file-exists-p (expand-file-name "simple.el" (car tem)))
215 (file-exists-p (expand-file-name "simple.el.gz" (car tem))))
213 (setq toplevs (cons (car tem) toplevs))) 216 (setq toplevs (cons (car tem) toplevs)))
214 (setq tem (cdr tem))) 217 (setq tem (cdr tem)))
215 (if (> (length toplevs) 1) 218 (if (> (length toplevs) 1)
216 ;; Cut off our copy of load-path right before 219 ;; Cut off our copy of load-path right before
217 ;; the last directory which has simple.el in it. 220 ;; the last directory which has simple.el in it.
255 (setq shadows (cdr (cdr shadows)))) 258 (setq shadows (cdr (cdr shadows))))
256 (message "%s" msg)))))) 259 (message "%s" msg))))))
257 260
258 (provide 'shadow) 261 (provide 'shadow)
259 262
263 ;;; arch-tag: 0480e8a7-62ed-4a12-a9f6-f44ded9b0830
260 ;;; shadow.el ends here 264 ;;; shadow.el ends here