all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: <tomas@tuxteam.de>
To: help-gnu-emacs@gnu.org
Subject: Re: typeface for keyword
Date: Mon, 15 Feb 2021 18:51:28 +0100	[thread overview]
Message-ID: <20210215175128.GH16960@tuxteam.de> (raw)
In-Reply-To: <trinity-81735604-33e1-4d89-ac23-ca61c0a1ccf9-1613409458037@3c-app-mailcom-bs12>

[-- Attachment #1: Type: text/plain, Size: 1742 bytes --]

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 #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

  reply	other threads:[~2021-02-15 17:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-15  4:53 typeface for keyword steve-humphreys
2021-02-15 15:55 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-02-15 17:17   ` steve-humphreys
2021-02-15 17:51     ` tomas [this message]
2021-02-15 17:53     ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-02-15 18:06       ` steve-humphreys
2021-02-15 19:22         ` steve-humphreys
2021-02-15 23:01           ` steve-humphreys

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=20210215175128.GH16960@tuxteam.de \
    --to=tomas@tuxteam.de \
    --cc=help-gnu-emacs@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 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.