diff options
| author | Roland McGrath | 1993-09-08 07:06:46 +0000 |
|---|---|---|
| committer | Roland McGrath | 1993-09-08 07:06:46 +0000 |
| commit | 9dac04334996ac7124c11871112fc8a33618d752 (patch) | |
| tree | 3555750a07d053dba90141bbf918e0a0ed1d1728 | |
| parent | 36df718cbf8a6ac82bedc4d6ec244e6cd2db5abc (diff) | |
| download | emacs-9dac04334996ac7124c11871112fc8a33618d752.tar.gz emacs-9dac04334996ac7124c11871112fc8a33618d752.zip | |
(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.
| -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'." | |||
| 376 | ;;; (";" or end of string)]. | 376 | ;;; (";" or end of string)]. |
| 377 | 377 | ||
| 378 | 378 | ||
| 379 | ;; Like `cd', but prepends comint-filename-prefix to absolute names. | ||
| 380 | (defsubst shell-cd (directory) | ||
| 381 | (if (file-name-absolute-p directory) | ||
| 382 | (cd-absolute (concat comint-filename-prefix directory)) | ||
| 383 | (cd directory))) | ||
| 384 | |||
| 379 | ;;; popd [+n] | 385 | ;;; popd [+n] |
| 380 | (defun shell-process-popd (arg) | 386 | (defun shell-process-popd (arg) |
| 381 | (let ((num (if (zerop (length arg)) 0 ; no arg means +0 | 387 | (let ((num (if (zerop (length arg)) 0 ; no arg means +0 |
| 382 | (shell-extract-num arg)))) | 388 | (shell-extract-num arg)))) |
| 383 | (if (and num (< num (length shell-dirstack))) | 389 | (if (and num (< num (length shell-dirstack))) |
| 384 | (if (= num 0) ; condition-case because the CD could lose. | 390 | (if (= num 0) ; condition-case because the CD could lose. |
| 385 | (condition-case nil (progn (cd (concat comint-filename-prefix | 391 | (condition-case nil (progn (shell-cd (car shell-dirstack)) |
| 386 | (car shell-dirstack))) | ||
| 387 | (setq shell-dirstack | 392 | (setq shell-dirstack |
| 388 | (cdr shell-dirstack)) | 393 | (cdr shell-dirstack)) |
| 389 | (shell-dirstack-message)) | 394 | (shell-dirstack-message)) |
| @@ -404,7 +409,7 @@ Environment variables are expanded, see function `substitute-in-file-name'." | |||
| 404 | ((string-equal "-" arg) shell-last-dir) | 409 | ((string-equal "-" arg) shell-last-dir) |
| 405 | (t arg)))) | 410 | (t arg)))) |
| 406 | (setq shell-last-dir default-directory) | 411 | (setq shell-last-dir default-directory) |
| 407 | (cd (concat comint-filename-prefix new-dir)) | 412 | (shell-cd new-dir) |
| 408 | (shell-dirstack-message)) | 413 | (shell-dirstack-message)) |
| 409 | (error (message "Couldn't cd.")))) | 414 | (error (message "Couldn't cd.")))) |
| 410 | 415 | ||
| @@ -414,8 +419,7 @@ Environment variables are expanded, see function `substitute-in-file-name'." | |||
| 414 | ;; no arg -- swap pwd and car of shell stack | 419 | ;; no arg -- swap pwd and car of shell stack |
| 415 | (condition-case nil (if shell-dirstack | 420 | (condition-case nil (if shell-dirstack |
| 416 | (let ((old default-directory)) | 421 | (let ((old default-directory)) |
| 417 | (cd (concat comint-filename-prefix | 422 | (shell-cd (car shell-dirstack)) |
| 418 | (car shell-dirstack))) | ||
| 419 | (setq shell-dirstack | 423 | (setq shell-dirstack |
| 420 | (cons old (cdr shell-dirstack))) | 424 | (cons old (cdr shell-dirstack))) |
| 421 | (shell-dirstack-message)) | 425 | (shell-dirstack-message)) |
| @@ -433,7 +437,7 @@ Environment variables are expanded, see function `substitute-in-file-name'." | |||
| 433 | (back (reverse (nthcdr (- dslen num) (reverse ds)))) | 437 | (back (reverse (nthcdr (- dslen num) (reverse ds)))) |
| 434 | (new-ds (append front back))) | 438 | (new-ds (append front back))) |
| 435 | (condition-case nil | 439 | (condition-case nil |
| 436 | (progn (cd (concat comint-filename-prefix (car new-ds))) | 440 | (progn (shell-cd (car new-ds)) |
| 437 | (setq shell-dirstack (cdr new-ds)) | 441 | (setq shell-dirstack (cdr new-ds)) |
| 438 | (shell-dirstack-message)) | 442 | (shell-dirstack-message)) |
| 439 | (error (message "Couldn't cd."))))) | 443 | (error (message "Couldn't cd."))))) |
| @@ -441,7 +445,7 @@ Environment variables are expanded, see function `substitute-in-file-name'." | |||
| 441 | ;; pushd <dir> | 445 | ;; pushd <dir> |
| 442 | (let ((old-wd default-directory)) | 446 | (let ((old-wd default-directory)) |
| 443 | (condition-case nil | 447 | (condition-case nil |
| 444 | (progn (cd (concat comint-filename-prefix arg)) | 448 | (progn (shell-cd arg) |
| 445 | (setq shell-dirstack | 449 | (setq shell-dirstack |
| 446 | (cons old-wd shell-dirstack)) | 450 | (cons old-wd shell-dirstack)) |
| 447 | (shell-dirstack-message)) | 451 | (shell-dirstack-message)) |
| @@ -503,7 +507,7 @@ command again." | |||
| 503 | (setq i (match-end 0))) | 507 | (setq i (match-end 0))) |
| 504 | (let ((ds (reverse ds))) | 508 | (let ((ds (reverse ds))) |
| 505 | (condition-case nil | 509 | (condition-case nil |
| 506 | (progn (cd (concat comint-filename-prefix (car ds))) | 510 | (progn (shell-cd (car ds)) |
| 507 | (setq shell-dirstack (cdr ds)) | 511 | (setq shell-dirstack (cdr ds)) |
| 508 | (shell-dirstack-message)) | 512 | (shell-dirstack-message)) |
| 509 | (error (message "Couldn't cd."))))))) | 513 | (error (message "Couldn't cd."))))))) |