changeset 48611:79a38ce36eb1

(PC-do-completion): Do not add wildcards to pattern unless filename is non-nil.
author Noah Friedman <friedman@splode.com>
date Mon, 02 Dec 2002 08:49:45 +0000
parents 6d0d9fa39133
children 86555a848e72
files lisp/complete.el
diffstat 1 files changed, 17 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/complete.el	Sun Dec 01 23:38:48 2002 +0000
+++ b/lisp/complete.el	Mon Dec 02 08:49:45 2002 +0000
@@ -383,7 +383,7 @@
 	     (delete-region beg end)
 	     (insert str)
 	     (setq end (+ beg (length str)))))
-      
+
       ;; Prepare various delimiter strings
       (or (equal PC-word-delimiters PC-delims)
 	  (setq PC-delims PC-word-delimiters
@@ -392,17 +392,18 @@
 		PC-delims-list (append PC-delims nil)))
 
       ;; Add wildcards if necessary
-      (let ((dir (file-name-directory str))
-	    (file (file-name-nondirectory str)))
-	(while (and (stringp dir) (not (file-directory-p dir)))
-	  (setq dir (directory-file-name dir))
-	  (setq file (concat (replace-regexp-in-string
-			      PC-delim-regex "*\\&"
-			      (file-name-nondirectory dir))
-			     "*/" file))
-	  (setq dir (file-name-directory dir)))
-	(setq str (concat dir file)))
-      
+      (and filename
+           (let ((dir (file-name-directory str))
+                 (file (file-name-nondirectory str)))
+             (while (and (stringp dir) (not (file-directory-p dir)))
+               (setq dir (directory-file-name dir))
+               (setq file (concat (replace-regexp-in-string
+                                   PC-delim-regex "*\\&"
+                                   (file-name-nondirectory dir))
+                                  "*/" file))
+               (setq dir (file-name-directory dir)))
+             (setq str (concat dir file))))
+
       ;; Look for wildcard expansions in directory name
       (and filename
 	   (string-match "\\*.*/" str)
@@ -890,7 +891,7 @@
 ;;; This is adapted from lib-complete.el, by Mike Williams.
 (defun PC-include-file-all-completions (file search-path &optional full)
   "Return all completions for FILE in any directory on SEARCH-PATH.
-If optional third argument FULL is non-nil, returned pathnames should be 
+If optional third argument FULL is non-nil, returned pathnames should be
 absolute rather than relative to some directory on the SEARCH-PATH."
   (setq search-path
 	(mapcar (lambda (dir)
@@ -900,7 +901,7 @@
       ;; It's an absolute file name, so don't need search-path
       (progn
 	(setq file (expand-file-name file))
-	(file-name-all-completions 
+	(file-name-all-completions
 	 (file-name-nondirectory file) (file-name-directory file)))
     (let ((subdir (file-name-directory file))
 	  (ndfile (file-name-nondirectory file))
@@ -918,9 +919,9 @@
 	  (if (file-directory-p dir)
 	      (progn
 		(setq file-lists
-		      (cons 
+		      (cons
 		       (mapcar (lambda (file) (concat subdir file))
-			       (file-name-all-completions ndfile 
+			       (file-name-all-completions ndfile
 							  (car search-path)))
 		       file-lists))))
 	  (setq search-path (cdr search-path))))