changeset 54953:d7c47f8983f7

(locate-file-completion): Handle nil in path-and-suffixes. (file-truename): Expand all ~ constructs directly. (insert-directory): Delete any error msg output by the `insert-directory-program'.
author Richard M. Stallman <rms@gnu.org>
date Sat, 17 Apr 2004 19:58:19 +0000
parents 5e2b4f7225cb
children 798d3ee76081
files lisp/files.el
diffstat 1 files changed, 15 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/files.el	Sat Apr 17 19:53:58 2004 +0000
+++ b/lisp/files.el	Sat Apr 17 19:58:19 2004 +0000
@@ -616,6 +616,8 @@
 	  (suffix (concat (regexp-opt (cdr path-and-suffixes) t) "\\'"))
 	  (string-dir (file-name-directory string)))
       (dolist (dir (car path-and-suffixes))
+	(unless dir
+	  (setq dir default-directory))
 	(if string-dir (setq dir (expand-file-name string-dir dir)))
 	(when (file-directory-p dir)
 	  (dolist (file (file-name-all-completions
@@ -668,14 +670,17 @@
   ;; PREV-DIRS can be a cons cell whose car is an alist
   ;; of truenames we've just recently computed.
 
-  ;; The last test looks dubious, maybe `+' is meant here?  --simon.
-  (if (or (string= filename "") (string= filename "~")
-	  (and (string= (substring filename 0 1) "~")
-	       (string-match "~[^/]*" filename)))
-      (progn
-	(setq filename (expand-file-name filename))
-	(if (string= filename "")
-	    (setq filename "/"))))
+  (cond ((or (string= filename "") (string= filename "~"))
+	 (setq filename (expand-file-name filename))
+	 (if (string= filename "")
+	     (setq filename "/")))
+	((and (string= (substring filename 0 1) "~")
+	      (string-match "~[^/]*/?" filename))
+	 (let ((first-part
+		(substring filename 0 (match-end 0)))
+	       (rest (substring filename (match-end 0))))
+	   (setq filename (concat (expand-file-name first-part) rest)))))
+
   (or counter (setq counter (list 100)))
   (let (done
 	;; For speed, remove the ange-ftp completion handler from the list.
@@ -4307,6 +4312,8 @@
 
 	  ;; If `insert-directory-program' failed, signal an error.
 	  (unless (eq 0 result)
+	    ;; Delete the error message it may have output.
+	    (delete-region beg (point))
 	    ;; On non-Posix systems, we cannot open a directory, so
 	    ;; don't even try, because that will always result in
 	    ;; the ubiquitous "Access denied".  Instead, show the