changeset 5474:239620e1795d

(shell-cd): Function removed. (shell-prefixed-directory-name): New defsubst. (shell-process-popd, shell-process-pushd, shell-process-cd, shell-resync-dirs): Apply it to ARG when it's a directory name. Use (concat comint-file-name-prefix "~") in place of (getenv "HOME") or "~". Call cd instead of shell-cd.
author Roland McGrath <roland@gnu.org>
date Thu, 06 Jan 1994 17:02:00 +0000
parents e080a27c1dd6
children e723f6be6239
files lisp/shell.el
diffstat 1 files changed, 22 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/shell.el	Thu Jan 06 16:49:05 1994 +0000
+++ b/lisp/shell.el	Thu Jan 06 17:02:00 1994 +0000
@@ -416,18 +416,11 @@
 				 (match-end 0)))))
 	(error (message "Couldn't cd")))))
 
-
-;; Like `cd', but prepends comint-file-name-prefix to absolute names.
-(defsubst shell-cd (directory)
-  (if (file-name-absolute-p directory)
-      (cd-absolute (concat comint-file-name-prefix directory))
-    (cd directory)))
-
 ;;; popd [+n]
 (defun shell-process-popd (arg)
   (let ((num (or (shell-extract-num arg) 0)))
     (cond ((and num (= num 0) shell-dirstack)
-	   (shell-cd (car shell-dirstack))
+	   (cd (car shell-dirstack))
 	   (setq shell-dirstack (cdr shell-dirstack))
 	   (shell-dirstack-message))
 	  ((and num (> num 0) (<= num (length shell-dirstack)))
@@ -439,13 +432,22 @@
 	  (t
 	   (error (message "Couldn't popd."))))))
 
+;; Return DIR prefixed with comint-file-name-prefix as appropriate.
+(defsubst shell-prefixed-directory-name (dir)
+  (if (file-name-absolute-p dir)
+      ;; The name is absolute, so prepend the prefix.
+      (concat comint-file-name-prefix dir)
+    ;; For a relative name we assume default-directory already has the prefix.
+    (expand-file-name dir)))
+
 ;;; cd [dir]
 (defun shell-process-cd (arg)
-  (let ((new-dir (cond ((zerop (length arg)) (getenv "HOME"))
+  (let ((new-dir (cond ((zerop (length arg)) (concat comint-file-name-prefix
+						     "~"))
 		       ((string-equal "-" arg) shell-last-dir)
-		       (t arg))))
+		       (t (shell-prefixed-directory-name arg)))))
     (setq shell-last-dir default-directory)
-    (shell-cd new-dir)
+    (cd new-dir)
     (shell-dirstack-message)))
 
 ;;; pushd [+n | dir]
@@ -454,10 +456,10 @@
     (cond ((zerop (length arg))
 	   ;; no arg -- swap pwd and car of stack unless shell-pushd-tohome
 	   (cond (shell-pushd-tohome
-		  (shell-process-pushd "~"))
+		  (shell-process-pushd (concat comint-file-name-prefix "~")))
 		 (shell-dirstack
 		  (let ((old default-directory))
-		    (shell-cd (car shell-dirstack))
+		    (cd (car shell-dirstack))
 		    (setq shell-dirstack
 			  (cons old (cdr shell-dirstack)))
 		    (shell-dirstack-message)))
@@ -473,7 +475,7 @@
 		  (let ((dir (nth (1- num) shell-dirstack)))
 		    (shell-process-popd arg)
 		    (shell-process-pushd default-directory)
-		    (shell-cd dir)
+		    (cd dir)
 		    (shell-dirstack-message)))
 		 (t
 		  (let* ((ds (cons default-directory shell-dirstack))
@@ -481,13 +483,13 @@
 			 (front (nthcdr num ds))
 			 (back (reverse (nthcdr (- dslen num) (reverse ds))))
 			 (new-ds (append front back)))
-		    (shell-cd (car new-ds))
+		    (cd (car new-ds))
 		    (setq shell-dirstack (cdr new-ds))
 		    (shell-dirstack-message)))))
 	  (t
 	   ;; pushd <dir>
 	   (let ((old-wd default-directory))
-	     (shell-cd arg)
+	     (cd (shell-prefixed-directory-name arg))
 	     (if (or (null shell-pushd-dunique)
 		     (not (member old-wd shell-dirstack)))
 		 (setq shell-dirstack (cons old-wd shell-dirstack)))
@@ -543,10 +545,12 @@
       (while (< i dl-len)
 	;; regexp = optional whitespace, (non-whitespace), optional whitespace
 	(string-match "\\s *\\(\\S +\\)\\s *" dl i) ; pick off next dir
-	(setq ds (cons (substring dl (match-beginning 1) (match-end 1))
+	(setq ds (cons (concat comint-file-name-prefix
+			       (substring dl (match-beginning 1)
+					  (match-end 1)))
 		       ds))
 	(setq i (match-end 0)))
-      (let ((ds (reverse ds)))
+      (let ((ds (nreverse ds)))
 	(condition-case nil
 	    (progn (cd (car ds))
 		   (setq shell-dirstack (cdr ds))