emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] comint: save & restore fonts so misidentified prompts don't lose


From: Lawrence D'Anna
Subject: [PATCH] comint: save & restore fonts so misidentified prompts don't lose their color
Date: Wed, 11 Mar 2015 21:59:05 -0700

I'm hitting a very annoying bug where sometimes colors will be missing
from random segments of output, always starting at the beginning of a
line.

The reason is that comint is seeing a partial line, interpreting it as
a prompt, coloring it as a prompt, and then uncoloring it when it
receives more input.

This should fix it by saving and restoring the colors in an alternate
text property instead.
---
 lisp/comint.el | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/lisp/comint.el b/lisp/comint.el
index 68b8edb..9a0ca2a 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -1989,6 +1989,12 @@ Make backspaces delete the previous character."
        (set-marker delete-end nil))
       (widen))))
 
+(defun comint-copy-text-property (begin end src dest)
+  (while (< begin end)
+    (put-text-property begin (1+ begin) dest
+                       (get-text-property begin src))
+    (setq begin (1+ begin))))
+
 ;; The purpose of using this filter for comint processes
 ;; is to keep comint-last-input-end from moving forward
 ;; when output is inserted.
@@ -2077,11 +2083,14 @@ 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)))
+                (comint-copy-text-property
+                 (car comint-last-prompt) (cdr comint-last-prompt)
+                 'comint-saved-face 'font-lock-face))
+
              (setq comint-last-prompt
                    (cons (copy-marker prompt-start) (point-marker)))
+              (comint-copy-text-property
+               prompt-start (point) 'font-lock-face 'comint-saved-face)
              (add-text-properties prompt-start (point)
                                   '(rear-nonsticky t
                                     font-lock-face comint-highlight-prompt)))
-- 
2.2.1 (Apple Git-53)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]