]> code.delx.au - gnu-emacs/blobdiff - lisp/comint.el
(tempo-local-tags, tempo-user-elements, tempo-use-tag-list):
[gnu-emacs] / lisp / comint.el
index ac73762903a204866105f7b283ffa26835474b17..f2fdffea9523a50be74bed8937c1e942bf2acad2 100644 (file)
@@ -1,6 +1,6 @@
 ;;; comint.el --- general command interpreter in a window stuff
 
-;; Copyright (C) 1988, 1990, 1992, 1993, 1994 Free Software Foundation, Inc.
+;; Copyright (C) 1988, 90, 92, 93, 94, 95 Free Software Foundation, Inc.
 
 ;; Author: Olin Shivers <shivers@cs.cmu.edu>
 ;; Adapted-by: Simon Marshall <simon@gnu.ai.mit.edu>
 ;;;     comint-input-filter-functions - hook     process-in-a-buffer
 ;;;     comint-output-filter-functions - hook    function modes.
 ;;;     comint-input-filter     - function         ...
-;;;     comint-input-send      - function         ...
+;;;     comint-input-sender    - function         ...
 ;;;     comint-eol-on-send     - boolean          ...
 ;;;     comint-process-echoes   - boolean          ...
 ;;;     comint-scroll-to-bottom-on-input - symbol For scroll behavior
@@ -226,7 +226,7 @@ appears in the buffer.
 This variable is buffer-local.")
 
 (defvar comint-password-prompt-regexp
-  "\\(^[Pp]assword\\|pass phrase\\):\\s *\\'"
+  "\\(\\([Oo]ld \\|[Nn]ew \\|^\\)[Pp]assword\\|pass phrase\\):\\s *\\'"
   "*Regexp matching prompts for passwords in the inferior process.
 This is used by `comint-watch-for-password-prompt'.")
 
@@ -291,7 +291,7 @@ executed once when the buffer is created.")
 
 (defvar comint-ptyp t
   "Non-nil if communications via pty; false if by pipe.  Buffer local.
-This is to work around a bug in Emacs process signalling.")
+This is to work around a bug in Emacs process signaling.")
 
 (defvar comint-input-ring nil)
 (defvar comint-last-input-start)
@@ -376,10 +376,10 @@ Entry to this mode runs the hooks on `comint-mode-hook'."
   (make-local-variable 'comint-input-autoexpand)
   (make-local-variable 'comint-input-ignoredups)
   (make-local-variable 'comint-delimiter-argument-list)
-  (make-local-variable 'comint-dynamic-complete-functions)
+  (make-local-hook 'comint-dynamic-complete-functions)
   (make-local-variable 'comint-completion-fignore)
   (make-local-variable 'comint-get-old-input)
-  (make-local-variable 'comint-input-filter-functions)
+  (make-local-hook 'comint-input-filter-functions)
   (make-local-variable 'comint-input-filter)
   (make-local-variable 'comint-input-sender)
   (make-local-variable 'comint-eol-on-send)
@@ -388,7 +388,7 @@ Entry to this mode runs the hooks on `comint-mode-hook'."
   (make-local-variable 'comint-scroll-show-maximum-output)
   (make-local-variable 'pre-command-hook)
   (add-hook 'pre-command-hook 'comint-preinput-scroll-to-bottom)
-  (make-local-variable 'comint-output-filter-functions)
+  (make-local-hook 'comint-output-filter-functions)
   (make-local-variable 'comint-ptyp)
   (make-local-variable 'comint-exec-hook)
   (make-local-variable 'comint-process-echoes)
@@ -513,6 +513,8 @@ running process in that buffer, it is not restarted.  Optional third arg
 STARTFILE is the name of a file to send the contents of to the process.
 
 If PROGRAM is a string, any more args are arguments to PROGRAM."
+  (or (fboundp 'start-process)
+      (error "Multi-processing is not supported for this system"))
   (let ((buffer (get-buffer-create (concat "*" name "*"))))
     ;; If no process, or nuked process, crank up a new one and put buffer in
     ;; comint mode.  Otherwise, leave buffer and existing process alone.
@@ -585,10 +587,11 @@ buffer.  The hook `comint-exec-hook' is run after each exec."
          ;; Some programs that use terminfo get very confused
          ;; if TERM is not a valid terminal type.
          (if (and (boundp 'system-uses-terminfo) system-uses-terminfo)
-             (list "EMACS=t" "TERM=unknown"
+             (list "TERM=unknown"
                    (format "COLUMNS=%d" (frame-width)))
-           (list "EMACS=t" "TERM=emacs"
+           (list "TERM=emacs"
                  (format "TERMCAP=emacs:co#%d:tc=unknown:" (frame-width))))
+         (if (getenv "EMACS") nil (list "EMACS=t"))
          process-environment))
        (default-directory
          (if (file-directory-p default-directory)
@@ -1174,10 +1177,8 @@ Similarly for Soar, Scheme, etc."
                       (not (string-equal (ring-ref comint-input-ring 0)
                                          history))))
              (ring-insert comint-input-ring history))
-         (let ((functions comint-input-filter-functions))
-           (while functions
-             (funcall (car functions) (concat input "\n"))
-             (setq functions (cdr functions))))
+         (run-hook-with-args 'comint-input-filter-functions
+                             (concat input "\n"))
          (setq comint-input-ring-index nil)
          ;; Update the markers before we send the input
          ;; in case we get output amidst sending the input.
@@ -1227,10 +1228,7 @@ Similarly for Soar, Scheme, etc."
 
          (narrow-to-region obeg oend)
          (goto-char opoint)
-         (let ((functions comint-output-filter-functions))
-           (while functions
-             (funcall (car functions) string)
-             (setq functions (cdr functions))))
+         (run-hook-with-args 'comint-output-filter-functions string)
          (set-buffer obuf)))))
 
 (defun comint-preinput-scroll-to-bottom ()
@@ -1436,17 +1434,16 @@ applications."
 
 (defun send-invisible (str)
   "Read a string without echoing.
-Then send it to the process running in the current buffer.  A new-line
-is additionally sent.  String is not saved on comint input history list.
+Then send it to the process running in the current buffer.
+The string is sent using `comint-input-sender'.
 Security bug: your string can still be temporarily recovered with
 \\[view-lossage]."
   (interactive "P") ; Defeat snooping via C-x esc
   (let ((proc (get-buffer-process (current-buffer))))
     (if (not proc)
        (error "Current buffer has no process")
-      (comint-send-string
-       proc (if (stringp str) str (comint-read-noecho "Non-echoed text: " t)))
-      (comint-send-string proc "\n"))))
+      (funcall comint-input-sender proc
+       (if (stringp str) str (comint-read-noecho "Non-echoed text: " t))))))
 
 (defun comint-watch-for-password-prompt (string) 
   "Prompt in the minibuffer for password and send without echoing.
@@ -1476,7 +1473,7 @@ Does not delete the prompt."
                          (beginning-of-line nil)
                          (point-marker))))
        (delete-region comint-last-input-end pmark)
-       (comint-skip-prompt)
+       (goto-char (process-mark proc))
        (setq replacement (concat "*** output flushed ***\n"
                                  (buffer-substring pmark (point))))
        (delete-region pmark (point))))
@@ -1799,7 +1796,7 @@ See `comint-prompt-regexp'."
 ;;; want them present in specific modes.
 
 (defvar comint-completion-autolist nil
-  "*If non-nil, automatically list possiblities on partial completion.
+  "*If non-nil, automatically list possibilities on partial completion.
 This mirrors the optional behavior of tcsh.")
 
 (defvar comint-completion-addsuffix t
@@ -1846,10 +1843,15 @@ inside of a \"[...]\" (see `skip-chars-forward')."
     (let ((non-word-chars (concat "[^\\\\" word-chars "]")) (here (point)))
       (while (and (re-search-backward non-word-chars nil 'move)
                  ;(memq (char-after (point)) shell-file-name-quote-list)
-                 (not (bolp)) (eq (char-after (1- (point))) ?\\))
+                 (eq (preceding-char) ?\\))
        (backward-char 1))
-      (forward-char 1)
-      (and (< (point) here) (buffer-substring (point) here)))))
+      ;; Don't go forward over a word-char (this can happen if we're at bob).
+      (if (or (not (bobp)) (looking-at non-word-chars))
+         (forward-char 1))
+      ;; Set match-data to match the entire string.
+      (if (< (point) here)
+         (progn (store-match-data (list (point) here))
+                (match-string 0))))))
 
 
 (defun comint-match-partial-filename ()
@@ -1888,9 +1890,7 @@ Calls the functions in `comint-dynamic-complete-functions' to perform
 completion until a function returns non-nil, at which point completion is
 assumed to have occurred."
   (interactive)
-  (let ((functions comint-dynamic-complete-functions))
-    (while (and functions (null (funcall (car functions))))
-      (setq functions (cdr functions)))))
+  (run-hook-with-args-until-success 'comint-dynamic-complete-functions))
 
 
 (defun comint-dynamic-complete-filename ()