From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Keith David Bershatsky Newsgroups: gmane.emacs.bugs Subject: bug#22757: 25.1.50; `face-at-point` and `faces--attribute-at-point` -- add argument WINDOW-OR-BUFFER Date: Mon, 22 Feb 2016 11:46:39 -0800 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 (generated by - "") Content-Type: text/plain; charset=US-ASCII X-Trace: ger.gmane.org 1456170444 18113 80.91.229.3 (22 Feb 2016 19:47:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 22 Feb 2016 19:47:24 +0000 (UTC) Cc: 22757@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Feb 22 20:47:11 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 1aXwRq-00020X-Kz for geb-bug-gnu-emacs@m.gmane.org; Mon, 22 Feb 2016 20:47:10 +0100 Original-Received: from localhost ([::1]:51542 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXwRq-0007ZA-8R for geb-bug-gnu-emacs@m.gmane.org; Mon, 22 Feb 2016 14:47:10 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58309) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXwRm-0007Z0-5c for bug-gnu-emacs@gnu.org; Mon, 22 Feb 2016 14:47:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aXwRi-0007cG-3m for bug-gnu-emacs@gnu.org; Mon, 22 Feb 2016 14:47:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:41358) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXwRh-0007cC-W3 for bug-gnu-emacs@gnu.org; Mon, 22 Feb 2016 14:47:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84) (envelope-from ) id 1aXwRh-0003AH-RD for bug-gnu-emacs@gnu.org; Mon, 22 Feb 2016 14:47:01 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: Resent-From: Keith David Bershatsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 22 Feb 2016 19:47:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22757 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 22757-submit@debbugs.gnu.org id=B22757.145617040912143 (code B ref 22757); Mon, 22 Feb 2016 19:47:01 +0000 Original-Received: (at 22757) by debbugs.gnu.org; 22 Feb 2016 19:46:49 +0000 Original-Received: from localhost ([127.0.0.1]:38485 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aXwRV-00039n-9K for submit@debbugs.gnu.org; Mon, 22 Feb 2016 14:46:49 -0500 Original-Received: from cobb.liquidweb.com ([50.28.13.150]:42657) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aXwRT-00039a-6k for 22757@debbugs.gnu.org; Mon, 22 Feb 2016 14:46:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lawlist.com; s=default; h=Content-Type:MIME-Version:Subject:Cc:To:From:Message-ID:Date; bh=omc5hAXn21anqZZ03c08Z/r//OOUecyBn6pAeoM8fe0=; b=R1doE7USryMXUkEyZS0bTwy7EpjMpsEKdfmgegv89b3tioED429c6/PU1B8oo5ymMTcJfj6DcrF1uZrUWuG6DjJs9Q3h6Z4KJIcSTVaVn4HxGEDvyI8/KT4+YO2KLY+Q; Original-Received: from cpe-45-48-239-195.socal.res.rr.com ([45.48.239.195]:50473 helo=server.private.localhost) by cobb.liquidweb.com with esmtp (Exim 4.82) (envelope-from ) id 1aXwRJ-0002st-St; Mon, 22 Feb 2016 14:46:38 -0500 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - cobb.liquidweb.com X-AntiAbuse: Original Domain - debbugs.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lawlist.com X-Get-Message-Sender-Via: cobb.liquidweb.com: acl_c_relayhosts_text_entry: lawlist|lawlist.com 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:113490 Archived-At: Here is the custom function that I came up with, derived in part from `faces.el`, `color.el` and from Drew's color libraries. (defun color-vector-calc (buffer-or-window pos fg-or-bg) "Calculate the color vector of either :foreground or :background for the face at POS. Sample usage: (color-vector-calc (selected-window) (point) 'foreground) The first argument BUFFER-OR-WINDOW is used in the context of `get-char-property'. The second argument POS is a user specified `point' somewhere in the buffer/window. The third argument FG-OR-BG is a symbol of either 'foreground or 'background" (let* ( (frame (selected-frame)) (+-default-face-fg (face-attribute-specified-or (face-attribute 'default :foreground frame 'default) nil)) (+-default-face-bg (face-attribute-specified-or (face-attribute 'default :background frame 'default) nil)) (faceprop (or (get-char-property pos 'read-face-name buffer-or-window) (get-char-property pos 'face buffer-or-window) 'default)) (face (cond ((symbolp faceprop) faceprop) ((and (consp faceprop) (not (keywordp (car faceprop))) (not (memq (car faceprop) '(foreground-color background-color)))) (car faceprop)) (t ;; e.g., (:foreground yellow) faceprop))) (color (cond ((and face (symbolp face)) (if (eq 'foreground fg-or-bg) (face-attribute-specified-or (face-attribute face :foreground frame 'default) nil) (face-attribute-specified-or (face-attribute face :background frame 'default) nil))) ((and (eq 'foreground fg-or-bg) (consp face)) (cond ((memq 'foreground-color face) (cdr (memq 'foreground-color face))) ((memq ':foreground face) (cadr (memq ':foreground face))) (t +-default-face-fg))) ((and (eq 'background fg-or-bg) (consp face)) (cond ((memq 'background-color face) (cdr (memq 'background-color face))) ((memq ':background face) (cadr (memq ':background face))) (t +-default-face-bg))) (t (if (eq 'foreground fg-or-bg) +-default-face-fg +-default-face-bg)))) (color-values (cond ((member color '(unspecified "unspecified-fg" "unspecified-bg")) nil) ((memq (framep (or frame (selected-frame))) '(x w32 ns)) (xw-color-values color frame)) (t (tty-color-values color frame)))) (value (mapcar (lambda (x) (let* ( (valmax (cond ((memq (framep (or frame (selected-frame))) '(x w32 ns)) (xw-color-values "#ffffff" frame)) (t (tty-color-values "#ffffff" frame)))) (+-valmax (float (car valmax)))) (/ x +-valmax))) color-values)) ) (vconcat value)))