annotate lisp/emacs-lisp/shadow.el @ 17323:15fa68d983e7

(ccl_driver): Fix bug of the case CCL_WriteArrayReadJump.
author Kenichi Handa <handa@m17n.org>
date Mon, 07 Apr 1997 07:12:13 +0000
parents 30e9db641e6f
children c160218de690
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14058
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1 ;;; shadow.el --- Locate Emacs Lisp file shadowings.
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3 ;; Copyright (C) 1995 Free Software Foundation, Inc.
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5 ;; Author: Terry Jones <terry@santafe.edu>
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6 ;; Keywords: lisp
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
7 ;; Created: 15 December 1995
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
8
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
10
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
14 ;; any later version.
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
15
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
19 ;; GNU General Public License for more details.
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
20
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14058
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14058
diff changeset
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14058
diff changeset
24 ;; Boston, MA 02111-1307, USA.
14058
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
25
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
26 ;;; Commentary:
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14058
diff changeset
27
14058
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
28 ;; The functions in this file detect (`find-emacs-lisp-shadows')
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
29 ;; and display (`list-load-path-shadows') potential load-path
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
30 ;; problems that arise when Emacs Lisp files "shadow" each other.
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
31 ;;
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
32 ;; For example, a file XXX.el early in one's load-path will shadow
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
33 ;; a file with the same name in a later load-path directory. When
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
34 ;; this is unintentional, it may result in problems that could have
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
35 ;; been easily avoided. This occurs often (to me) when installing a
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
36 ;; new version of emacs and something in the site-lisp directory
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
37 ;; has been updated and added to the emacs distribution. The old
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
38 ;; version, now outdated, shadows the new one. This is obviously
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
39 ;; undesirable.
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
40 ;;
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
41 ;; The `list-load-path-shadows' function was run when you installed
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
42 ;; this version of emacs. To run it by hand in emacs:
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
43 ;;
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
44 ;; M-x load-library RET shadow RET
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
45 ;; M-x list-load-path-shadows
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
46 ;;
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
47 ;; or run it non-interactively via:
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
48 ;;
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
49 ;; emacs -batch -l shadow.el -f list-load-path-shadows
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
50 ;;
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
51 ;; Thanks to Francesco Potorti` <pot@cnuce.cnr.it> for suggestions,
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
52 ;; rewritings & speedups.
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
53
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
54 ;;; Code:
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
55
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
56 (defun find-emacs-lisp-shadows (&optional path)
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
57 "Return a list of Emacs Lisp files that create shadows.
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
58 This function does the work for `list-load-path-shadows'.
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
59
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
60 We traverse PATH looking for shadows, and return a \(possibly empty\)
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
61 even-length list of files. A file in this list at position 2i shadows
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
62 the file in position 2i+1. Emacs Lisp file suffixes \(.el and .elc\)
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
63 are stripped from the file names in the list.
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
64
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
65 See the documentation for `list-load-path-shadows' for further information."
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
66
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
67 (or path (setq path load-path))
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
68
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
69 (let (true-names ; List of dirs considered.
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
70 shadows ; List of shadowings, to be returned.
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
71 files ; File names ever seen, with dirs.
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
72 dir ; The dir being currently scanned.
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
73 curr-files ; This dir's Emacs Lisp files.
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
74 orig-dir ; Where the file was first seen.
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
75 files-seen-this-dir ; Files seen so far in this dir.
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
76 file) ; The current file.
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
77
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
78
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
79 (while path
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
80
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
81 (setq dir (file-truename (or (car path) ".")))
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
82 (if (member dir true-names)
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
83 ;; We have already considered this PATH redundant directory.
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
84 ;; Show the redundancy if we are interactiver, unless the PATH
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
85 ;; dir is nil or "." (these redundant directories are just a
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
86 ;; result of the current working directory, and are therefore
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
87 ;; not always redundant).
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
88 (or noninteractive
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
89 (and (car path)
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
90 (not (string= (car path) "."))
15736
73a325c414a5 (list-load-path-shadows): Fix ambiguous wording.
Karl Heuer <kwzh@gnu.org>
parents: 14348
diff changeset
91 (message "Ignoring redundant directory %s" (car path))))
14058
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
92
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
93 (setq true-names (append true-names (list dir)))
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
94 (setq dir (or (car path) "."))
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
95 (setq curr-files (if (file-accessible-directory-p dir)
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
96 (directory-files dir nil ".\\.elc?$" t)))
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
97 (and curr-files
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
98 (not noninteractive)
15736
73a325c414a5 (list-load-path-shadows): Fix ambiguous wording.
Karl Heuer <kwzh@gnu.org>
parents: 14348
diff changeset
99 (message "Checking %d files in %s..." (length curr-files) dir))
14058
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
100
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
101 (setq files-seen-this-dir nil)
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
102
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
103 (while curr-files
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
104
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
105 (setq file (car curr-files))
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
106 (setq file (substring
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
107 file 0 (if (string= (substring file -1) "c") -4 -3)))
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
108
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
109 ;; 'file' now contains the current file name, with no suffix.
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
110 (if (member file files-seen-this-dir)
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
111 nil
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
112
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
113 ;; File has not been seen yet in this directory.
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
114 ;; This test prevents us declaring that XXX.el shadows
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
115 ;; XXX.elc (or vice-versa) when they are in the same directory.
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
116 (setq files-seen-this-dir (cons file files-seen-this-dir))
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
117
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
118 (if (setq orig-dir (assoc file files))
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
119 ;; This file was seen before, we have a shadowing.
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
120 (setq shadows
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
121 (append shadows
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
122 (list (concat (cdr orig-dir) "/" file)
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
123 (concat dir "/" file))))
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
124
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
125 ;; Not seen before, add it to the list of seen files.
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
126 (setq files (cons (cons file dir) files))))
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
127
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
128 (setq curr-files (cdr curr-files))))
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
129 (setq path (cdr path)))
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
130
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
131 ;; Return the list of shadowings.
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
132 shadows))
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
133
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
134
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
135 ;;;###autoload
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
136 (defun list-load-path-shadows ()
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
137
15756
30e9db641e6f (list-load-path-shadows): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 15736
diff changeset
138 "Display a list of Emacs Lisp files that shadow other files.
14058
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
139
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
140 This function lists potential load-path problems. Directories in the
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
141 `load-path' variable are searched, in order, for Emacs Lisp
15756
30e9db641e6f (list-load-path-shadows): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 15736
diff changeset
142 files. When a previously encountered file name is found again, a
30e9db641e6f (list-load-path-shadows): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 15736
diff changeset
143 message is displayed indicating that the later file is \"hidden\" by
14058
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
144 the earlier.
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
145
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
146 For example, suppose `load-path' is set to
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
147
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
148 \(\"/usr/gnu/emacs/site-lisp\" \"/usr/gnu/emacs/share/emacs/19.30/lisp\"\)
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
149
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
150 and that each of these directories contains a file called XXX.el. Then
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
151 XXX.el in the site-lisp directory is referred to by all of:
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
152 \(require 'XXX\), \(autoload .... \"XXX\"\), \(load-library \"XXX\"\) etc.
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
153
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
154 The first XXX.el file prevents emacs from seeing the second \(unless
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
155 the second is loaded explicitly via load-file\).
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
156
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
157 When not intended, such shadowings can be the source of subtle
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
158 problems. For example, the above situation may have arisen because the
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
159 XXX package was not distributed with versions of emacs prior to
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
160 19.30. An emacs maintainer downloaded XXX from elsewhere and installed
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
161 it. Later, XXX was updated and included in the emacs distribution.
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
162 Unless the emacs maintainer checks for this, the new version of XXX
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
163 will be hidden behind the old \(which may no longer work with the new
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
164 emacs version\).
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
165
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
166 This function performs these checks and flags all possible
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
167 shadowings. Because a .el file may exist without a corresponding .elc
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
168 \(or vice-versa\), these suffixes are essentially ignored. A file
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
169 XXX.elc in an early directory \(that does not contain XXX.el\) is
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
170 considered to shadow a later file XXX.el, and vice-versa.
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
171
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
172 When run interactively, the shadowings \(if any\) are displayed in a
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
173 buffer called `*Shadows*'. Shadowings are located by calling the
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
174 \(non-interactive\) companion function, `find-emacs-lisp-shadows'."
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
175
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
176 (interactive)
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
177 (let* ((shadows (find-emacs-lisp-shadows))
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
178 (n (/ (length shadows) 2))
15736
73a325c414a5 (list-load-path-shadows): Fix ambiguous wording.
Karl Heuer <kwzh@gnu.org>
parents: 14348
diff changeset
179 (msg (format "%s Emacs Lisp load-path shadowing%s found"
14058
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
180 (if (zerop n) "No" (concat "\n" (number-to-string n)))
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
181 (if (= n 1) " was" "s were"))))
15736
73a325c414a5 (list-load-path-shadows): Fix ambiguous wording.
Karl Heuer <kwzh@gnu.org>
parents: 14348
diff changeset
182 (if (interactive-p)
73a325c414a5 (list-load-path-shadows): Fix ambiguous wording.
Karl Heuer <kwzh@gnu.org>
parents: 14348
diff changeset
183 (save-excursion
73a325c414a5 (list-load-path-shadows): Fix ambiguous wording.
Karl Heuer <kwzh@gnu.org>
parents: 14348
diff changeset
184 ;; We are interactive.
73a325c414a5 (list-load-path-shadows): Fix ambiguous wording.
Karl Heuer <kwzh@gnu.org>
parents: 14348
diff changeset
185 ;; Create the *Shadows* buffer and display shadowings there.
73a325c414a5 (list-load-path-shadows): Fix ambiguous wording.
Karl Heuer <kwzh@gnu.org>
parents: 14348
diff changeset
186 (let ((output-buffer (get-buffer-create "*Shadows*")))
73a325c414a5 (list-load-path-shadows): Fix ambiguous wording.
Karl Heuer <kwzh@gnu.org>
parents: 14348
diff changeset
187 (display-buffer output-buffer)
73a325c414a5 (list-load-path-shadows): Fix ambiguous wording.
Karl Heuer <kwzh@gnu.org>
parents: 14348
diff changeset
188 (set-buffer output-buffer)
73a325c414a5 (list-load-path-shadows): Fix ambiguous wording.
Karl Heuer <kwzh@gnu.org>
parents: 14348
diff changeset
189 (erase-buffer)
73a325c414a5 (list-load-path-shadows): Fix ambiguous wording.
Karl Heuer <kwzh@gnu.org>
parents: 14348
diff changeset
190 (while shadows
73a325c414a5 (list-load-path-shadows): Fix ambiguous wording.
Karl Heuer <kwzh@gnu.org>
parents: 14348
diff changeset
191 (insert (format "%s hides %s\n" (car shadows)
73a325c414a5 (list-load-path-shadows): Fix ambiguous wording.
Karl Heuer <kwzh@gnu.org>
parents: 14348
diff changeset
192 (car (cdr shadows))))
73a325c414a5 (list-load-path-shadows): Fix ambiguous wording.
Karl Heuer <kwzh@gnu.org>
parents: 14348
diff changeset
193 (setq shadows (cdr (cdr shadows))))
73a325c414a5 (list-load-path-shadows): Fix ambiguous wording.
Karl Heuer <kwzh@gnu.org>
parents: 14348
diff changeset
194 (insert msg "\n")))
73a325c414a5 (list-load-path-shadows): Fix ambiguous wording.
Karl Heuer <kwzh@gnu.org>
parents: 14348
diff changeset
195 ;; We are non-interactive, print shadows via message.
73a325c414a5 (list-load-path-shadows): Fix ambiguous wording.
Karl Heuer <kwzh@gnu.org>
parents: 14348
diff changeset
196 (while shadows
73a325c414a5 (list-load-path-shadows): Fix ambiguous wording.
Karl Heuer <kwzh@gnu.org>
parents: 14348
diff changeset
197 (message "%s hides %s" (car shadows) (car (cdr shadows)))
73a325c414a5 (list-load-path-shadows): Fix ambiguous wording.
Karl Heuer <kwzh@gnu.org>
parents: 14348
diff changeset
198 (setq shadows (cdr (cdr shadows))))
73a325c414a5 (list-load-path-shadows): Fix ambiguous wording.
Karl Heuer <kwzh@gnu.org>
parents: 14348
diff changeset
199 (message "%s" msg))))
14058
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
200
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
201 (provide 'shadow)
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
202
be8c739308f7 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
203 ;;; shadow.el ends here