diff --git a/src/code/pathname.lisp b/src/code/pathname.lisp
index 0092a82efc972799dcdaf1effd93166bd700ae72..217bbc919137e7a46e5f95beb4f75a478c4fcedb 100644
--- a/src/code/pathname.lisp
+++ b/src/code/pathname.lisp
@@ -1227,18 +1227,21 @@ a host-structure or string."
 	   ;; Not path-designator because a file-stream can't have a
 	   ;; wild pathname.
 	   (type (or string pathname) in-wildname))
-  (with-pathname (pathname in-pathname)
-    (with-pathname (wildname in-wildname)
-      (macrolet ((frob (field &optional (op 'components-match ))
-		   `(or (null (,field wildname))
-			(,op (,field pathname) (,field wildname)))))
-	(and (or (null (%pathname-host wildname))
-		 (eq (%pathname-host wildname) (%pathname-host pathname)))
-	     (frob %pathname-device)
-	     (frob %pathname-directory directory-components-match)
-	     (frob %pathname-name)
-	     (frob %pathname-type)
-	     (frob %pathname-version))))))
+  (with-pathname (in-path in-pathname)
+    (enumerate-search-list (pathname in-path)
+      (with-pathname (in-wild in-wildname)
+	(enumerate-search-list (wildname in-wild)
+	  (macrolet ((frob (field &optional (op 'components-match ))
+		       `(or (null (,field wildname))
+			    (,op (,field pathname) (,field wildname)))))
+	    (when (and (or (null (%pathname-host wildname))
+			   (eq (%pathname-host wildname) (%pathname-host pathname)))
+		       (frob %pathname-device)
+		       (frob %pathname-directory directory-components-match)
+		       (frob %pathname-name)
+		       (frob %pathname-type)
+		       (frob %pathname-version))
+	      (return-from pathname-match-p pathname))))))))
 
 
 ;;; SUBSTITUTE-INTO -- Internal
diff --git a/tests/pathname.lisp b/tests/pathname.lisp
new file mode 100644
index 0000000000000000000000000000000000000000..73b31a1e3772a1af727a94dae6d920fbbb727835
--- /dev/null
+++ b/tests/pathname.lisp
@@ -0,0 +1,43 @@
+;; Tests for pathnames
+
+(defpackage :pathname-tests
+  (:use :cl :lisp-unit))
+
+(in-package "PATHNAME-TESTS")
+
+;; Define "foo:" search list.  /tmp and /usr should exist on all unix
+;; systems.
+(setf (ext:search-list "foo:")
+      '(#p"/tmp/" #p"/usr/"))
+
+;; Define "bar:" search list.  The second entry should match the
+;; second entry of the "foo:" search list.
+(setf (ext:search-list "bar:")
+      '(#p"/bin/" #p"/usr/"))
+
+(define-test pathname-match-p.search-lists
+    (:tag :search-list)
+  ;; Basic tests where the wild path is search-list
+
+  (assert-true (pathname-match-p "/tmp/foo.lisp" "foo:*"))
+  (assert-true (pathname-match-p "/tmp/zot/foo.lisp" "foo:**/*"))
+  (assert-true (pathname-match-p "/tmp/zot/foo.lisp" "foo:**/*.lisp"))
+  ;; These match because the second entry of the "foo:" search list is
+  ;; "/usr/".
+  (assert-true (pathname-match-p "/usr/foo.lisp" "foo:*"))
+  (assert-true (pathname-match-p "/usr/bin/foo" "foo:**/*"))
+  (assert-true (pathname-match-p "/usr/bin/foo.lisp" "foo:**/*.lisp"))
+
+  ;; This fails because "/bin/" doesn't match any path of the search
+  ;; list.
+  (assert-false (pathname-match-p "/bin/foo.lisp" "foo:*"))
+
+  ;; Basic test where the pathname is a search-list and the wild path is not.
+  (assert-true (pathname-match-p "foo:foo.lisp" "/tmp/*"))
+  (assert-true (pathname-match-p "foo:foo" "/usr/*"))
+  (assert-true (pathname-match-p "foo:zot/foo.lisp" "/usr/**/*.lisp"))
+
+  (assert-false (pathname-match-p "foo:foo" "/bin/*"))
+  
+  ;; Tests where both args are search-lists.
+  (assert-true "foo:foo.lisp" "bar:*"))