Moved filter to duplicate-symbols.

Pascal J. Bourguignon [2014-03-09 06:50]
Moved filter to duplicate-symbols.
Filename
tools/package-symbols.lisp
tools/symbol.lisp
diff --git a/tools/package-symbols.lisp b/tools/package-symbols.lisp
index 7594190..f3505ce 100644
--- a/tools/package-symbols.lisp
+++ b/tools/package-symbols.lisp
@@ -58,4 +58,11 @@
     (sort result (function string<)
           :key (function symbol-name))))

+(defmacro packages-created-by (&body body)
+  (let ((vold (gensym)))
+    `(let ((,vold (copy-list (list-all-packages))))
+       (progn ,@body)
+       (set-difference  (list-all-packages) ,vold))))
+
 ;;;; THE END ;;;;
+
diff --git a/tools/symbol.lisp b/tools/symbol.lisp
index a741ee0..d4ed395 100644
--- a/tools/symbol.lisp
+++ b/tools/symbol.lisp
@@ -47,7 +47,7 @@ A tool to check duplicate/un-exported/imported symbols.
   (let ((*package* (find-package "KEYWORD")))
     (format t "~&~S~%" symbols)))

-(defun duplicate-symbols (&optional (packages (list-all-packages)))
+(defun duplicate-symbols (&key (packages (list-all-packages)) (exported nil))
   "Return: a list of list of symbols that have the same name."
   (let ((symbols (make-hash-table :test (function equal))) ; maps names to list of unique symbols
         (duplicates '()))
@@ -59,18 +59,18 @@ A tool to check duplicate/un-exported/imported symbols.
                (when (cdr symbols)
                  (push symbols duplicates)))
              symbols)
-    duplicates))
+    (if exported
+        (remove-if-not (lambda (symbols)
+                         (some (lambda (symbol)
+                                 (eq :external
+                                     (nth-value 1 (find-symbol (symbol-name symbol)
+                                                               (symbol-package symbol)))))
+                               symbols))
+                       duplicates)
+        duplicates)))

 (defun check-duplicate-symbols (&key (packages (list-all-packages)) (exported nil))
-  (report-duplicates (if exported
-                         (remove-if-not (lambda (symbols)
-                                          (some (lambda (symbol)
-                                                  (eq :external
-                                                      (nth-value 1 (find-symbol (symbol-name symbol)
-                                                                                (symbol-package symbol)))))
-                                                symbols))
-                                        (duplicate-symbols packages))
-                         (duplicate-symbols  packages)))
+  (report-duplicates (duplicate-symbols :packages packages :exported exported))
   (values))

ViewGit