annotate lisp/shadow.el @ 5887:6eca500211f4

Prototype for X509_check_host() has changed, detect this in configure.ac ChangeLog addition: 2015-04-09 Aidan Kehoe <kehoea@parhasard.net> * configure.ac: If X509_check_host() is available, check the number of arguments it takes. Don't use it if it takes any number of arguments other than five. Also don't use it if <openssl/x509v3.h> does not declare it, since if that is so there is no portable way to tell how many arguments it should take, and so we would end up smashing the stack. * configure: Regenerate. src/ChangeLog addition: 2015-04-09 Aidan Kehoe <kehoea@parhasard.net> * tls.c: #include <openssl/x509v3.h> for its prototype for X509_check_host(). * tls.c (tls_open): Pass the new fifth argument to X509_check_host().
author Aidan Kehoe <kehoea@parhasard.net>
date Thu, 09 Apr 2015 14:27:02 +0100
parents 308d34e9f07d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 ;;; shadow.el --- Locate Emacs Lisp file shadowings.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 ;; Copyright (C) 1995 Free Software Foundation, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 ;; Author: Terry Jones <terry@santafe.edu>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 ;; Keywords: lisp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 ;; Created: 15 December 1995
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 ;; This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 2562
diff changeset
11 ;; XEmacs is free software: you can redistribute it and/or modify it
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 2562
diff changeset
12 ;; under the terms of the GNU General Public License as published by the
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 2562
diff changeset
13 ;; Free Software Foundation, either version 3 of the License, or (at your
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 2562
diff changeset
14 ;; option) any later version.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 2562
diff changeset
16 ;; XEmacs is distributed in the hope that it will be useful, but WITHOUT
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 2562
diff changeset
17 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 2562
diff changeset
18 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 2562
diff changeset
19 ;; for more details.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 2562
diff changeset
22 ;; along with XEmacs. If not, see <http://www.gnu.org/licenses/>.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 ;;; Commentary:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 ;; The functions in this file detect (`find-emacs-lisp-shadows')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 ;; and display (`list-load-path-shadows') potential load-path
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 ;; problems that arise when Emacs Lisp files "shadow" each other.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 ;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 ;; For example, a file XXX.el early in one's load-path will shadow
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 ;; a file with the same name in a later load-path directory. When
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 ;; this is unintentional, it may result in problems that could have
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 ;; been easily avoided. This occurs often (to me) when installing a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 ;; new version of emacs and something in the site-lisp directory
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 ;; has been updated and added to the emacs distribution. The old
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 ;; version, now outdated, shadows the new one. This is obviously
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 ;; undesirable.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 ;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 ;; The `list-load-path-shadows' function was run when you installed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 ;; this version of emacs. To run it by hand in emacs:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 ;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 ;; M-x load-library RET shadow RET
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 ;; M-x list-load-path-shadows
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 ;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 ;; or run it non-interactively via:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 ;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 ;; emacs -batch -l shadow.el -f list-load-path-shadows
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 ;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 ;; Thanks to Francesco Potorti` <pot@cnuce.cnr.it> for suggestions,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 ;; rewritings & speedups.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 ;; 1998-08-15 Martin Buchholz: Speed up using hash tables instead of lists.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 ;;; Code:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 (defun find-emacs-lisp-shadows (&optional path)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 "Return a list of Emacs Lisp files that create shadows.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 This function does the work for `list-load-path-shadows'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 We traverse PATH looking for shadows, and return a \(possibly empty\)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 even-length list of files. A file in this list at position 2i shadows
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 the file in position 2i+1. Emacs Lisp file suffixes \(.el and .elc\)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 are stripped from the file names in the list.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 See the documentation for `list-load-path-shadows' for further information."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 (let (shadows ; List of shadowings, to be returned.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 dir ; The dir being currently scanned.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 curr-files ; This dir's Emacs Lisp files.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 orig-dir ; Where the file was first seen.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 (file-dirs ; File names ever seen, with dirs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 (make-hash-table :size 2000 :test 'equal))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 (true-names ; Dirs ever considered.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 (make-hash-table :size 50 :test 'equal))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 (files-seen-this-dir ; Files seen so far in this dir.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 (make-hash-table :size 100 :test 'equal))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 (dolist (path-elt (or path load-path))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 (setq dir (file-truename (or path-elt ".")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 (if (gethash dir true-names)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 ;; We have already considered this PATH redundant directory.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 ;; Show the redundancy if we are interactive, unless the PATH
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 ;; dir is nil or "." (these redundant directories are just a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 ;; result of the current working directory, and are therefore
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 ;; not always redundant).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 (or noninteractive
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 (and path-elt
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 (not (string= path-elt "."))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 (message "Ignoring redundant directory %s" path-elt)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 (puthash dir t true-names)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 (setq dir (or path-elt "."))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 (setq curr-files (if (file-accessible-directory-p dir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 (directory-files dir nil ".\\.elc?$" t)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 (and curr-files
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 (not noninteractive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 (message "Checking %d files in %s..." (length curr-files) dir))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 (clrhash files-seen-this-dir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 (dolist (file curr-files)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 (setq file (substring
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 file 0 (if (string= (substring file -1) "c") -4 -3)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 ;; FILE now contains the current file name, with no suffix.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 (unless (or (gethash file files-seen-this-dir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 ;; Ignore these files.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 (member file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 '("subdirs"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 "auto-autoloads"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 "custom-load"
2562
ecc681180115 [xemacs-hg @ 2005-02-04 02:59:26 by ben]
ben
parents: 613
diff changeset
115 "custom-defines"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 "dumped-lisp"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 "_pkg"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 "lpath")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 ;; File has not been seen yet in this directory.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 ;; This test prevents us declaring that XXX.el shadows
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 ;; XXX.elc (or vice-versa) when they are in the same directory.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 (puthash file t files-seen-this-dir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 (if (setq orig-dir (gethash file file-dirs))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 ;; This file was seen before, we have a shadowing.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 (setq shadows
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 (nconc shadows
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 (list (concat (file-name-as-directory orig-dir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 (concat (file-name-as-directory dir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 file))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 ;; Not seen before, add it to the list of seen files.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 (puthash file dir file-dirs))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 ;; Return the list of shadowings.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 shadows))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 (defun list-load-path-shadows ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 "Display a list of Emacs Lisp files that shadow other files.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 This function lists potential load-path problems. Directories in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 `load-path' variable are searched, in order, for Emacs Lisp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 files. When a previously encountered file name is found again, a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 message is displayed indicating that the later file is \"hidden\" by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 the earlier.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 For example, suppose `load-path' is set to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 \(\"/usr/gnu/emacs/site-lisp\" \"/usr/gnu/emacs/share/emacs/19.30/lisp\"\)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 and that each of these directories contains a file called XXX.el. Then
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 XXX.el in the site-lisp directory is referred to by all of:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 \(require 'XXX\), \(autoload .... \"XXX\"\), \(load-library \"XXX\"\) etc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 The first XXX.el file prevents emacs from seeing the second \(unless
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 the second is loaded explicitly via load-file\).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 When not intended, such shadowings can be the source of subtle
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 problems. For example, the above situation may have arisen because the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 XXX package was not distributed with versions of emacs prior to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 19.30. An emacs maintainer downloaded XXX from elsewhere and installed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 it. Later, XXX was updated and included in the emacs distribution.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 Unless the emacs maintainer checks for this, the new version of XXX
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 will be hidden behind the old \(which may no longer work with the new
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 emacs version\).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 This function performs these checks and flags all possible
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 shadowings. Because a .el file may exist without a corresponding .elc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 \(or vice-versa\), these suffixes are essentially ignored. A file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 XXX.elc in an early directory \(that does not contain XXX.el\) is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 considered to shadow a later file XXX.el, and vice-versa.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 When run interactively, the shadowings \(if any\) are displayed in a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 buffer called `*Shadows*'. Shadowings are located by calling the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 \(non-interactive\) companion function, `find-emacs-lisp-shadows'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 (let* ((path (copy-sequence load-path))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 (tem path)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 toplevs)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 ;; If we can find simple.el in two places,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 (while tem
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 (if (file-exists-p (expand-file-name "simple.el" (car tem)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 (setq toplevs (cons (car tem) toplevs)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 (setq tem (cdr tem)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 (if (> (length toplevs) 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 ;; Cut off our copy of load-path right before
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 ;; the second directory which has simple.el in it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 ;; This avoids loads of duplications between the source dir
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 ;; and the dir where these files were copied by installation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 (let ((break (nth (- (length toplevs) 2) toplevs)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 (setq tem path)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 (while tem
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 (if (eq (nth 1 tem) break)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 (setcdr tem nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 (setq tem nil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 (setq tem (cdr tem)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 (let* ((shadows (find-emacs-lisp-shadows path))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 (n (/ (length shadows) 2))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 (msg (format "%s Emacs Lisp load-path shadowing%s found"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 (if (zerop n) "No" (concat "\n" (number-to-string n)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 (if (= n 1) " was" "s were"))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 (if (interactive-p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 ;; We are interactive.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 ;; Create the *Shadows* buffer and display shadowings there.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 (let ((output-buffer (get-buffer-create "*Shadows*")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 (display-buffer output-buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 (set-buffer output-buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 (erase-buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 (while shadows
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 (insert (format "%s hides %s\n" (car shadows)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 (car (cdr shadows))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 (setq shadows (cdr (cdr shadows))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 (insert msg "\n")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 ;; We are non-interactive, print shadows via message.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 (when shadows
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 (message "This site has duplicate Lisp libraries with the same name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 If a locally-installed Lisp library overrides a library in the Emacs release,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 that can cause trouble, and you should probably remove the locally-installed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 version unless you know what you are doing.\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 (while shadows
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 (message "%s hides %s" (car shadows) (car (cdr shadows)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 (setq shadows (cdr (cdr shadows))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 (message "%s" msg))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 (provide 'shadow)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 ;;; shadow.el ends here