]> git.eshelyaron.com Git - emacs.git/commitdiff
(shell-cd): New function, like `cd' but prepend comint-filename-prefix.
authorRoland McGrath <roland@gnu.org>
Wed, 8 Sep 1993 07:06:46 +0000 (07:06 +0000)
committerRoland McGrath <roland@gnu.org>
Wed, 8 Sep 1993 07:06:46 +0000 (07:06 +0000)
(shell-resync-dirs, shell-process-cd, shell-process-pushd,
shell-process-popd): Use shell-cd in place of cd.

lisp/shell.el

index ef7474ae8225f40f9451f411745a9e2ced89c12e..530ea4478ac4131d400f029742c4ce2963af660e 100644 (file)
@@ -376,14 +376,19 @@ Environment variables are expanded, see function `substitute-in-file-name'."
 ;;;     (";" 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 @@ Environment variables are expanded, see function `substitute-in-file-name'."
                       ((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 @@ Environment variables are expanded, see function `substitute-in-file-name'."
       ;; 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 @@ Environment variables are expanded, see function `substitute-in-file-name'."
                       (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 @@ Environment variables are expanded, see function `substitute-in-file-name'."
            ;; 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 @@ command again."
        (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.")))))))