;;; shadow.el --- locate Emacs Lisp file shadowings
-;; Copyright (C) 1995, 2001, 2002, 2003, 2004, 2005,
-;; 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+;; Copyright (C) 1995, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+;; 2009 Free Software Foundation, Inc.
;; Author: Terry Jones <terry@santafe.edu>
;; Keywords: lisp
;; The `list-load-path-shadows' function was run when you installed
;; this version of emacs. To run it by hand in emacs:
;;
-;; M-x load-library RET shadow RET
;; M-x list-load-path-shadows
;;
;; or run it non-interactively via:
;;
-;; emacs -batch -l shadow.el -f list-load-path-shadows
+;; emacs -batch -f list-load-path-shadows
;;
;; Thanks to Francesco Potorti` <pot@cnuce.cnr.it> for suggestions,
;; rewritings & speedups.
:group 'lisp)
(defcustom shadows-compare-text-p nil
- "*If non-nil, then shadowing files are reported only if their text differs.
+ "If non-nil, then shadowing files are reported only if their text differs.
This is slower, but filters out some innocuous shadowing."
:type 'boolean
:group 'lisp-shadow)
(eq 0 (call-process "cmp" nil nil nil "-s" f1 f2))))))))
\f
;;;###autoload
-(defun list-load-path-shadows ()
+(defun list-load-path-shadows (&optional stringp)
"Display a list of Emacs Lisp files that shadow other files.
+If STRINGP is non-nil, returns any shadows as a string.
+Otherwise, if interactive shows any shadows in a `*Shadows*' buffer;
+else prints messages listing any shadows.
+
This function lists potential load path problems. Directories in
the `load-path' variable are searched, in order, for Emacs Lisp
files. When a previously encountered file name is found again, a
XXX.elc in an early directory \(that does not contain XXX.el\) is
considered to shadow a later file XXX.el, and vice-versa.
-When run interactively, the shadowings \(if any\) are displayed in a
-buffer called `*Shadows*'. Shadowings are located by calling the
-\(non-interactive\) companion function, `find-emacs-lisp-shadows'."
-
+Shadowings are located by calling the (non-interactive) companion
+function, `find-emacs-lisp-shadows'."
(interactive)
(let* ((path (copy-sequence load-path))
(tem path)
(msg (format "%s Emacs Lisp load-path shadowing%s found"
(if (zerop n) "No" (concat "\n" (number-to-string n)))
(if (= n 1) " was" "s were"))))
- (if (interactive-p)
- (save-excursion
- ;; We are interactive.
- ;; Create the *Shadows* buffer and display shadowings there.
- (let ((output-buffer (get-buffer-create "*Shadows*")))
- (display-buffer output-buffer)
- (set-buffer output-buffer)
- (erase-buffer)
- (while shadows
- (insert (format "%s hides %s\n" (car shadows)
- (car (cdr shadows))))
- (setq shadows (cdr (cdr shadows))))
- (insert msg "\n")))
- ;; We are non-interactive, print shadows via message.
- (when shadows
- (message "This site has duplicate Lisp libraries with the same name.
+ (with-temp-buffer
+ (while shadows
+ (insert (format "%s hides %s\n" (car shadows)
+ (car (cdr shadows))))
+ (setq shadows (cdr (cdr shadows))))
+ (if stringp
+ (buffer-string)
+ (if (interactive-p)
+ (save-excursion
+ ;; We are interactive.
+ ;; Create the *Shadows* buffer and display shadowings there.
+ (let ((string (buffer-string))
+ (output-buffer (get-buffer-create "*Shadows*")))
+ (display-buffer output-buffer)
+ (set-buffer output-buffer)
+ (erase-buffer)
+ (insert string)
+ (insert msg "\n")))
+ ;; We are non-interactive, print shadows via message.
+ (unless (zerop n)
+ (message "This site has duplicate Lisp libraries with the same name.
If a locally-installed Lisp library overrides a library in the Emacs release,
that can cause trouble, and you should probably remove the locally-installed
version unless you know what you are doing.\n")
- (while shadows
- (message "%s hides %s" (car shadows) (car (cdr shadows)))
- (setq shadows (cdr (cdr shadows))))
- (message "%s" msg))))))
+ (goto-char (point-min))
+ ;; Mimic the previous behavior of using lots of messages.
+ ;; I think one single message would look better...
+ (while (not (eobp))
+ (message "%s" (buffer-substring (line-beginning-position)
+ (line-end-position)))
+ (forward-line 1))
+ (message "%s" msg))))))))
(provide 'shadow)