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

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

Re: typeface for keyword


From: tomas
Subject: Re: typeface for keyword
Date: Mon, 15 Feb 2021 18:51:28 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

On Mon, Feb 15, 2021 at 06:17:38PM +0100, steve-humphreys@gmx.com wrote:
> It is a very useful utility.  It was "font-lock-keyword-face".
> Am trying to define a face that I can change, so that the
> face is updated at multiple locations, by simply changing the
> font lock face.  But this makes emacs complain.
> 
> (defface tface
>   '(:inherit font-lock-keyword-face)
>   "Colour typeface to use.")

"this makes emacs complain" makes people trying to help you
go the extra mile to try things out and look them up.

Why don't you help others help you?

If you look into the defface documentation (you know how to
do that, don't you?) the second arg of defface (called there
SPEC) expects a list of lists (more exactly an alist). So
it begins with

  '((

The keys in the alist are the display types (you want to
adjust your faces to match display capabilities). The doco
says that there is one type 'default which matches everything.
For simplicity, we'll go with that. So it's

  '((default

Next, as the cdr of that (it's an alist. You've read on alists
in the Emacs docs, have you?) is the list of attributes and
their values, in alternating order. You only want one attribute,
:inherit, and its value is 'font-lock-keyword-face, so:

  '((default . (:inherit font-lock-keyword-face)))

All together:

  (defface tface
    '((default . (:inherit font-lock-keyword-face)))
    "Colour typeface to use")

As a simplification, since '(foo . (bar baz...)) is the same
as '(foo bar baz ...) (see the chapter on "lists" in your trusty
Emacs Lisp documentation), you can also write

  (defface tface
    '((default :inherit font-lock-keyword-face))
    "Colour typeface to use")

Cheers
 - t

Attachment: signature.asc
Description: Digital signature


reply via email to

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