X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/0c3f76c6335de0a2d44db37c9ddf953654ca7f32..517ab6238a362bd0dda9af14681f5590da1df6de:/lisp/comint.el diff --git a/lisp/comint.el b/lisp/comint.el index da3782717c..de22061975 100644 --- a/lisp/comint.el +++ b/lisp/comint.el @@ -1,6 +1,6 @@ ;;; comint.el --- general command interpreter in a window stuff -*- lexical-binding: t -*- -;; Copyright (C) 1988, 1990, 1992-2014 Free Software Foundation, Inc. +;; Copyright (C) 1988, 1990, 1992-2015 Free Software Foundation, Inc. ;; Author: Olin Shivers ;; Simon Marshall @@ -472,6 +472,7 @@ executed once when the buffer is created." (define-key map "\C-c\C-\\" 'comint-quit-subjob) (define-key map "\C-c\C-m" 'comint-copy-old-input) (define-key map "\C-c\C-o" 'comint-delete-output) + (define-key map "\C-c\M-o" 'comint-clear-buffer) (define-key map "\C-c\C-r" 'comint-show-output) (define-key map "\C-c\C-e" 'comint-show-maximum-output) (define-key map "\C-c\C-l" 'comint-dynamic-list-input-ring) @@ -815,8 +816,6 @@ series of processes in the same Comint buffer. The hook (format "COLUMNS=%d" (window-width))) (list "TERM=emacs" (format "TERMCAP=emacs:co#%d:tc=unknown:" (window-width)))) - (unless (getenv "EMACS") - (list "EMACS=t")) (list (format "INSIDE_EMACS=%s,comint" emacs-version)) process-environment)) (default-directory @@ -1532,14 +1531,20 @@ the function `isearch-message'." ;; the initial comint prompt. (if (overlayp comint-history-isearch-message-overlay) (move-overlay comint-history-isearch-message-overlay - (save-excursion (forward-line 0) (point)) + (save-excursion + (goto-char (comint-line-beginning-position)) + (forward-line 0) + (point)) (comint-line-beginning-position)) (setq comint-history-isearch-message-overlay - (make-overlay (save-excursion (forward-line 0) (point)) + (make-overlay (save-excursion + (goto-char (comint-line-beginning-position)) + (forward-line 0) + (point)) (comint-line-beginning-position))) (overlay-put comint-history-isearch-message-overlay 'evaporate t)) (overlay-put comint-history-isearch-message-overlay - 'display (isearch-message-prefix c-q-hack ellipsis)) + 'display (isearch-message-prefix ellipsis isearch-nonincremental)) (if (and comint-input-ring-index (not ellipsis)) ;; Display the current history index. (message "History item: %d" (1+ comint-input-ring-index)) @@ -1781,7 +1786,10 @@ Similarly for Soar, Scheme, etc." (widen) (let* ((pmark (process-mark proc)) (intxt (if (>= (point) (marker-position pmark)) - (progn (if comint-eol-on-send (end-of-line)) + (progn (if comint-eol-on-send + (if comint-use-prompt-regexp + (end-of-line) + (goto-char (field-end)))) (buffer-substring pmark (point))) (let ((copy (funcall comint-get-old-input))) (goto-char pmark) @@ -1920,10 +1928,10 @@ the start, the cdr to the end of the last prompt recognized.") Freezes the `font-lock-face' text property in place." (when comint-last-prompt (with-silent-modifications - (add-text-properties + (font-lock-prepend-text-property (car comint-last-prompt) (cdr comint-last-prompt) - '(font-lock-face comint-highlight-prompt))) + 'font-lock-face 'comint-highlight-prompt)) ;; Reset comint-last-prompt so later on comint-output-filter does ;; not remove the font-lock-face text property of the previous ;; (this) prompt. @@ -2074,14 +2082,19 @@ Make backspaces delete the previous character." (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))) + ;; There might be some keywords here waiting for + ;; fontification, so no `with-silent-modifications'. + (font-lock--remove-face-from-text-property + (car comint-last-prompt) + (cdr comint-last-prompt) + 'font-lock-face + 'comint-highlight-prompt)) (setq comint-last-prompt (cons (copy-marker prompt-start) (point-marker))) - (add-text-properties prompt-start (point) - '(rear-nonsticky t - font-lock-face comint-highlight-prompt))) + (font-lock-prepend-text-property prompt-start (point) + 'font-lock-face + 'comint-highlight-prompt) + (add-text-properties prompt-start (point) '(rear-nonsticky t))) (goto-char saved-point))))))) (defun comint-preinput-scroll-to-bottom () @@ -2212,7 +2225,10 @@ the current line with any initial string matching the regexp (null (get-char-property (setq bof (field-beginning)) 'field))) (field-string-no-properties bof) (comint-bol) - (buffer-substring-no-properties (point) (line-end-position))))) + (buffer-substring-no-properties (point) + (if comint-use-prompt-regexp + (line-end-position) + (field-end)))))) (defun comint-copy-old-input () "Insert after prompt old input at point as new input to be edited. @@ -2270,7 +2286,10 @@ a buffer local variable." ;; if there are two fields on a line, then the first one is the ;; prompt, and the second one is an input field, and is front-sticky ;; (as input fields should be). - (constrain-to-field (line-beginning-position) (line-end-position)))) + (constrain-to-field (if (eq (field-at-pos (point)) 'output) + (line-beginning-position) + (field-beginning)) + (line-end-position)))) (defun comint-bol (&optional arg) "Go to the beginning of line, then skip past the prompt, if any. @@ -2422,6 +2441,11 @@ Sets mark to the value of point when this command is run." (goto-char (field-beginning pos)) (set-window-start (selected-window) (point)))))) +(defun comint-clear-buffer () + "Clear the comint buffer." + (interactive) + (let ((comint-buffer-maximum-size 0)) + (comint-truncate-buffer))) (defun comint-interrupt-subjob () "Interrupt the current subjob.