From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#22915: foreground-color-at-point doesn't return the foreground color at point (when overlays are present) Date: Sat, 05 Mar 2016 10:15:58 +0200 Message-ID: <83lh5xxrup.fsf@gnu.org> References: <56DA785D.8080202@live.com> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1457165844 23839 80.91.229.3 (5 Mar 2016 08:17:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 5 Mar 2016 08:17:24 +0000 (UTC) Cc: 22915@debbugs.gnu.org To: =?UTF-8?Q?Cl=C3=A9ment?= Pit--Claudel Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Mar 05 09:17:12 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ac7Oi-0006Md-3a for geb-bug-gnu-emacs@m.gmane.org; Sat, 05 Mar 2016 09:17:12 +0100 Original-Received: from localhost ([::1]:45207 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ac7Og-0007sS-SU for geb-bug-gnu-emacs@m.gmane.org; Sat, 05 Mar 2016 03:17:10 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43487) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ac7Od-0007s1-0L for bug-gnu-emacs@gnu.org; Sat, 05 Mar 2016 03:17:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ac7OX-0003so-Vn for bug-gnu-emacs@gnu.org; Sat, 05 Mar 2016 03:17:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:37126) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ac7OX-0003si-T9 for bug-gnu-emacs@gnu.org; Sat, 05 Mar 2016 03:17:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84) (envelope-from ) id 1ac7OX-0001LH-ND for bug-gnu-emacs@gnu.org; Sat, 05 Mar 2016 03:17:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 05 Mar 2016 08:17:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22915 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 22915-submit@debbugs.gnu.org id=B22915.14571657705093 (code B ref 22915); Sat, 05 Mar 2016 08:17:01 +0000 Original-Received: (at 22915) by debbugs.gnu.org; 5 Mar 2016 08:16:10 +0000 Original-Received: from localhost ([127.0.0.1]:34253 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1ac7Ni-0001K5-0O for submit@debbugs.gnu.org; Sat, 05 Mar 2016 03:16:10 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:52151) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1ac7Nf-0001Jk-VT for 22915@debbugs.gnu.org; Sat, 05 Mar 2016 03:16:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ac7NX-0003Gt-GJ for 22915@debbugs.gnu.org; Sat, 05 Mar 2016 03:16:02 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:52073) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ac7NX-0003Go-CL; Sat, 05 Mar 2016 03:15:59 -0500 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:4633 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1ac7NW-0004QI-K4; Sat, 05 Mar 2016 03:15:59 -0500 In-reply-to: <56DA785D.8080202@live.com> (message from =?UTF-8?Q?Cl=C3=A9ment?= Pit--Claudel on Sat, 5 Mar 2016 01:10:37 -0500) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:114439 Archived-At: > From: Clément Pit--Claudel > Date: Sat, 5 Mar 2016 01:10:37 -0500 > > (with-current-buffer (get-buffer-create "*broken*") > (require 'cl-lib) > (erase-buffer) > (delete-all-overlays) > (fundamental-mode) > (insert "AAAAA") > (goto-char (point-min)) > > ;; Add two faces > (set-text-properties (point-min) (point-max) '(face font-lock-type-face)) > (let ((ov (make-overlay (point-min) (point-max)))) > (overlay-put ov 'face 'font-lock-negation-char-face)) > > ;; This passes, proving that font-lock-negation-char-face is not contributing to the > ;; foreground color > (cl-assert (eq (face-attribute 'font-lock-negation-char-face :foreground) > 'unspecified)) > > ;; This fails: foreground-color-at-point reads the face of the overlay, sees that it's undefined, > ;; and ignores the 'face text property > (cl-assert (eq (foreground-color-at-point) > (face-attribute 'font-lock-type-face :foreground))) > > (pop-to-buffer (current-buffer))) You are creating a situation where the actual color of the character is the result of face merging as part of redisplay. I don't think there's currently any way of accessing the results of face merging from Lisp. By contrast, foreground-color-at-point simply returns the color specified by the highest-priority overlay/text property at point; in this case that color is unspecified, so it defaults to the default face's foreground color. If I'm right, you expect too much from foreground-color-at-point, or from any Lisp implementation of this functionality in general. AFAICT, if we want this kind of functionality supported from Lisp, we will need first to implement a primitive that would accept a list of faces and return the fully realized face spec produced by merging those faces. Then a Lisp implementation of foreground-color-at-point could be changed to collect all the relevant text/overlay properties at point and pass them to that primitive. Alternatively, an entirely-C implementation, exposed to Lisp as a primitive, could simulate display of the character at point and return the resulting color. If there are other ideas, I'm all ears. If not, I think this is a fine subject for a small project, patches are welcome.