;;; shell.el --- specialized comint.el for running the shell
;; Copyright (C) 1988, 1993, 1994, 1995, 1996, 1997, 2000,
-;; 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+;; 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
;; Author: Olin Shivers <shivers@cs.cmu.edu>
;; Simon Marshall <simon@gnu.org>
;;; 2. It cannot infallibly deal with command sequences, though it does well
;;; with these and with ignoring commands forked in another shell with ()s.
;;; 3. More generally, any complex command is going to throw it. Otherwise,
-;;; you'd have to build an entire shell interpreter in emacs lisp. Failing
+;;; you'd have to build an entire shell interpreter in Emacs Lisp. Failing
;;; that, there's no way to catch shell commands where cd's are buried
;;; inside conditional expressions, aliases, and so forth.
;;;
default directory to track these commands.
You may toggle this tracking on and off with M-x dirtrack-mode.
-If emacs gets confused, you can resync with the shell with M-x dirs.
+If Emacs gets confused, you can resync with the shell with M-x dirs.
See variables `shell-cd-regexp', `shell-chdrive-regexp', `shell-pushd-regexp',
and `shell-popd-regexp', while `shell-pushd-tohome', `shell-pushd-dextract',
(let* ((proc (get-buffer-process (current-buffer)))
(pmark (process-mark proc)))
(goto-char pmark)
- (insert shell-dirstack-query) (insert "\n")
+ ;; If the process echoes commands, don't insert a fake command in
+ ;; the buffer or it will appear twice.
+ (unless comint-process-echoes
+ (insert shell-dirstack-query) (insert "\n"))
(sit-for 0) ; force redisplay
(comint-send-string proc shell-dirstack-query)
(comint-send-string proc "\n")
(set-marker pmark (point))
- (let ((pt (point))) ; wait for 1 line
+ (let ((pt (point))
+ (regexp
+ (concat
+ (if comint-process-echoes
+ ;; Skip command echo if the process echoes
+ (concat "\\(" (regexp-quote shell-dirstack-query) "\n\\)")
+ "\\(\\)")
+ "\\(.+\n\\)")))
;; This extra newline prevents the user's pending input from spoofing us.
(insert "\n") (backward-char 1)
- (while (not (looking-at
- (concat "\\(" ; skip literal echo in case of stty echo
- (regexp-quote shell-dirstack-query)
- "\n\\)?" ; skip if present
- "\\(" ".+\n" "\\)")) ) ; what to actually look for
+ ;; Wait for one line.
+ (while (not (looking-at regexp))
(accept-process-output proc)
(goto-char pt)))
(goto-char pmark) (delete-char 1) ; remove the extra newline
(defun shell-dynamic-complete-command ()
"Dynamically complete the command at point.
This function is similar to `comint-dynamic-complete-filename', except that it
-searches `exec-path' (minus the trailing emacs library path) for completion
+searches `exec-path' (minus the trailing Emacs library path) for completion
candidates. Note that this may not be the same as the shell's idea of the
path.