From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.bugs Subject: bug#15900: 24.3.50; foreground-color-at-point returns wrong results Date: Fri, 15 Nov 2013 23:18:11 +0100 Message-ID: <878uwpgvh8.fsf@web.de> References: <87siuyxvw7.fsf@web.de> <83li0qhxyl.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1384553953 3320 80.91.229.3 (15 Nov 2013 22:19:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 15 Nov 2013 22:19:13 +0000 (UTC) Cc: 15900@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Nov 15 23:19:17 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 1VhRjR-0005AZ-0X for geb-bug-gnu-emacs@m.gmane.org; Fri, 15 Nov 2013 23:19:17 +0100 Original-Received: from localhost ([::1]:34058 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VhRjQ-00007a-GL for geb-bug-gnu-emacs@m.gmane.org; Fri, 15 Nov 2013 17:19:16 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40413) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VhRjI-00007Q-FV for bug-gnu-emacs@gnu.org; Fri, 15 Nov 2013 17:19:14 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VhRjC-00088V-LC for bug-gnu-emacs@gnu.org; Fri, 15 Nov 2013 17:19:08 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:42285) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VhRjC-00088R-IZ for bug-gnu-emacs@gnu.org; Fri, 15 Nov 2013 17:19:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1VhRjC-0000Ap-AY for bug-gnu-emacs@gnu.org; Fri, 15 Nov 2013 17:19:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Michael Heerdegen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 15 Nov 2013 22:19:02 +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.1384553904614 (code B ref 15900); Fri, 15 Nov 2013 22:19:02 +0000 Original-Received: (at 15900) by debbugs.gnu.org; 15 Nov 2013 22:18:24 +0000 Original-Received: from localhost ([127.0.0.1]:56304 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VhRia-00009m-6m for submit@debbugs.gnu.org; Fri, 15 Nov 2013 17:18:24 -0500 Original-Received: from mout.web.de ([212.227.17.12]:60181) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VhRiX-00009X-QN for 15900@debbugs.gnu.org; Fri, 15 Nov 2013 17:18:22 -0500 Original-Received: from drachen.dragon ([90.186.185.213]) by smtp.web.de (mrweb003) with ESMTPA (Nemesis) id 0M4ZVE-1VVFQQ1UlA-00ygBa for <15900@debbugs.gnu.org>; Fri, 15 Nov 2013 23:18:15 +0100 In-Reply-To: <83li0qhxyl.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 15 Nov 2013 10:26:58 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-Provags-ID: V03:K0:n9Ksv1+bpEeWDIBVmqGb6UuLyq90vZYoTdl2aRyJVK3VJT44RJ1 wAE0RJsxVsVKRkOl+3Oeu0GyisEqZk4ijByvwHLXwdy0UsiewXM8CX2NVX+RuvEF/zVmCYb uw+uDUVMdUQuhwUiqSc/xejQx9+BqI3La7RIGRTvy3tHjQBtqQ/VFtyyMgvd3SIt0WzbwLX I1MlDCCeK0LqvNOHjFELQ== 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:80618 Archived-At: Hello, CCing Drew cause the Change Log mentions him with regard to `foreground-color-at-point'. Eli Zaretskii writes: > 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. That sounds good. Can we just do that? > > 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? What do you mean with "properties" - text and overlay properties? If faces are among them, I still must figure out if one of these faces changes the foreground. If not, i.e., if a face e.g. just underlines, I do want to color the text nevertheless. Probably I didn't understand what you meant. This expression works ok for me: --8<---------------cut here---------------start------------->8--- (cl-some (lambda (face) (not (memq (face-foreground face nil t) `(nil ,(face-attribute 'default :foreground) "unspecified-fg" "unspecified-bg")))) (cl-mapcan (lambda (face-or-list) (if (facep face-or-list) (list face-or-list) face-or-list)) (list (get-text-property (point) 'face) (get-text-property (point) 'font-lock-face)))) --8<---------------cut here---------------end--------------->8--- Overlays are not covered by this - which is not even necessary, because overlays have priorities that can be controlled. Thanks, Michael.