comparison lisp/shell.el @ 2351:bb1ff4e31fb6

Brent Benson's patch to support `cd -'.
author Eric S. Raymond <esr@snark.thyrsus.com>
date Thu, 25 Mar 1993 01:55:24 +0000
parents dd8e5024b4f9
children 250c60d32a5a
comparison
equal deleted inserted replaced
2350:368fe26e6f33 2351:bb1ff4e31fb6
50 50
51 ;; YOUR .EMACS FILE 51 ;; YOUR .EMACS FILE
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:
71 ;;;============================================================================ 71 ;;;============================================================================
72 ;;; Comint Mode Commands: (common to shell and all comint-derived modes) 72 ;;; Comint Mode Commands: (common to shell and all comint-derived modes)
178 178
179 (defvar shell-dirstack nil 179 (defvar shell-dirstack 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
186 (defvar shell-mode-map '()) 189 (defvar shell-mode-map '())
187 (cond ((not shell-mode-map) 190 (cond ((not shell-mode-map)
227 (setq major-mode 'shell-mode) 230 (setq major-mode 'shell-mode)
228 (setq mode-name "shell") 231 (setq mode-name "shell")
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)
235 (run-hooks 'shell-mode-hook)) 239 (run-hooks 'shell-mode-hook))
236 240
387 (message "Bad popd.")))) 391 (message "Bad popd."))))
388 392
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)
400 (if (zerop (length arg)) 408 (if (zerop (length arg))
401 ;; no arg -- swap pwd and car of shell stack 409 ;; no arg -- swap pwd and car of shell stack
610 ;;; - Moved comint-dynamic-complete (filename completion) from M-tab to tab. 618 ;;; - Moved comint-dynamic-complete (filename completion) from M-tab to tab.
611 ;;; 619 ;;;
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
618 ;;; shell.el ends here 630 ;;; shell.el ends here