1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-16 10:50:49 -08:00

(shell-cd): Function removed.

(shell-prefixed-directory-name): New defsubst.
(shell-process-popd, shell-process-pushd, shell-process-cd,
shell-resync-dirs): Apply it to ARG when it's a directory name.
Use (concat comint-file-name-prefix "~") in place of (getenv "HOME") or "~".
Call cd instead of shell-cd.
This commit is contained in:
Roland McGrath 1994-01-06 17:02:00 +00:00
parent 03dcd202f4
commit 3db9a4ebb4

View file

@ -416,18 +416,11 @@ Environment variables are expanded, see function `substitute-in-file-name'."
(match-end 0))))) (match-end 0)))))
(error (message "Couldn't cd"))))) (error (message "Couldn't cd")))))
;; Like `cd', but prepends comint-file-name-prefix to absolute names.
(defsubst shell-cd (directory)
(if (file-name-absolute-p directory)
(cd-absolute (concat comint-file-name-prefix directory))
(cd directory)))
;;; popd [+n] ;;; popd [+n]
(defun shell-process-popd (arg) (defun shell-process-popd (arg)
(let ((num (or (shell-extract-num arg) 0))) (let ((num (or (shell-extract-num arg) 0)))
(cond ((and num (= num 0) shell-dirstack) (cond ((and num (= num 0) shell-dirstack)
(shell-cd (car shell-dirstack)) (cd (car shell-dirstack))
(setq shell-dirstack (cdr shell-dirstack)) (setq shell-dirstack (cdr shell-dirstack))
(shell-dirstack-message)) (shell-dirstack-message))
((and num (> num 0) (<= num (length shell-dirstack))) ((and num (> num 0) (<= num (length shell-dirstack)))
@ -439,13 +432,22 @@ Environment variables are expanded, see function `substitute-in-file-name'."
(t (t
(error (message "Couldn't popd.")))))) (error (message "Couldn't popd."))))))
;; Return DIR prefixed with comint-file-name-prefix as appropriate.
(defsubst shell-prefixed-directory-name (dir)
(if (file-name-absolute-p dir)
;; The name is absolute, so prepend the prefix.
(concat comint-file-name-prefix dir)
;; For a relative name we assume default-directory already has the prefix.
(expand-file-name dir)))
;;; cd [dir] ;;; cd [dir]
(defun shell-process-cd (arg) (defun shell-process-cd (arg)
(let ((new-dir (cond ((zerop (length arg)) (getenv "HOME")) (let ((new-dir (cond ((zerop (length arg)) (concat comint-file-name-prefix
"~"))
((string-equal "-" arg) shell-last-dir) ((string-equal "-" arg) shell-last-dir)
(t arg)))) (t (shell-prefixed-directory-name arg)))))
(setq shell-last-dir default-directory) (setq shell-last-dir default-directory)
(shell-cd new-dir) (cd new-dir)
(shell-dirstack-message))) (shell-dirstack-message)))
;;; pushd [+n | dir] ;;; pushd [+n | dir]
@ -454,10 +456,10 @@ Environment variables are expanded, see function `substitute-in-file-name'."
(cond ((zerop (length arg)) (cond ((zerop (length arg))
;; no arg -- swap pwd and car of stack unless shell-pushd-tohome ;; no arg -- swap pwd and car of stack unless shell-pushd-tohome
(cond (shell-pushd-tohome (cond (shell-pushd-tohome
(shell-process-pushd "~")) (shell-process-pushd (concat comint-file-name-prefix "~")))
(shell-dirstack (shell-dirstack
(let ((old default-directory)) (let ((old default-directory))
(shell-cd (car shell-dirstack)) (cd (car shell-dirstack))
(setq shell-dirstack (setq shell-dirstack
(cons old (cdr shell-dirstack))) (cons old (cdr shell-dirstack)))
(shell-dirstack-message))) (shell-dirstack-message)))
@ -473,7 +475,7 @@ Environment variables are expanded, see function `substitute-in-file-name'."
(let ((dir (nth (1- num) shell-dirstack))) (let ((dir (nth (1- num) shell-dirstack)))
(shell-process-popd arg) (shell-process-popd arg)
(shell-process-pushd default-directory) (shell-process-pushd default-directory)
(shell-cd dir) (cd dir)
(shell-dirstack-message))) (shell-dirstack-message)))
(t (t
(let* ((ds (cons default-directory shell-dirstack)) (let* ((ds (cons default-directory shell-dirstack))
@ -481,13 +483,13 @@ Environment variables are expanded, see function `substitute-in-file-name'."
(front (nthcdr num ds)) (front (nthcdr num ds))
(back (reverse (nthcdr (- dslen num) (reverse ds)))) (back (reverse (nthcdr (- dslen num) (reverse ds))))
(new-ds (append front back))) (new-ds (append front back)))
(shell-cd (car new-ds)) (cd (car new-ds))
(setq shell-dirstack (cdr new-ds)) (setq shell-dirstack (cdr new-ds))
(shell-dirstack-message))))) (shell-dirstack-message)))))
(t (t
;; pushd <dir> ;; pushd <dir>
(let ((old-wd default-directory)) (let ((old-wd default-directory))
(shell-cd arg) (cd (shell-prefixed-directory-name arg))
(if (or (null shell-pushd-dunique) (if (or (null shell-pushd-dunique)
(not (member old-wd shell-dirstack))) (not (member old-wd shell-dirstack)))
(setq shell-dirstack (cons old-wd shell-dirstack))) (setq shell-dirstack (cons old-wd shell-dirstack)))
@ -543,10 +545,12 @@ command again."
(while (< i dl-len) (while (< i dl-len)
;; regexp = optional whitespace, (non-whitespace), optional whitespace ;; regexp = optional whitespace, (non-whitespace), optional whitespace
(string-match "\\s *\\(\\S +\\)\\s *" dl i) ; pick off next dir (string-match "\\s *\\(\\S +\\)\\s *" dl i) ; pick off next dir
(setq ds (cons (substring dl (match-beginning 1) (match-end 1)) (setq ds (cons (concat comint-file-name-prefix
(substring dl (match-beginning 1)
(match-end 1)))
ds)) ds))
(setq i (match-end 0))) (setq i (match-end 0)))
(let ((ds (reverse ds))) (let ((ds (nreverse ds)))
(condition-case nil (condition-case nil
(progn (cd (car ds)) (progn (cd (car ds))
(setq shell-dirstack (cdr ds)) (setq shell-dirstack (cdr ds))