emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs/lisp/emacs-lisp shadow.el


From: Glenn Morris
Subject: [Emacs-diffs] emacs/lisp/emacs-lisp shadow.el
Date: Wed, 22 Jul 2009 02:34:11 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Glenn Morris <gm>       09/07/22 02:34:11

Modified files:
        lisp/emacs-lisp: shadow.el 

Log message:
        (shadows-compare-text-p): Remove leading * from defcustom doc.
        (list-load-path-shadows): Optionally, just return shadows as a string.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/emacs-lisp/shadow.el?cvsroot=emacs&r1=1.30&r2=1.31

Patches:
Index: shadow.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/emacs-lisp/shadow.el,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -b -r1.30 -r1.31
--- shadow.el   5 Jan 2009 03:21:09 -0000       1.30
+++ shadow.el   22 Jul 2009 02:34:11 -0000      1.31
@@ -1,7 +1,7 @@
 ;;; 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 <address@hidden>
 ;; Keywords: lisp
@@ -40,12 +40,11 @@
 ;; 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` <address@hidden> for suggestions,
 ;; rewritings & speedups.
@@ -58,7 +57,7 @@
   :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)
@@ -165,9 +164,13 @@
                      (eq 0 (call-process "cmp" nil nil nil "-s" f1 f2))))))))
 
 ;;;###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
@@ -200,10 +203,8 @@
 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)
@@ -233,29 +234,38 @@
           (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"))))
+      (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 ((output-buffer (get-buffer-create "*Shadows*")))
+               (let ((string (buffer-string))
+                     (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 string)
              (insert msg "\n")))
        ;; We are non-interactive, print shadows via message.
-       (when shadows
+           (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)
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]