changeset 4677:835ecfabae68

(shell-cd): New function, like `cd' but prepend comint-filename-prefix. (shell-resync-dirs, shell-process-cd, shell-process-pushd, shell-process-popd): Use shell-cd in place of cd.
author Roland McGrath <roland@gnu.org>
date Wed, 08 Sep 1993 07:06:46 +0000
parents a95bec390bc3
children cd842296bebf
files lisp/shell.el
diffstat 1 files changed, 12 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/shell.el	Wed Sep 08 07:01:42 1993 +0000
+++ b/lisp/shell.el	Wed Sep 08 07:06:46 1993 +0000
@@ -376,14 +376,19 @@
 ;;;     (";" or end of string)].
 
 
+;; Like `cd', but prepends comint-filename-prefix to absolute names.
+(defsubst shell-cd (directory)
+  (if (file-name-absolute-p directory)
+      (cd-absolute (concat comint-filename-prefix directory))
+    (cd directory)))
+
 ;;; popd [+n]
 (defun shell-process-popd (arg)
   (let ((num (if (zerop (length arg)) 0 ; no arg means +0
 		 (shell-extract-num arg))))
     (if (and num (< num (length shell-dirstack)))
 	(if (= num 0) ; condition-case because the CD could lose.
-	    (condition-case nil (progn (cd (concat comint-filename-prefix
-						   (car shell-dirstack)))
+	    (condition-case nil (progn (shell-cd (car shell-dirstack))
 				       (setq shell-dirstack
 					     (cdr shell-dirstack))
 				       (shell-dirstack-message))
@@ -404,7 +409,7 @@
                       ((string-equal "-" arg) shell-last-dir)
                       (t arg))))
        (setq shell-last-dir default-directory)
-       (cd (concat comint-filename-prefix new-dir))
+       (shell-cd new-dir)
        (shell-dirstack-message))
     (error (message "Couldn't cd."))))
 
@@ -414,8 +419,7 @@
       ;; no arg -- swap pwd and car of shell stack
       (condition-case nil (if shell-dirstack
 			      (let ((old default-directory))
-				(cd (concat comint-filename-prefix
-					    (car shell-dirstack)))
+				(shell-cd (car shell-dirstack))
 				(setq shell-dirstack
 				      (cons old (cdr shell-dirstack)))
 				(shell-dirstack-message))
@@ -433,7 +437,7 @@
 		       (back (reverse (nthcdr (- dslen num) (reverse ds))))
 		       (new-ds (append front back)))
 		  (condition-case nil
-		      (progn (cd (concat comint-filename-prefix (car new-ds)))
+		      (progn (shell-cd (car new-ds))
 			     (setq shell-dirstack (cdr new-ds))
 			     (shell-dirstack-message))
 		    (error (message "Couldn't cd.")))))
@@ -441,7 +445,7 @@
 	    ;; pushd <dir>
 	    (let ((old-wd default-directory))
 	      (condition-case nil
-		  (progn (cd (concat comint-filename-prefix arg))
+		  (progn (shell-cd arg)
 			 (setq shell-dirstack
 			       (cons old-wd shell-dirstack))
 			 (shell-dirstack-message))
@@ -503,7 +507,7 @@
 	(setq i (match-end 0)))
       (let ((ds (reverse ds)))
 	(condition-case nil
-	    (progn (cd (concat comint-filename-prefix (car ds)))
+	    (progn (shell-cd (car ds))
 		   (setq shell-dirstack (cdr ds))
 		   (shell-dirstack-message))
 	  (error (message "Couldn't cd.")))))))