unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Dave Goel <deego3@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: Faces: How to clear an attribute while continuing to inherit other attributes?
Date: Thu, 10 Oct 2019 21:07:46 +0300	[thread overview]
Message-ID: <83pnj4qxsd.fsf@gnu.org> (raw)
In-Reply-To: <CAOCW0DgcGM+FgvPF5_Aez=N5agQhXRsJSshPFZjWTc91CYVqog@mail.gmail.com> (message from Dave Goel on Thu, 10 Oct 2019 13:50:33 -0400)

> From: Dave Goel <deego3@gmail.com>
> Date: Thu, 10 Oct 2019 13:50:33 -0400
> Cc: emacs-devel@gnu.org
> 
> Of course, but that runs counter to the philosophy of inheritance. If you changed the default, you have to then
> go back and change all such faces. 

Not if your code does

  (set-face-foreground FACE (face-foreground 'default))

With this, if the default face changes the color, FACE will follow
suit.

You could also try inheriting from both default and another face,
although I'm not sure this will do what you want (as I don't yet have
a clear idea of what you are trying to do)

> Again, if it was something like :underline or :bold or :height, you wouldn't see this problem: setting them to nil
> would remove any inheritance, and then, whenever you change the 'default face, your face's final resolved
> value automatically uses that.   

That's because for boolean attributes nil is a valid value, whereas
valid values for colors are strings, so nil isn't valid and is taken
as unspecified.

You must understand that face inheritance is a one-way street: Emacs
merges all the faces in the chain starting from default and going down
the inheritance chain, so the last face in the chain that specifies a
color wins.

> It seems that :fg and :bg also try to implement precisely that (providing a nil option as well as 'unspecified),
> but then don't do the final step correctly.

I don't see anything incorrect in what you describe, it is all
expected behavior.

> It seems that the design of faces goes out of its way to carefully distinguish nil from 'unspecified, precisely to
> allow you to clear an attribute..

See above: I think your conclusion is wrong.



  reply	other threads:[~2019-10-10 18:07 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-10  2:42 Faces: How to clear an attribute while continuing to inherit other attributes? Dave Goel
2019-10-10  8:09 ` Eli Zaretskii
2019-10-10 15:56   ` Dave Goel
2019-10-10 15:59     ` Dave Goel
2019-10-10 17:37     ` Eli Zaretskii
2019-10-10 17:50       ` Dave Goel
2019-10-10 18:07         ` Eli Zaretskii [this message]
2019-10-10 18:26           ` Dave Goel
2019-10-10 18:39             ` Eli Zaretskii
     [not found]           ` <47578dbd-71ea-cb02-c337-96fb18af1915@lanl.gov>
     [not found]             ` <83k19cqvdi.fsf@gnu.org>
2019-10-11  0:56               ` Dave Goel
2019-10-11  1:13                 ` Dave Goel
2019-10-11  8:37                   ` Eli Zaretskii
2019-10-11  8:36                 ` Eli Zaretskii

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=83pnj4qxsd.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=deego3@gmail.com \
    --cc=emacs-devel@gnu.org \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).