diff options
Diffstat (limited to 'lisp/shell.el')
-rw-r--r-- | lisp/shell.el | 20 |
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."))))))) |