summaryrefslogtreecommitdiff
path: root/lisp/shell.el
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1993-09-08 07:06:46 +0000
committerRoland McGrath <roland@gnu.org>1993-09-08 07:06:46 +0000
commitab4c28e61c59a35ff1511e84392c42c9a5fc999c (patch)
tree9325dffa82880120aa9b1d5dda30de6607811533 /lisp/shell.el
parent37a664c0572fe2c6b68274fed96742c0c12f4cf8 (diff)
downloademacs-ab4c28e61c59a35ff1511e84392c42c9a5fc999c.tar.gz
(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.
Diffstat (limited to 'lisp/shell.el')
-rw-r--r--lisp/shell.el20
1 files changed, 12 insertions, 8 deletions
diff --git a/lisp/shell.el b/lisp/shell.el
index ef7474ae822..530ea4478ac 100644
--- a/lisp/shell.el
+++ b/lisp/shell.el
@@ -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.")))))))