diff options
| author | Roland McGrath | 1994-01-06 17:02:00 +0000 |
|---|---|---|
| committer | Roland McGrath | 1994-01-06 17:02:00 +0000 |
| commit | 3db9a4ebb4a0a2730428dca65bd30fdcc352b49c (patch) | |
| tree | 9e295cf35854b14dc053b736a4ec5b35ff7a793b /lisp/shell.el | |
| parent | 03dcd202f4ae02d0088c02cc0c154ed38b3f681f (diff) | |
| download | emacs-3db9a4ebb4a0a2730428dca65bd30fdcc352b49c.tar.gz emacs-3db9a4ebb4a0a2730428dca65bd30fdcc352b49c.zip | |
(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.
Diffstat (limited to 'lisp/shell.el')
| -rw-r--r-- | lisp/shell.el | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/lisp/shell.el b/lisp/shell.el index 7550d7f4a67..18fd50f822d 100644 --- a/lisp/shell.el +++ b/lisp/shell.el | |||
| @@ -416,18 +416,11 @@ Environment variables are expanded, see function `substitute-in-file-name'." | |||
| 416 | (match-end 0))))) | 416 | (match-end 0))))) |
| 417 | (error (message "Couldn't cd"))))) | 417 | (error (message "Couldn't cd"))))) |
| 418 | 418 | ||
| 419 | |||
| 420 | ;; Like `cd', but prepends comint-file-name-prefix to absolute names. | ||
| 421 | (defsubst shell-cd (directory) | ||
| 422 | (if (file-name-absolute-p directory) | ||
| 423 | (cd-absolute (concat comint-file-name-prefix directory)) | ||
| 424 | (cd directory))) | ||
| 425 | |||
| 426 | ;;; popd [+n] | 419 | ;;; popd [+n] |
| 427 | (defun shell-process-popd (arg) | 420 | (defun shell-process-popd (arg) |
| 428 | (let ((num (or (shell-extract-num arg) 0))) | 421 | (let ((num (or (shell-extract-num arg) 0))) |
| 429 | (cond ((and num (= num 0) shell-dirstack) | 422 | (cond ((and num (= num 0) shell-dirstack) |
| 430 | (shell-cd (car shell-dirstack)) | 423 | (cd (car shell-dirstack)) |
| 431 | (setq shell-dirstack (cdr shell-dirstack)) | 424 | (setq shell-dirstack (cdr shell-dirstack)) |
| 432 | (shell-dirstack-message)) | 425 | (shell-dirstack-message)) |
| 433 | ((and num (> num 0) (<= num (length shell-dirstack))) | 426 | ((and num (> num 0) (<= num (length shell-dirstack))) |
| @@ -439,13 +432,22 @@ Environment variables are expanded, see function `substitute-in-file-name'." | |||
| 439 | (t | 432 | (t |
| 440 | (error (message "Couldn't popd.")))))) | 433 | (error (message "Couldn't popd.")))))) |
| 441 | 434 | ||
| 435 | ;; Return DIR prefixed with comint-file-name-prefix as appropriate. | ||
| 436 | (defsubst shell-prefixed-directory-name (dir) | ||
| 437 | (if (file-name-absolute-p dir) | ||
| 438 | ;; The name is absolute, so prepend the prefix. | ||
| 439 | (concat comint-file-name-prefix dir) | ||
| 440 | ;; For a relative name we assume default-directory already has the prefix. | ||
| 441 | (expand-file-name dir))) | ||
| 442 | |||
| 442 | ;;; cd [dir] | 443 | ;;; cd [dir] |
| 443 | (defun shell-process-cd (arg) | 444 | (defun shell-process-cd (arg) |
| 444 | (let ((new-dir (cond ((zerop (length arg)) (getenv "HOME")) | 445 | (let ((new-dir (cond ((zerop (length arg)) (concat comint-file-name-prefix |
| 446 | "~")) | ||
| 445 | ((string-equal "-" arg) shell-last-dir) | 447 | ((string-equal "-" arg) shell-last-dir) |
| 446 | (t arg)))) | 448 | (t (shell-prefixed-directory-name arg))))) |
| 447 | (setq shell-last-dir default-directory) | 449 | (setq shell-last-dir default-directory) |
| 448 | (shell-cd new-dir) | 450 | (cd new-dir) |
| 449 | (shell-dirstack-message))) | 451 | (shell-dirstack-message))) |
| 450 | 452 | ||
| 451 | ;;; pushd [+n | dir] | 453 | ;;; pushd [+n | dir] |
| @@ -454,10 +456,10 @@ Environment variables are expanded, see function `substitute-in-file-name'." | |||
| 454 | (cond ((zerop (length arg)) | 456 | (cond ((zerop (length arg)) |
| 455 | ;; no arg -- swap pwd and car of stack unless shell-pushd-tohome | 457 | ;; no arg -- swap pwd and car of stack unless shell-pushd-tohome |
| 456 | (cond (shell-pushd-tohome | 458 | (cond (shell-pushd-tohome |
| 457 | (shell-process-pushd "~")) | 459 | (shell-process-pushd (concat comint-file-name-prefix "~"))) |
| 458 | (shell-dirstack | 460 | (shell-dirstack |
| 459 | (let ((old default-directory)) | 461 | (let ((old default-directory)) |
| 460 | (shell-cd (car shell-dirstack)) | 462 | (cd (car shell-dirstack)) |
| 461 | (setq shell-dirstack | 463 | (setq shell-dirstack |
| 462 | (cons old (cdr shell-dirstack))) | 464 | (cons old (cdr shell-dirstack))) |
| 463 | (shell-dirstack-message))) | 465 | (shell-dirstack-message))) |
| @@ -473,7 +475,7 @@ Environment variables are expanded, see function `substitute-in-file-name'." | |||
| 473 | (let ((dir (nth (1- num) shell-dirstack))) | 475 | (let ((dir (nth (1- num) shell-dirstack))) |
| 474 | (shell-process-popd arg) | 476 | (shell-process-popd arg) |
| 475 | (shell-process-pushd default-directory) | 477 | (shell-process-pushd default-directory) |
| 476 | (shell-cd dir) | 478 | (cd dir) |
| 477 | (shell-dirstack-message))) | 479 | (shell-dirstack-message))) |
| 478 | (t | 480 | (t |
| 479 | (let* ((ds (cons default-directory shell-dirstack)) | 481 | (let* ((ds (cons default-directory shell-dirstack)) |
| @@ -481,13 +483,13 @@ Environment variables are expanded, see function `substitute-in-file-name'." | |||
| 481 | (front (nthcdr num ds)) | 483 | (front (nthcdr num ds)) |
| 482 | (back (reverse (nthcdr (- dslen num) (reverse ds)))) | 484 | (back (reverse (nthcdr (- dslen num) (reverse ds)))) |
| 483 | (new-ds (append front back))) | 485 | (new-ds (append front back))) |
| 484 | (shell-cd (car new-ds)) | 486 | (cd (car new-ds)) |
| 485 | (setq shell-dirstack (cdr new-ds)) | 487 | (setq shell-dirstack (cdr new-ds)) |
| 486 | (shell-dirstack-message))))) | 488 | (shell-dirstack-message))))) |
| 487 | (t | 489 | (t |
| 488 | ;; pushd <dir> | 490 | ;; pushd <dir> |
| 489 | (let ((old-wd default-directory)) | 491 | (let ((old-wd default-directory)) |
| 490 | (shell-cd arg) | 492 | (cd (shell-prefixed-directory-name arg)) |
| 491 | (if (or (null shell-pushd-dunique) | 493 | (if (or (null shell-pushd-dunique) |
| 492 | (not (member old-wd shell-dirstack))) | 494 | (not (member old-wd shell-dirstack))) |
| 493 | (setq shell-dirstack (cons old-wd shell-dirstack))) | 495 | (setq shell-dirstack (cons old-wd shell-dirstack))) |
| @@ -543,10 +545,12 @@ command again." | |||
| 543 | (while (< i dl-len) | 545 | (while (< i dl-len) |
| 544 | ;; regexp = optional whitespace, (non-whitespace), optional whitespace | 546 | ;; regexp = optional whitespace, (non-whitespace), optional whitespace |
| 545 | (string-match "\\s *\\(\\S +\\)\\s *" dl i) ; pick off next dir | 547 | (string-match "\\s *\\(\\S +\\)\\s *" dl i) ; pick off next dir |
| 546 | (setq ds (cons (substring dl (match-beginning 1) (match-end 1)) | 548 | (setq ds (cons (concat comint-file-name-prefix |
| 549 | (substring dl (match-beginning 1) | ||
| 550 | (match-end 1))) | ||
| 547 | ds)) | 551 | ds)) |
| 548 | (setq i (match-end 0))) | 552 | (setq i (match-end 0))) |
| 549 | (let ((ds (reverse ds))) | 553 | (let ((ds (nreverse ds))) |
| 550 | (condition-case nil | 554 | (condition-case nil |
| 551 | (progn (cd (car ds)) | 555 | (progn (cd (car ds)) |
| 552 | (setq shell-dirstack (cdr ds)) | 556 | (setq shell-dirstack (cdr ds)) |