all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Boris Buliga <boris@d12frosted.io>
To: stephen.berman@gmx.net
Cc: help-gnu-emacs@gnu.org
Subject: Re: Overriding inherited face attributes
Date: Wed, 28 Nov 2018 09:39:29 +0200	[thread overview]
Message-ID: <CAD5F_-Aarn2crEEFRzi5PT-6=mk4vNq_ZrDwHM6VYNv6J6mT2Q@mail.gmail.com> (raw)
In-Reply-To: <87pnuqfboc.fsf@gmx.net>

Stephen,

Thank you for the answer. Indeed, adding this property to the end resolves
my
problem.

--------------------------------------------------------------------------------

Stephen and Eli,

Regarding documentation.

1. We have a part saying that 'faces occurring earlier in the list have
higher
priority'. This is super clear and easy to check. For example,

  > (setq my-test-string (propertize "hello" 'face '(:inherit (:foreground
"orange"))))
  #("hello" 0 5 (face (:inherit (:foreground "orange"))))
  > (add-face-text-property 0 5 '(:foreground "red") nil my-test-string)
  nil
  > my-test-string
  #("hello" 0 5 (face ((:foreground "red") (:inherit ...))))

Inserting this string results in the red 'hello'.

If you try you do append the property to the end, you'll get an orange
'hello'.

So far so good. Then I tried to do the same with propertize and I've got
quite
different result.

  > (propertize "hello" 'face '(:foreground "red" :inherit (:foreground
"orange")))
  #("hello" 0 5 (face (:foreground "red" :inherit (:foreground "orange"))))
  ;; results in an orange text

  > (propertize "hello" 'face '((:foreground "red") (:inherit (:foreground
"orange"))))
  #("hello" 0 5 (face ((:foreground "red") (:inherit ...))))
  ;; results in a red text

To me, it's still confusing. Why in the first example I have an orange text
and
in the second one - red?

2. And there is a part saying something I don't quite understand about
inheritance.

> Attributes from inherited faces are merged into the face like an
underlying
> face would be, with higher priority than underlying faces.

This one looks good to me. If I understand this correctly - inherited face
attributes behave as usual face attributes. Am I right?

On Tue, 27 Nov 2018 at 23:33, Stephen Berman <stephen.berman@gmx.net> wrote:

> On Tue, 27 Nov 2018 22:18:45 +0200 Boris Buliga <boris@d12frosted.io>
> wrote:
>
> > Hi everyone,
> >
> > Sorry if this question was answered somewhere before. I searched and
> didn't
> > find any working solution, so here I am.
> >
> > Problem. Override a face attribute that is defined in an inherited face.
> >
> > For example, open up a new buffer in the fundamental mode and evaulate
> the
> > following experssion:
> >
> > (insert (propertize "hello" 'face '(:foreground "red" :inherit
> (:foreground
> > "orange"))))
> >
> > I expect the word 'hello' to be red, but instead, it is orange.
> >
> > So two questions:
> >
> > 1. Am I right to expect the text to be red?
> > 2. How to achieve this?
>
> I don't know the answer to your first questions, but the answer to the
> second question appears to be: switch the order.  At least, when I
> evaluate the following in fundamental mode, 'hello' is red:
>
> (insert (propertize "hello" 'face '(:inherit (:foreground "orange")
> :foreground "red")))
>
> In (info "(elisp) Special Properties") it says this: "The value of the
> [`face'] property can be... A list of faces... Faces occurring earlier
> in the list have higher priority."  And in (info "(elisp) Face
> Attributes") it says: "Attributes from inherited faces are merged into
> the face like an underlying face would be, with higher priority than
> underlying faces."  Whether this implies the above observed behavior is
> not clear to me.
>
> Steve Berman
>


-- 
Cheers,
Boris


  parent reply	other threads:[~2018-11-28  7:39 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-27 20:18 Overriding inherited face attributes Boris Buliga
2018-11-27 21:33 ` Stephen Berman
2018-11-28  6:19   ` Eli Zaretskii
2018-11-28 12:24     ` Stephen Berman
2018-11-28 13:06       ` Eli Zaretskii
2018-11-28 13:13         ` Stephen Berman
2018-11-28 16:18           ` Eli Zaretskii
2018-11-28 20:01             ` Stephen Berman
2018-11-28 20:35               ` Eli Zaretskii
2018-11-28 21:34                 ` Stephen Berman
2018-11-29  7:14                   ` Eli Zaretskii
2018-11-29 17:30                     ` Stephen Berman
2018-11-28 21:44                 ` Boris Buliga
2018-11-29  7:08                   ` Eli Zaretskii
2018-11-28  7:39   ` Boris Buliga [this message]
2018-11-28  7:51     ` Eli Zaretskii
2018-11-28  8:42       ` Boris Buliga

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAD5F_-Aarn2crEEFRzi5PT-6=mk4vNq_ZrDwHM6VYNv6J6mT2Q@mail.gmail.com' \
    --to=boris@d12frosted.io \
    --cc=help-gnu-emacs@gnu.org \
    --cc=stephen.berman@gmx.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.