bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#20084: comint-highlight-prompt overrides ANSI colors in 24.4


From: Wolfgang Jenkner
Subject: bug#20084: comint-highlight-prompt overrides ANSI colors in 24.4
Date: Thu, 12 Mar 2015 03:00:13 +0100
User-agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/25.0.50 (berkeley-unix)

On Wed, Mar 11 2015, Glenn Morris wrote:

> Perhaps related to http://debbugs.gnu.org/14744, which I see was applied
> 2013-08-08, without any comment being made to the associated bug report, sigh.

Another symptom of the same bug introduced there is that copious
colourful output, as produced by, say, `ls /usr/bin', will have "white
spots".

I've been using something like the following patch for some time:

-- >8 --
Subject: [PATCH] Preserve face text properties in comint prompt.

* lisp/comint.el (comint-snapshot-last-prompt): Use
font-lock-prepend-text-property for comint-highlight-prompt.
(comint-output-filter): Remove only comint-highlight-prompt.

Thus, the original face text property of a prompt "candidate" (the
last line of an output chunk not ending with a newline) is
preserved.  This amends the fixing of bug#14744.  (Bug#20084)
---
 lisp/comint.el | 38 ++++++++++++++++++++++++++++++--------
 1 file changed, 30 insertions(+), 8 deletions(-)

diff --git a/lisp/comint.el b/lisp/comint.el
index b52d7fd..65b9c3c 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -1926,10 +1926,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.
@@ -2081,14 +2081,36 @@ 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)))
+               (let ((start (car comint-last-prompt))
+                     (limit (cdr comint-last-prompt))
+                     face end)
+                 (with-silent-modifications
+                   (while
+                       (progn
+                         (setq end
+                               (next-single-property-change start
+                                                            'font-lock-face
+                                                            nil
+                                                            limit))
+                         (setq face (get-text-property start 'font-lock-face))
+                         (put-text-property
+                          start end 'font-lock-face
+                          (if (and (consp face)
+                                   (not (or
+                                         (eq (car face) 'foreground-color)
+                                         (eq (car face) 'background-color)
+                                         (keywordp (car face)))))
+                              (remove 'comint-highlight-prompt face)
+                            (unless (eq face 'comint-highlight-prompt)
+                              face)))
+                         (< (setq start end) limit))))))
              (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)))
+             (with-silent-modifications
+               (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 ()
-- 
2.3.0






reply via email to

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