bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#15298: 24.3.50; Background color lost when highlighting a string


From: Josh
Subject: bug#15298: 24.3.50; Background color lost when highlighting a string
Date: Fri, 13 Dec 2013 12:21:02 -0800

On Fri, Dec 13, 2013 at 10:45 AM, Eli Zaretskii <eliz@gnu.org> wrote:
>> From: Josh <josh@foxtail.org>
>> Date: Fri, 13 Dec 2013 08:14:38 -0800
>> Cc: Sebastien Vauban <sva-news@mygooglest.com>, 15298@debbugs.gnu.org
>>
>> On Fri, Dec 13, 2013 at 6:11 AM, Eli Zaretskii <eliz@gnu.org> wrote:
>> >> From: "Sebastien Vauban" <sva-news@mygooglest.com>
>> >> Date: Fri, 13 Dec 2013 13:50:26 +0100
>> >> Cc: 15298@debbugs.gnu.org
>> >>
>> >> Side question: when we observe such a word which is not highlighted as
>> >> we expect it, is there a way to see the list of all applied faces in the
>> >> order they are applied?  That'd help debugging such a problem...
>> >
>> > The problem in this case (and other similar ones) is that the face you
>> > expected was removed, and then another one applied to the same text.
>> > Removed faces are not recorded anywhere, as you might expect.
>>
>> Would (faces-at-position nil :include-all) reveal the absence of the
>> face Sebastien was expecting to have been in effect?
>
> I have no idea, as there's no such function in my Emacs.  But
> describe-text-properties will do the job.

Indeed, I've been using this function for long enough that I had
forgotten that it resides in my init file instead of Emacs proper.
It extends face-at-point to accept an optional position argument
and to optionally return all of the faces at point instead of only
the first when multiple faces are present.  Here it is, in case
anyone is interested:

(defun faces-at-position (&optional position include-all)
  "Return the face of the character after POSITION.
If no position is specified, (point) is used.  If the character has
more than one face, return only the first one unless INCLUDE-ALL is
non-nil.  Return nil if it has no specified face."
  (setq position (or position (point)))
  (let* ((faceprop (or (get-char-property position 'read-face-name)
                       (get-char-property position 'face)
                       'default))
         (face (cond ((symbolp faceprop) faceprop)
                     ;; List of faces (don't treat an attribute spec).
                     ;; Just use the first face.
                     ((and (consp faceprop) (not (keywordp (car faceprop)))
                           (not (memq (car faceprop)
                      '(foreground-color background-color))))
                      ;;(message "include-all: %s, faceprop: %s"
include-all faceprop)
                      (if include-all faceprop (car faceprop)))
                     (t nil))))         ; Invalid face value.
    (cond ((facep face) (list face))
          ((listp face) face)
          (t nil))))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]