diff options
| author | Eric S. Raymond | 1993-03-25 01:55:24 +0000 |
|---|---|---|
| committer | Eric S. Raymond | 1993-03-25 01:55:24 +0000 |
| commit | fa8f1b2563145056f0884f5a9d7de18a5226a8b1 (patch) | |
| tree | 1234450e610490d092601d63bb86ca9c99b5b02c | |
| parent | d352289cebade5fbef93b9138c75426461856750 (diff) | |
| download | emacs-fa8f1b2563145056f0884f5a9d7de18a5226a8b1.tar.gz emacs-fa8f1b2563145056f0884f5a9d7de18a5226a8b1.zip | |
Brent Benson's patch to support `cd -'.
| -rw-r--r-- | lisp/shell.el | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/lisp/shell.el b/lisp/shell.el index b16ac2431fa..88e62c64361 100644 --- a/lisp/shell.el +++ b/lisp/shell.el | |||
| @@ -52,19 +52,19 @@ | |||
| 52 | ;;============================================================================= | 52 | ;;============================================================================= |
| 53 | ;; Some suggestions for your .emacs file. | 53 | ;; Some suggestions for your .emacs file. |
| 54 | ;; | 54 | ;; |
| 55 | ;; ; If cmushell lives in some non-standard directory, you must tell emacs | 55 | ;; ; If shell lives in some non-standard directory, you must tell emacs |
| 56 | ;; ; where to get it. This may or may not be necessary. | 56 | ;; ; where to get it. This may or may not be necessary. |
| 57 | ;; (setq load-path (cons (expand-file-name "~jones/lib/emacs") load-path)) | 57 | ;; (setq load-path (cons (expand-file-name "~jones/lib/emacs") load-path)) |
| 58 | ;; | 58 | ;; |
| 59 | ;; ; Autoload cmushell from file cmushell.el | 59 | ;; ; Autoload shell from file shell.el |
| 60 | ;; (autoload 'cmushell "cmushell" | 60 | ;; (autoload 'shell "shell" |
| 61 | ;; "Run an inferior shell process." | 61 | ;; "Run an inferior shell process." |
| 62 | ;; t) | 62 | ;; t) |
| 63 | ;; | 63 | ;; |
| 64 | ;; ; Define C-c t to run my favorite command in cmushell mode: | 64 | ;; ; Define C-c t to run my favorite command in shell mode: |
| 65 | ;; (setq cmushell-load-hook | 65 | ;; (setq shell-load-hook |
| 66 | ;; '((lambda () | 66 | ;; '((lambda () |
| 67 | ;; (define-key cmushell-mode-map "\C-ct" 'favorite-cmd)))) | 67 | ;; (define-key shell-mode-map "\C-ct" 'favorite-cmd)))) |
| 68 | 68 | ||
| 69 | 69 | ||
| 70 | ;;; Brief Command Documentation: | 70 | ;;; Brief Command Documentation: |
| @@ -180,6 +180,9 @@ Value is a list of strings, which may be nil.") | |||
| 180 | "List of directories saved by pushd in this buffer's shell. | 180 | "List of directories saved by pushd in this buffer's shell. |
| 181 | Thus, this does not include the shell's current directory.") | 181 | Thus, this does not include the shell's current directory.") |
| 182 | 182 | ||
| 183 | (defvar shell-last-dir nil | ||
| 184 | "Keep track of last directory for ksh `cd -' command.") | ||
| 185 | |||
| 183 | (defvar shell-dirstack-query "dirs" | 186 | (defvar shell-dirstack-query "dirs" |
| 184 | "Command used by shell-resync-dirlist to query shell.") | 187 | "Command used by shell-resync-dirlist to query shell.") |
| 185 | 188 | ||
| @@ -229,6 +232,7 @@ to match their respective commands." | |||
| 229 | (use-local-map shell-mode-map) | 232 | (use-local-map shell-mode-map) |
| 230 | (make-local-variable 'shell-dirstack) | 233 | (make-local-variable 'shell-dirstack) |
| 231 | (setq shell-dirstack nil) | 234 | (setq shell-dirstack nil) |
| 235 | (setq shell-last-dir nil) | ||
| 232 | (make-local-variable 'shell-dirtrackp) | 236 | (make-local-variable 'shell-dirtrackp) |
| 233 | (setq shell-dirtrackp t) | 237 | (setq shell-dirtrackp t) |
| 234 | (setq comint-input-sentinel 'shell-directory-tracker) | 238 | (setq comint-input-sentinel 'shell-directory-tracker) |
| @@ -389,11 +393,15 @@ Environment variables are expanded, see function substitute-in-file-name." | |||
| 389 | 393 | ||
| 390 | ;;; cd [dir] | 394 | ;;; cd [dir] |
| 391 | (defun shell-process-cd (arg) | 395 | (defun shell-process-cd (arg) |
| 392 | (condition-case nil (progn (cd (if (zerop (length arg)) (getenv "HOME") | 396 | (condition-case nil |
| 393 | arg)) | 397 | (let ((new-dir (cond |
| 394 | (shell-dirstack-message)) | 398 | ((zerop (length arg)) (getenv "HOME")) |
| 395 | (error (message "Couldn't cd.")))) | 399 | ((string-equal "-" arg) shell-last-dir) |
| 396 | 400 | (t arg)))) | |
| 401 | (setq shell-last-dir default-directory) | ||
| 402 | (cd new-dir) | ||
| 403 | (shell-dirstack-message)) | ||
| 404 | (error (message "Couldn't cd.")))) | ||
| 397 | 405 | ||
| 398 | ;;; pushd [+n | dir] | 406 | ;;; pushd [+n | dir] |
| 399 | (defun shell-process-pushd (arg) | 407 | (defun shell-process-pushd (arg) |
| @@ -612,6 +620,10 @@ This is a good place to put keybindings.") | |||
| 612 | ;;; Jim Blandy 10/30/91 | 620 | ;;; Jim Blandy 10/30/91 |
| 613 | ;;; - Removed the "cmu" prefix from names, renamed file to shell.el, | 621 | ;;; - Removed the "cmu" prefix from names, renamed file to shell.el, |
| 614 | ;;; to become the standard shell package. | 622 | ;;; to become the standard shell package. |
| 623 | ;;; | ||
| 624 | ;;; Eric Raymond 3/23/93 | ||
| 625 | ;;; - Merged in Brent Benson's patch to handle cd -. Made some more | ||
| 626 | ;;; cmushell -> shell changes. | ||
| 615 | 627 | ||
| 616 | (provide 'shell) | 628 | (provide 'shell) |
| 617 | 629 | ||