;;; comint.el --- general command interpreter in a window stuff -*- lexical-binding: t -*-
-;; Copyright (C) 1988, 1990, 1992-2013 Free Software Foundation, Inc.
+;; Copyright (C) 1988, 1990, 1992-2014 Free Software Foundation, Inc.
;; Author: Olin Shivers <shivers@cs.cmu.edu>
;; Simon Marshall <simon@gnu.org>
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
;; Keywords: processes
;; Package: emacs
\(add-hook 'comint-mode-hook
(lambda ()
- (define-key comint-mode-map \"\\C-w\" 'comint-kill-region)
- (define-key comint-mode-map [C-S-backspace]
+ (define-key comint-mode-map [remap kill-region] 'comint-kill-region)
+ (define-key comint-mode-map [remap kill-whole-line]
'comint-kill-whole-line)))
If you sometimes use comint-mode on text-only terminals or with `emacs -nw',
"Old" "old" "New" "new" "'s" "login"
"Kerberos" "CVS" "UNIX" " SMB" "LDAP" "[sudo]" "Repeat" "Bad") t)
" +\\)"
- (regexp-opt
- '("password" "Password" "passphrase" "Passphrase"
- "pass phrase" "Pass phrase" "Response"))
+ "\\(?:" (regexp-opt password-word-equivalents) "\\|Response\\)"
"\\(?:\\(?:, try\\)? *again\\| (empty for no passphrase)\\| (again)\\)?\
-\\(?: for .+\\)?:\\s *\\'")
+\\(?: for [^::៖]+\\)?[::៖]\\s *\\'")
"Regexp matching prompts for passwords in the inferior process.
This is used by `comint-watch-for-password-prompt'."
- :version "24.1"
+ :version "24.4"
:type 'regexp
:group 'comint)
(define-key map "\e\C-l" 'comint-show-output)
(define-key map "\C-m" 'comint-send-input)
(define-key map "\C-d" 'comint-delchar-or-maybe-eof)
- ;; The following two are standardly aliased to C-d,
+ ;; The following two are standardly bound to delete-forward-char,
;; but they should never do EOF, just delete.
- (define-key map [delete] 'delete-char)
- (define-key map [kp-delete] 'delete-char)
+ (define-key map [delete] 'delete-forward-char)
+ (define-key map [kp-delete] 'delete-forward-char)
(define-key map "\C-c " 'comint-accumulate)
(define-key map "\C-c\C-x" 'comint-get-next-from-history)
(define-key map "\C-c\C-a" 'comint-bol-or-process-mark)
The file name is used to make a symbol name, such as `comint-sh-hook', and any
hooks on this symbol are run in the buffer.
See `make-comint' and `comint-exec'."
+ (declare (interactive-only make-comint))
(interactive "sRun program: ")
(let ((name (file-name-nondirectory program)))
(switch-to-buffer (make-comint name program))
With prefix argument N, search for Nth previous match.
If N is negative, search forwards for the -Nth following match."
(interactive "p")
- (if (not (memq last-command '(comint-previous-matching-input-from-input
- comint-next-matching-input-from-input)))
+ (let ((opoint (point)))
+ (unless (memq last-command '(comint-previous-matching-input-from-input
+ comint-next-matching-input-from-input))
;; Starting a new search
(setq comint-matching-input-from-input-string
(buffer-substring
(process-mark (get-buffer-process (current-buffer))))
(point))
comint-input-ring-index nil))
- (comint-previous-matching-input
- (concat "^" (regexp-quote comint-matching-input-from-input-string))
- n))
+ (comint-previous-matching-input
+ (concat "^" (regexp-quote comint-matching-input-from-input-string))
+ n)
+ (goto-char opoint)))
(defun comint-next-matching-input-from-input (n)
"Search forwards through input history for match for current input.
"Search for a string backward in input history using Isearch."
(interactive)
(let ((comint-history-isearch t))
- (isearch-backward)))
+ (isearch-backward nil t)))
(defun comint-history-isearch-backward-regexp ()
"Search for a regular expression backward in input history using Isearch."
(interactive)
(let ((comint-history-isearch t))
- (isearch-backward-regexp)))
+ (isearch-backward-regexp nil t)))
(defvar-local comint-history-isearch-message-overlay nil)
Similarly for Soar, Scheme, etc."
(interactive)
+ ;; If we're currently completing, stop. We're definitely done
+ ;; completing, and by sending the input, we might cause side effects
+ ;; that will confuse the code running in the completion
+ ;; post-command-hook.
+ (when completion-in-region-mode
+ (completion-in-region-mode -1))
;; Note that the input string does not include its terminal newline.
(let ((proc (get-buffer-process (current-buffer))))
(if (not proc) (user-error "Current buffer has no process")
(let ((prompt-start (save-excursion (forward-line 0) (point)))
(inhibit-read-only t))
(when comint-prompt-read-only
- (with-silent-modifications
- (or (= (point-min) prompt-start)
- (get-text-property (1- prompt-start) 'read-only)
- (put-text-property
- (1- prompt-start) prompt-start 'read-only 'fence))
- (add-text-properties
- prompt-start (point)
- '(read-only t rear-nonsticky t front-sticky (read-only)))))
+ (with-silent-modifications
+ (or (= (point-min) prompt-start)
+ (get-text-property (1- prompt-start) 'read-only)
+ (put-text-property (1- prompt-start)
+ prompt-start 'read-only 'fence))
+ (add-text-properties prompt-start (point)
+ '(read-only t front-sticky (read-only)))))
(when comint-last-prompt
(remove-text-properties (car comint-last-prompt)
(cdr comint-last-prompt)
'(font-lock-face)))
(setq comint-last-prompt
(cons (copy-marker prompt-start) (point-marker)))
- (add-text-properties (car comint-last-prompt)
- (cdr comint-last-prompt)
- '(font-lock-face comint-highlight-prompt)))
+ (add-text-properties prompt-start (point)
+ '(rear-nonsticky t
+ font-lock-face comint-highlight-prompt)))
(goto-char saved-point)))))))
(defun comint-preinput-scroll-to-bottom ()
`comint-password-prompt-regexp'.
This function could be in the list `comint-output-filter-functions'."
- (when (string-match comint-password-prompt-regexp string)
+ (when (let ((case-fold-search t))
+ (string-match comint-password-prompt-regexp string))
(when (string-match "^[ \n\r\t\v\f\b\a]+" string)
(setq string (replace-match "" t t string)))
(send-invisible string)))
(kill-whole-line count)
(when (>= count 0) (comint-update-fence))))
-(defun comint-kill-region (beg end &optional yank-handler)
+(defun comint-kill-region (beg end)
"Like `kill-region', but ignores read-only properties, if safe.
This command assumes that the buffer contains read-only
\"prompts\" which are regions with front-sticky read-only
the case, this command just calls `kill-region' with all
read-only properties intact. The read-only status of newlines is
updated using `comint-update-fence', if necessary."
- (declare (advertised-calling-convention (beg end) "23.3"))
(interactive "r")
(save-excursion
(let* ((true-beg (min beg end))
(if (listp end-lst) (memq 'read-only end-lst) t))))
(if (or (and (not beg-bolp) (or beg-bad end-bad))
(and (not end-bolp) end-bad))
- (kill-region beg end yank-handler)
+ (kill-region beg end)
(let ((inhibit-read-only t))
- (kill-region beg end yank-handler)
+ (kill-region beg end)
(comint-update-fence))))))
\f
;; Support for source-file processing commands.
(defun comint-dynamic-list-completions (completions &optional common-substring)
"Display a list of sorted COMPLETIONS.
-The meaning of COMMON-SUBSTRING is the same as in `display-completion-list'.
-Typing SPC flushes the completions buffer."
+Typing SPC flushes the completions buffer.
+
+The optional argument COMMON-SUBSTRING, if non-nil, should be a string
+specifying a common substring for adding the faces
+`completions-first-difference' and `completions-common-part' to
+the completions."
(let ((window (get-buffer-window "*Completions*" 0)))
(setq completions (sort completions 'string-lessp))
(if (and (eq last-command this-command)
(setq comint-dynamic-list-completions-config
(current-window-configuration))
(with-output-to-temp-buffer "*Completions*"
- (display-completion-list completions common-substring))
+ (display-completion-list
+ (completion-hilit-commonality completions (length common-substring))))
(if (window-minibuffer-p)
(minibuffer-message "Type space to flush; repeat completion command to scroll")
(message "Type space to flush; repeat completion command to scroll")))
(and (consp first) (consp (event-start first))
(eq (window-buffer (posn-window (event-start first)))
(get-buffer "*Completions*"))
- (eq (key-binding key) 'mouse-choose-completion)))
- ;; If the user does mouse-choose-completion with the mouse,
+ (memq (key-binding key)
+ '(mouse-choose-completion choose-completion))))
+ ;; If the user does choose-completion with the mouse,
;; execute the command, then delete the completion window.
(progn
(choose-completion first)
;; If we see the prompt, tidy up
;; We'll look for the prompt in the original string, so nobody can
;; clobber it
- (and (string-match comint-redirect-finished-regexp
- (concat comint-redirect-previous-input-string
+ (and (string-match comint-redirect-finished-regexp
+ (concat comint-redirect-previous-input-string
input-string))
(progn
(and comint-redirect-verbose