3

What is the idiomatic way to make one face the same as another?

Basically, I would like vertical-border to be exactly the same as default. Preferably, if default changes, so does vertical-border.

I'm not sure that creating a face alias is the right thing to do.

  • It's not clear that we should be aliasing one face as another.
  • By the time the init file is loaded, the vertical border has already rendered, and aliasing does not re-render the vertical border

At the very least, I'd like to have something like (copy-face 'default 'vertical-border) that copied all attributes of default into vertical-border, even if it's a one-time thing and the latter will not change when the former does.

  • 1
    You want to look-up/Google customize-face and the inherit property. – lawlist Sep 18 '16 at 16:32
3

What @lawlist said. But you can ask Emacs about it, not just Google.

C-h i m elisp to visit the Elisp manual, then i inherit TAB, to look up inheritance entries in the index. Choose inheritance, for faces.

That takes you to the manual node Face Attributes, which tells you all about how to make one face inherit from others.

Interactively, for your own use, you can do this:

  1. M-x customize-face vertical-border
  2. Change the definition, so that the face just inherits from face default.
  3. Save your changes.

To make the face inherit from default, check the Inherit attribute checkbox, and specify default as the fact to inherit from. (INS and DEL buttons insert a new line/entry and delete the current line/entry, respectively.)

  • 1
    Thanks, I found "alias" but not "inherit" in the manual. Alas, I realized what I actually wanted as to set the foreground of vertical-border the same as the background of default. – Tianxiang Xiong Sep 19 '16 at 0:50
  • 1
    Ah, that you cannot do using :inherit - it is separate for each face attribute. – Drew Sep 19 '16 at 1:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.