From 74c5d24c74e3167db6e3ee01831584c99905bb70 Mon Sep 17 00:00:00 2001 From: Christopher Schmidt Date: Thu, 8 Aug 2013 21:22:58 +0200 Subject: [PATCH] * lisp/comint.el: Do not use an overlay to highlight the last prompt. (Bug#14744) (comint-mode): Make comint-last-prompt buffer local. (comint-last-prompt): New variable. (comint-last-prompt-overlay): Remove. Superseded by comint-last-prompt. (comint-snapshot-last-prompt, comint-output-filter): Use comint-last-prompt. --- lisp/ChangeLog | 11 ++++++++++ lisp/comint.el | 54 ++++++++++++++++++++++++-------------------------- 2 files changed, 37 insertions(+), 28 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index d98c9cac530..294c6af6595 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,14 @@ +2013-08-08 Christopher Schmidt + + * comint.el: + Do not use an overlay to highlight the last prompt. (Bug#14744) + (comint-mode): Make comint-last-prompt buffer local. + (comint-last-prompt): New variable. + (comint-last-prompt-overlay): Remove. Superseded by + comint-last-prompt. + (comint-snapshot-last-prompt, comint-output-filter): Use + comint-last-prompt. + 2013-08-08 Juanma Barranquero * frameset.el (frameset-valid-p): Check vector length. Doc fix. diff --git a/lisp/comint.el b/lisp/comint.el index c2b69a42a8b..4517e9c65a0 100644 --- a/lisp/comint.el +++ b/lisp/comint.el @@ -636,7 +636,7 @@ Entry to this mode runs the hooks on `comint-mode-hook'." (setq-local comint-last-input-start (point-min-marker)) (setq-local comint-last-input-end (point-min-marker)) (setq-local comint-last-output-start (make-marker)) - (make-local-variable 'comint-last-prompt-overlay) + (make-local-variable 'comint-last-prompt) (make-local-variable 'comint-prompt-regexp) ; Don't set; default (make-local-variable 'comint-input-ring-size) ; ...to global val. (make-local-variable 'comint-input-ring) @@ -1902,21 +1902,24 @@ either globally or locally.") "If nil, Comint will interpret `carriage control' characters in output. See `comint-carriage-motion' for details.") -;; When non-nil, this is an overlay over the last recognized prompt in -;; the buffer; it is used when highlighting the prompt. -(defvar comint-last-prompt-overlay nil) +(defvar comint-last-prompt nil + "Markers pointing to the last prompt. +If non-nil, a cons cell containing markers. The car points to +the start, the cdr to the end of the last prompt recognized.") (defun comint-snapshot-last-prompt () - "`snapshot' any current `comint-last-prompt-overlay'. -Freeze its attributes in place, even when more input comes along -and moves the prompt overlay." - (when comint-last-prompt-overlay - (let ((inhibit-read-only t)) - (with-silent-modifications - (add-text-properties - (overlay-start comint-last-prompt-overlay) - (overlay-end comint-last-prompt-overlay) - (overlay-properties comint-last-prompt-overlay)))))) + "Snapshot the current `comint-last-prompt'. +Freezes the `font-lock-face' text property in place." + (when comint-last-prompt + (with-silent-modifications + (add-text-properties + (car comint-last-prompt) + (cdr comint-last-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. + (setq comint-last-prompt nil))) (defun comint-carriage-motion (start end) "Interpret carriage control characters in the region from START to END. @@ -2063,20 +2066,15 @@ Make backspaces delete the previous character." (add-text-properties prompt-start (point) '(read-only t rear-nonsticky t front-sticky (read-only))))) - (unless (and (bolp) (null comint-last-prompt-overlay)) - ;; Need to create or move the prompt overlay (in the case - ;; where there is no prompt ((bolp) == t), we still do - ;; this if there's already an existing overlay). - (if comint-last-prompt-overlay - ;; Just move an existing overlay - (move-overlay comint-last-prompt-overlay - prompt-start (point)) - ;; Need to create the overlay - (setq comint-last-prompt-overlay - (make-overlay prompt-start (point))) - (overlay-put comint-last-prompt-overlay - 'font-lock-face 'comint-highlight-prompt)))) - + (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))) (goto-char saved-point))))))) (defun comint-preinput-scroll-to-bottom () -- 2.39.2