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#15900: 24.3.50; foreground-color-at-point returns wrong results Date: Fri, 15 Nov 2013 10:26:58 +0200 Message-ID: <83li0qhxyl.fsf@gnu.org> References: <87siuyxvw7.fsf@web.de> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1384504100 27944 80.91.229.3 (15 Nov 2013 08:28:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 15 Nov 2013 08:28:20 +0000 (UTC) Cc: 15900@debbugs.gnu.org To: Michael Heerdegen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Nov 15 09:28:24 2013 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 1VhElM-0007ct-FM for geb-bug-gnu-emacs@m.gmane.org; Fri, 15 Nov 2013 09:28:24 +0100 Original-Received: from localhost ([::1]:59351 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VhElM-0000nq-2V for geb-bug-gnu-emacs@m.gmane.org; Fri, 15 Nov 2013 03:28:24 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40469) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VhEl8-0000bl-L6 for bug-gnu-emacs@gnu.org; Fri, 15 Nov 2013 03:28:17 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VhEl1-0005BO-Bs for bug-gnu-emacs@gnu.org; Fri, 15 Nov 2013 03:28:10 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:39917) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VhEl1-0005BJ-8f for bug-gnu-emacs@gnu.org; Fri, 15 Nov 2013 03:28:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1VhEkz-0001Ld-Tj for bug-gnu-emacs@gnu.org; Fri, 15 Nov 2013 03:28:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 15 Nov 2013 08:28:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15900 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 15900-submit@debbugs.gnu.org id=B15900.13845040445124 (code B ref 15900); Fri, 15 Nov 2013 08:28:01 +0000 Original-Received: (at 15900) by debbugs.gnu.org; 15 Nov 2013 08:27:24 +0000 Original-Received: from localhost ([127.0.0.1]:53935 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VhEkN-0001KZ-3V for submit@debbugs.gnu.org; Fri, 15 Nov 2013 03:27:23 -0500 Original-Received: from mtaout22.012.net.il ([80.179.55.172]:56619) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VhEkJ-0001KH-SF for 15900@debbugs.gnu.org; Fri, 15 Nov 2013 03:27:21 -0500 Original-Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0MWA00500PV5JU00@a-mtaout22.012.net.il> for 15900@debbugs.gnu.org; Fri, 15 Nov 2013 10:27:13 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0MWA005BPQ5DJI20@a-mtaout22.012.net.il>; Fri, 15 Nov 2013 10:27:13 +0200 (IST) In-reply-to: <87siuyxvw7.fsf@web.de> X-012-Sender: halo1@inter.net.il X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.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:80578 Archived-At: > From: Michael Heerdegen > Date: Fri, 15 Nov 2013 03:04:56 +0100 > > `foreground-color-at-point' doesn't return the expected result when > there are several faces at point present. > > For example, on the red subject in a Gnus article buffer, or on a blue > link in w3m, it returns "black". Looking at the code, I see that > `foreground-color-at-point' uses > > (face-at-point) > > i.e., it looks only at one face and disregards the others. This is > especially meaningless when this first face doesn't specify any > foreground at all. As you later discovered, even (face-at-point nil t) doesn't do the job. Which doesn't surprise me a bit: this kind of things cannot be done reliably from Lisp, even at a price of the kind of obfuscated code that face-at-point and foreground-color-at-point use. It is much simpler to write a C primitive that simulates the display, then returns the resulting face at a given character position, a simple and straightforward task on the C level, something the display engine does all the time. > P.S. Some background: I'm working on an addition to stripe-buffer.el > that changes the foreground color continuously, instead of changing the > background. This is for better readability. > > I want to keep the foreground colors already present, so that e.g. links > in w3m are still recognizable. Paragraphs in italic can be colored > OTOH. > > So, what I need is a reliable `foreground-color-at-point'. Tips and > alternatives welcome. Why can't you detect that a portion of text is covered by specific properties (e.g., one of a list of known properties), and leave those portions alone?