Commit 9dac0433 authored by Roland McGrath's avatar Roland McGrath
Browse files

(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.
parent 36df718c
......@@ -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.")))))))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment