changeset 30291:062625598798

insert-directory: use split-string
author Sam Steingold <sds@gnu.org>
date Tue, 18 Jul 2000 14:18:03 +0000
parents 5d592031fd61
children 14a9937df1f5
files lisp/ChangeLog lisp/files.el
diffstat 2 files changed, 50 insertions(+), 53 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Tue Jul 18 13:05:44 2000 +0000
+++ b/lisp/ChangeLog	Tue Jul 18 14:18:03 2000 +0000
@@ -1,3 +1,8 @@
+2000-07-17  Sam Steingold  <sds@gnu.org>
+
+	* files.el (insert-directory): Call `split-string' instead of
+	re-implementing it.
+
 2000-07-18  Gerd Moellmann  <gerd@gnu.org>
 
 	* mail/vms-pmail.el: Change maintainer to FSF.
@@ -196,7 +201,7 @@
 	* battery.el, info-look.el: Change author's mail address.
 
 2000-07-07  Jonathan I. Kamens  <jik@kamens.brookline.ma.us>
-	
+
 	* mail/rmail.el (rmail-clear-headers): Don't throw an error
 	if rmail-ignored-headers is nil.
 	(rmail-retry-failure): Bind rmail-ignored-headers and
@@ -213,7 +218,7 @@
 
 	* rmail.el (mail-unsent-separator): Changed "the" to "\\w+", as
 	exim can use "your message" instead of "the message".
-	
+
 2000-07-06  Stefan Monnier  <monnier@cs.yale.edu>
 
 	* facemenu.el: Docstrings fixes.
@@ -224,7 +229,7 @@
 	backwards over `=' not to bump into BOBP.
 
 2000-07-05  Michael Kifer  <kifer@cs.sunysb.edu>
-	
+
 	* ediff-diff.el (ediff-wordify): Use syntax table.
 	* ediff-init.el (ediff-has-face-support-p): Use
 	ediff-color-display-p.
@@ -233,7 +238,7 @@
 	Got rid of special cases for NeXT and OS/2.
 	* ediff-wind.el (ediff-setup-control-frame): Set proper modeline
 	face.
-	
+
 2000-07-05  Stefan Monnier  <monnier@cs.yale.edu>
 
 	* emacs-lisp/lucid.el: Require CL.
@@ -250,7 +255,7 @@
 
 	* emacs-lisp/cl-extra.el (cl-old-mapc): Removed; don't defalias mapc.
 	(cl-mapc): Use mapc instead of cl-old-mapc.
-	
+
 2000-07-05  Andrew Innes  <andrewi@gnu.org>
 
 	* makefile.nt: Add support for `bootstrap' and related targets.
@@ -403,7 +408,7 @@
 	* replace.el (perform-replace): Undo change of 2000-04-04.
 	Instead, move backward 1 character at the end of the loop when
 	necessary.
-	
+
 	* faces.el (fringe): Change face for different backgrounds.
 
 	* eshell/esh-module.el (toplevel): Load defgroup's differently;
@@ -467,7 +472,7 @@
 	* comint.el (comint-substitute-in-file-name): Call replace-match
 	with second and third arg t.
 
-	* cus-edit.el (custom-button-face, custom-button-pressed-face): 
+	* cus-edit.el (custom-button-face, custom-button-pressed-face):
 	Specify foreground color.
 
 	* faces.el (tool-bar, mode-line, header-line): Specify foreground
--- a/lisp/files.el	Tue Jul 18 13:05:44 2000 +0000
+++ b/lisp/files.el	Tue Jul 18 14:18:03 2000 +0000
@@ -3217,7 +3217,7 @@
 	    (let ((fn (file-name-nondirectory buffer-file-name)))
 	      (string-match "\\`\\([^.]+\\)\\(\\.\\(..?\\)?.?\\|\\)\\'" fn)
 	      (concat (file-name-directory buffer-file-name)
-		      "#" (match-string 1 fn) 
+		      "#" (match-string 1 fn)
 		      "." (match-string 3 fn) "#"))
 	  (concat (file-name-directory filename)
 		  "#"
@@ -3444,8 +3444,8 @@
 whose name is in the variable `insert-directory-program'.
 If WILDCARD, it also runs the shell specified by `shell-file-name'."
   ;; We need the directory in order to find the right handler.
-  (let ((handler (find-file-name-handler (expand-file-name file)
-					 'insert-directory)))
+  (let* ((file (expand-file-name file))
+         (handler (find-file-name-handler file 'insert-directory)))
     (if handler
 	(funcall handler 'insert-directory file switches
 		 wildcard full-directory-p)
@@ -3459,61 +3459,53 @@
 	       (coding-system-for-write coding-system-for-read)
 	       (result
 		(if wildcard
-		    ;; Run ls in the directory of the file pattern we asked for.
-		    (let ((default-directory
-			    (if (file-name-absolute-p file)
-				(file-name-directory file)
-			      (file-name-directory (expand-file-name file))))
+		    ;; Run ls in the directory of the file pattern we asked for
+		    (let ((default-directory (file-name-directory file))
 			  (pattern (file-name-nondirectory file))
 			  (beg 0))
-		      ;; Quote some characters that have special meanings in shells;
-		      ;; but don't quote the wildcards--we want them to be special.
-		      ;; We also currently don't quote the quoting characters
-		      ;; in case people want to use them explicitly to quote
-		      ;; wildcard characters.
+		      ;; Quote some characters that have special
+		      ;; meanings in shells; but don't quote the
+		      ;; wildcards--we want them to be special.
+		      ;; We also currently don't quote the quoting
+		      ;; characters in case people want to use them
+		      ;; explicitly to quote wildcard characters.
 		      (while (string-match "[ \t\n;<>&|()#$]" pattern beg)
 			(setq pattern
 			      (concat (substring pattern 0 (match-beginning 0))
 				      "\\"
 				      (substring pattern (match-beginning 0)))
 			      beg (1+ (match-end 0))))
-		      (call-process shell-file-name nil t nil
-				    "-c" (concat "\\";; Disregard shell aliases!
-						 insert-directory-program
-						 " -d "
-						 (if (stringp switches)
-						     switches
-						   (mapconcat 'identity switches " "))
-						 " -- "
-						  pattern)))
+		      (call-process
+                       shell-file-name nil t nil
+                       "-c" (concat "\\" ; Disregard shell aliases!
+                                    insert-directory-program
+                                    " -d "
+                                    (if (stringp switches)
+                                        switches
+                                        (mapconcat 'identity switches " "))
+                                    " -- "
+                                    pattern)))
 		  ;; SunOS 4.1.3, SVr4 and others need the "." to list the
 		  ;; directory if FILE is a symbolic link.
 		  (apply 'call-process
 			  insert-directory-program nil t nil
-			  (let (list)
-			    (if (listp switches)
-				(setq list switches)
-			      (if (not (equal switches ""))
-				  (progn
-				    ;; Split the switches at any spaces
-				    ;; so we can pass separate options as separate args.
-				    (while (string-match " " switches)
-				      (setq list (cons (substring switches 0 (match-beginning 0))
-						       list)
-					    switches (substring switches (match-end 0))))
-				    (setq list (nreverse (cons switches list))))))
-			    (append list
-				    ;; Avoid lossage if FILE starts with `-'.
-				    '("--")
-				    (progn
-				      (if (string-match "\\`~" file)
-					  (setq file (expand-file-name file)))
-				      (list
-				       (if full-directory-p
-					   (concat (file-name-as-directory file) ".")
-					 file)))))))))
+                          (append
+                           (if (listp switches) switches
+                               (unless (equal switches "")
+                                 ;; Split the switches at any spaces so we can
+                                 ;; pass separate options as separate args.
+                                 (split-string switches)))
+                           ;; Avoid lossage if FILE starts with `-'.
+                           '("--")
+                           (progn
+                             (if (string-match "\\`~" file)
+                                 (setq file (expand-file-name file)))
+                             (list
+                              (if full-directory-p
+                                  (concat (file-name-as-directory file) ".")
+                                  file))))))))
 	  (if (/= result 0)
-	      ;; We get here if ls failed.
+	      ;; We get here if `insert-directory-program' failed.
 	      ;; Access the file to get a suitable error.
 	      (access-file file "Reading directory")
 	    ;; Replace "total" with "used", to avoid confusion.
@@ -3534,7 +3526,7 @@
 		      (forward-word -1)
 		      (setq available (buffer-substring (point) end))))
 		  (insert " available " available))))))))))
-		    
+
 (defvar kill-emacs-query-functions nil
   "Functions to call with no arguments to query about killing Emacs.
 If any of these functions returns nil, killing Emacs is cancelled.