unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Noam Postavsky <npostavs@gmail.com>
Cc: mi-ebugs@kismala.com, 32072@debbugs.gnu.org, rami.ylimaki@vincit.fi
Subject: bug#32072: 27.0.50; clear-face-cache in an X frame breaks tty colors
Date: Thu, 19 Jul 2018 16:20:06 +0300	[thread overview]
Message-ID: <83lga72whl.fsf@gnu.org> (raw)
In-Reply-To: <87r2k06m1q.fsf@gmail.com> (message from Noam Postavsky on Wed, 18 Jul 2018 21:39:45 -0400)

> From: Noam Postavsky <npostavs@gmail.com>
> Date: Wed, 18 Jul 2018 21:39:45 -0400
> Cc: 32072@debbugs.gnu.org,
> 	Rami Ylimäki <rami.ylimaki@vincit.fi>
> 
> > I have done some more testing and found that 24-bit terminal frames are
> > not affected, their colors remain intact after doing (clear-face-cache)
> > in the X11 frame.
> 
> Hmm, interesting, I've bisected the problem to [1: e463e5762b].
> 
> [1: e463e5762b]: 2017-02-18 13:04:55 +0200
>   Support 24-bit direct colors on text terminals
>   https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=e463e5762bbe628be3d15da066a90f079a8468b3

Thanks.  Just stabbing in the dark here, but does the patch below
help?

diff --git a/lisp/term/tty-colors.el b/lisp/term/tty-colors.el
index ab9149e..a776c83 100644
--- a/lisp/term/tty-colors.el
+++ b/lisp/term/tty-colors.el
@@ -824,10 +824,12 @@ tty-color-canonicalize
 	(replace-regexp-in-string " +" "" (downcase color))
       color)))
 
-(defun tty-color-24bit (rgb)
-  "Return pixel value on 24-bit terminals. Return nil if RGB is
-nil or not on 24-bit terminal."
-  (when (and rgb (= (display-color-cells) 16777216))
+(defun tty-color-24bit (rgb &optional display)
+  "Return 24-bit color pixel value for RGB value on DISPLAY.
+DISPLAY can be a display name or a frame, and defaults to the
+selected frame's display.
+If DISPLAY is not on a 24-but TTY terminal, return nil."
+  (when (and rgb (= (display-color-cells display) 16777216))
     (let ((r (lsh (car rgb) -8))
 	  (g (lsh (cadr rgb) -8))
 	  (b (lsh (nth 2 rgb) -8)))
@@ -850,7 +852,7 @@ tty-color-define
       (error "Invalid specification for tty color \"%s\"" name))
   (tty-modify-color-alist
    (append (list (tty-color-canonicalize name)
-		 (or (tty-color-24bit rgb) index))
+		 (or (tty-color-24bit rgb frame) index))
 	   rgb)
    frame))
 
@@ -1026,7 +1028,7 @@ tty-color-desc
 	  (or (assoc color (tty-color-alist frame))
 	      (let ((rgb (tty-color-standard-values color)))
 		(and rgb
-		     (let ((pixel (tty-color-24bit rgb)))
+		     (let ((pixel (tty-color-24bit rgb frame)))
 		       (or (and pixel (cons color (cons pixel rgb)))
 			   (tty-color-approximate rgb frame)))))))))
 





  reply	other threads:[~2018-07-19 13:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-06 17:18 bug#32072: 27.0.50; clear-face-cache in an X frame breaks tty colors Istvan Marko
2018-07-07  8:14 ` Eli Zaretskii
2018-07-09  7:17   ` Istvan Marko
     [not found]     ` <m34lgzeje5.fsf@zsu.kismala.com>
2018-07-19  1:39       ` Noam Postavsky
2018-07-19 13:20         ` Eli Zaretskii [this message]
2018-07-19 17:33           ` Rami Ylimäki
2018-07-19 17:48             ` Eli Zaretskii
2018-07-19 18:18               ` Istvan Marko
2018-07-19 18:23                 ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83lga72whl.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=32072@debbugs.gnu.org \
    --cc=mi-ebugs@kismala.com \
    --cc=npostavs@gmail.com \
    --cc=rami.ylimaki@vincit.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).