]> code.delx.au - gnu-emacs/blobdiff - lisp/shell.el
Rename `MS-DOG' into `MS-DOS'.
[gnu-emacs] / lisp / shell.el
index 0f71d8d820558e1de65fba8b50a605de5a25afc2..71b5862feb6aea1e624ab88309d68adfa3d5aab7 100644 (file)
@@ -1,7 +1,7 @@
 ;;; 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>
@@ -574,7 +574,7 @@ Otherwise, one argument `-i' is passed to the shell.
 ;;; 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.
 ;;;
@@ -608,7 +608,7 @@ It watches for cd, pushd and popd commands and sets the buffer's
 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',
@@ -797,19 +797,26 @@ command again."
   (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
@@ -922,7 +929,7 @@ See `shell-command-regexp'."
 (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.