;;; 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
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'.")
(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)
(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)
(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)
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.
;; 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)
(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.
(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 ()
(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.
(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))))
;;; 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
(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 ()
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 ()