]> code.delx.au - gnu-emacs/blobdiff - lisp/shell.el
Rename `MS-DOG' into `MS-DOS'.
[gnu-emacs] / lisp / shell.el
index a8f4790a0543236100b7a1ee45674392df4e7869..71b5862feb6aea1e624ab88309d68adfa3d5aab7 100644 (file)
@@ -1,6 +1,7 @@
 ;;; shell.el --- specialized comint.el for running the shell
 
-;; Copyright (C) 1988, 93, 94, 95, 96, 1997, 2000 Free Software Foundation, Inc.
+;; Copyright (C) 1988, 1993, 1994, 1995, 1996, 1997, 2000,
+;;   2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 
 ;; Author: Olin Shivers <shivers@cs.cmu.edu>
 ;;     Simon Marshall <simon@gnu.org>
@@ -21,8 +22,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 
@@ -411,7 +412,7 @@ Variable `shell-completion-fignore' is used to initialize the value of
 `comint-completion-fignore'.
 
 Variables `comint-input-ring-file-name' and `comint-input-autoexpand' control
-the initialisation of the input ring history, and history expansion.
+the initialization of the input ring history, and history expansion.
 
 Variables `comint-output-filter-functions', a hook, and
 `comint-scroll-to-bottom-on-input' and `comint-scroll-to-bottom-on-output'
@@ -573,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.
 ;;;
@@ -607,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',
@@ -790,25 +791,32 @@ line output and parses it to form the new directory stack.
 DON'T issue this command unless the buffer is at a shell prompt.
 Also, note that if some other subprocess decides to do output
 immediately after the query, its output will be taken as the
-new directory stack -- you lose. If this happens, just do the
+new directory stack -- you lose.  If this happens, just do the
 command again."
   (interactive)
   (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
@@ -921,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.