unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] comint: save & restore fonts so misidentified prompts don't lose their color
@ 2015-03-12  4:59 Lawrence D'Anna
  2015-03-12 14:02 ` Wolfgang Jenkner
  0 siblings, 1 reply; 3+ messages in thread
From: Lawrence D'Anna @ 2015-03-12  4:59 UTC (permalink / raw)
  To: emacs-devel; +Cc: Lawrence D'Anna

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)




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] comint: save & restore fonts so misidentified prompts don't lose their color
  2015-03-12  4:59 [PATCH] comint: save & restore fonts so misidentified prompts don't lose their color Lawrence D'Anna
@ 2015-03-12 14:02 ` Wolfgang Jenkner
  2015-03-12 16:26   ` Lawrence D'Anna
  0 siblings, 1 reply; 3+ messages in thread
From: Wolfgang Jenkner @ 2015-03-12 14:02 UTC (permalink / raw)
  To: Lawrence D'Anna; +Cc: emacs-devel

On Wed, Mar 11 2015, Lawrence D'Anna wrote:

> 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.

Please see http://debbugs.gnu.org/cgi/bugreport.cgi?bug=20084.

It seems, however, that your patch doesn't address the bug report's OP's
concern.

Wolfgang



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] comint: save & restore fonts so misidentified prompts don't lose their color
  2015-03-12 14:02 ` Wolfgang Jenkner
@ 2015-03-12 16:26   ` Lawrence D'Anna
  0 siblings, 0 replies; 3+ messages in thread
From: Lawrence D'Anna @ 2015-03-12 16:26 UTC (permalink / raw)
  To: Wolfgang Jenkner; +Cc: emacs-devel


> On Mar 12, 2015, at 7:02 AM, Wolfgang Jenkner <wjenkner@inode.at> wrote:
> 
> On Wed, Mar 11 2015, Lawrence D'Anna wrote:
> 
>> 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.
> 
> Please see http://debbugs.gnu.org/cgi/bugreport.cgi?bug=20084.
> 
> It seems, however, that your patch doesn't address the bug report's OP's
> concern.
> 
> Wolfgang

So what is the correct behavior if the prompt has colors in it?  Color over the parts that don’t have colors?  
Or should the whole prompt be left alone if any of it has colors?


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-03-12 16:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-12  4:59 [PATCH] comint: save & restore fonts so misidentified prompts don't lose their color Lawrence D'Anna
2015-03-12 14:02 ` Wolfgang Jenkner
2015-03-12 16:26   ` Lawrence D'Anna

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).