* typeface for keyword
@ 2021-02-15 4:53 steve-humphreys
2021-02-15 15:55 ` Emanuel Berg via Users list for the GNU Emacs text editor
0 siblings, 1 reply; 8+ messages in thread
From: steve-humphreys @ 2021-02-15 4:53 UTC (permalink / raw)
To: Help Gnu Emacs
I am using the following typeface, but want to change so that
the face is the same as the typeface for keywords used in the
major mode that is loaded after opening the file (e.g. texinfo,
tex).
(defface tfcdye
'( (default :inherit bold)
( ((class color) (min-colors 88) (background light))
:foreground "#FF0000" )
( ((class color) (min-colors 88) (background dark))
:foreground "#FF0000" )
(t :inherit font-lock-builtin-face) )
"Colour typeface for tex commands.")
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: typeface for keyword
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
0 siblings, 1 reply; 8+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-02-15 15:55 UTC (permalink / raw)
To: help-gnu-emacs
steve-humphreys wrote:
> I am using the following typeface, but want to change so
> that the face is the same as the typeface for keywords used
> in the major mode that is loaded after opening the file
> (e.g. texinfo, tex).
>
> (defface tfcdye
> '( (default :inherit bold)
> ( ((class color) (min-colors 88) (background light))
> :foreground "#FF0000" )
> ( ((class color) (min-colors 88) (background dark))
> :foreground "#FF0000" )
> (t :inherit font-lock-builtin-face) )
> "Colour typeface for tex commands.")
It is easier to do it the other way around.
First find out what face you want to change.
Move point to the place where you see the face. Then use use
this function:
(defun what-face (pos)
(interactive "d")
(let ((face (or (get-char-property pos 'face)
(get-char-property pos 'read-cf-name) )))
(message "face: %s" (or face "no face")) ))
After that, set the face to whatever you like.
https://dataswamp.org/~incal/emacs-init/face.el
--
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: typeface for keyword
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
2021-02-15 17:53 ` Emanuel Berg via Users list for the GNU Emacs text editor
0 siblings, 2 replies; 8+ messages in thread
From: steve-humphreys @ 2021-02-15 17:17 UTC (permalink / raw)
To: moasenwood; +Cc: help-gnu-emacs
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.")
> Sent: Tuesday, February 16, 2021 at 3:55 AM
> From: "Emanuel Berg via Users list for the GNU Emacs text editor" <help-gnu-emacs@gnu.org>
> To: help-gnu-emacs@gnu.org
> Subject: Re: typeface for keyword
>
> steve-humphreys wrote:
>
> > I am using the following typeface, but want to change so
> > that the face is the same as the typeface for keywords used
> > in the major mode that is loaded after opening the file
> > (e.g. texinfo, tex).
> >
> > (defface tfcdye
> > '( (default :inherit bold)
> > ( ((class color) (min-colors 88) (background light))
> > :foreground "#FF0000" )
> > ( ((class color) (min-colors 88) (background dark))
> > :foreground "#FF0000" )
> > (t :inherit font-lock-builtin-face) )
> > "Colour typeface for tex commands.")
>
> It is easier to do it the other way around.
>
> First find out what face you want to change.
>
> Move point to the place where you see the face. Then use use
> this function:
>
> (defun what-face (pos)
> (interactive "d")
> (let ((face (or (get-char-property pos 'face)
> (get-char-property pos 'read-cf-name) )))
> (message "face: %s" (or face "no face")) ))
>
> After that, set the face to whatever you like.
>
> https://dataswamp.org/~incal/emacs-init/face.el
>
> --
> underground experts united
> http://user.it.uu.se/~embe8573
> https://dataswamp.org/~incal
>
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: typeface for keyword
2021-02-15 17:17 ` steve-humphreys
@ 2021-02-15 17:51 ` tomas
2021-02-15 17:53 ` Emanuel Berg via Users list for the GNU Emacs text editor
1 sibling, 0 replies; 8+ messages in thread
From: tomas @ 2021-02-15 17:51 UTC (permalink / raw)
To: help-gnu-emacs
[-- 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 --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: typeface for keyword
2021-02-15 17:17 ` steve-humphreys
2021-02-15 17:51 ` tomas
@ 2021-02-15 17:53 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-02-15 18:06 ` steve-humphreys
1 sibling, 1 reply; 8+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-02-15 17:53 UTC (permalink / raw)
To: help-gnu-emacs
steve-humphreys 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.")
If it is font-lock-keyword-face, why don't you just
change that?
Or is it something you like about that face, that you want to
use for your face?
--
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: typeface for keyword
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
0 siblings, 1 reply; 8+ messages in thread
From: steve-humphreys @ 2021-02-15 18:06 UTC (permalink / raw)
To: moasenwood; +Cc: help-gnu-emacs
> Sent: Tuesday, February 16, 2021 at 5:53 AM
> From: "Emanuel Berg via Users list for the GNU Emacs text editor" <help-gnu-emacs@gnu.org>
> To: help-gnu-emacs@gnu.org
> Subject: Re: typeface for keyword
>
> steve-humphreys 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.")
>
> If it is font-lock-keyword-face, why don't you just
> change that?
>
> Or is it something you like about that face, that you want to
> use for your face?
It will let users easily change the face. that occurs in various places
in the .el file. Would also like to define my own face and call that in
"tface", for instance use "tfcdye" below.
(defface tfcdye
'( (default :inherit bold)
( ((class color) (min-colors 88) (background light))
:foreground "#FF0000" )
( ((class color) (min-colors 88) (background dark))
:foreground "#FF0000" )
(t :inherit font-lock-builtin-face) )
"Colour typeface for tex commands.")
> --
> underground experts united
> http://user.it.uu.se/~embe8573
> https://dataswamp.org/~incal
>
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: typeface for keyword
2021-02-15 18:06 ` steve-humphreys
@ 2021-02-15 19:22 ` steve-humphreys
2021-02-15 23:01 ` steve-humphreys
0 siblings, 1 reply; 8+ messages in thread
From: steve-humphreys @ 2021-02-15 19:22 UTC (permalink / raw)
To: steve-humphreys; +Cc: help-gnu-emacs, moasenwood
Have coded the following for a user defined typeface.
I wonder how I could improve on this.
(defface tface-foreground
'( (default :inherit bold)
( ((class color) (min-colors 88) (background light))
:foreground "#00FF00" )
( ((class color) (min-colors 88) (background dark))
:foreground "#00FF00" )
(t :inherit font-lock-builtin-face) )
"User defined colour typeface.")
(defface keyword-tface
'((default :inherit tface-foreground))
"Colour typeface for keywords.")
> Sent: Tuesday, February 16, 2021 at 6:06 AM
> From: steve-humphreys@gmx.com
> To: moasenwood@zoho.eu
> Cc: help-gnu-emacs@gnu.org
> Subject: Re: typeface for keyword
>
>
> > Sent: Tuesday, February 16, 2021 at 5:53 AM
> > From: "Emanuel Berg via Users list for the GNU Emacs text editor" <help-gnu-emacs@gnu.org>
> > To: help-gnu-emacs@gnu.org
> > Subject: Re: typeface for keyword
> >
> > steve-humphreys 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.")
> >
> > If it is font-lock-keyword-face, why don't you just
> > change that?
> >
> > Or is it something you like about that face, that you want to
> > use for your face?
>
> It will let users easily change the face. that occurs in various places
> in the .el file. Would also like to define my own face and call that in
> "tface", for instance use "tfcdye" below.
>
> (defface tfcdye
> '( (default :inherit bold)
> ( ((class color) (min-colors 88) (background light))
> :foreground "#FF0000" )
> ( ((class color) (min-colors 88) (background dark))
> :foreground "#FF0000" )
> (t :inherit font-lock-builtin-face) )
> "Colour typeface for tex commands.")
>
>
> > --
> > underground experts united
> > http://user.it.uu.se/~embe8573
> > https://dataswamp.org/~incal
> >
> >
> >
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: typeface for keyword
2021-02-15 19:22 ` steve-humphreys
@ 2021-02-15 23:01 ` steve-humphreys
0 siblings, 0 replies; 8+ messages in thread
From: steve-humphreys @ 2021-02-15 23:01 UTC (permalink / raw)
To: steve-humphreys; +Cc: help-gnu-emacs
Can one make some functionality to select one face from another?
For instance, have a face which can be updated to be one face or
another. What is customarily done?
(defface keyword-tface-foreground
'( (default :inherit bold)
( ((class color) (background light)) :foreground "#00FF00" )
( ((class color) (background dark)) :foreground "#00FF00" )
(t :inherit font-lock-builtin-face) )
"Colour typeface for keywords.")
(defface keyword-tface
'((default :inherit keyword-tface-foreground))
"Colour typeface for keywords.")
(defface keyword-tface
'((default :inherit font-lock-keyword-face))
"Colour typeface for keywords.")
> Sent: Tuesday, February 16, 2021 at 7:22 AM
> From: steve-humphreys@gmx.com
> To: steve-humphreys@gmx.com
> Cc: moasenwood@zoho.eu, help-gnu-emacs@gnu.org
> Subject: Re: typeface for keyword
>
> Have coded the following for a user defined typeface.
> I wonder how I could improve on this.
>
> (defface tface-foreground
> '( (default :inherit bold)
> ( ((class color) (min-colors 88) (background light))
> :foreground "#00FF00" )
> ( ((class color) (min-colors 88) (background dark))
> :foreground "#00FF00" )
> (t :inherit font-lock-builtin-face) )
> "User defined colour typeface.")
>
> (defface keyword-tface
> '((default :inherit tface-foreground))
> "Colour typeface for keywords.")
>
>
>
>
> > Sent: Tuesday, February 16, 2021 at 6:06 AM
> > From: steve-humphreys@gmx.com
> > To: moasenwood@zoho.eu
> > Cc: help-gnu-emacs@gnu.org
> > Subject: Re: typeface for keyword
> >
> >
> > > Sent: Tuesday, February 16, 2021 at 5:53 AM
> > > From: "Emanuel Berg via Users list for the GNU Emacs text editor" <help-gnu-emacs@gnu.org>
> > > To: help-gnu-emacs@gnu.org
> > > Subject: Re: typeface for keyword
> > >
> > > steve-humphreys 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.")
> > >
> > > If it is font-lock-keyword-face, why don't you just
> > > change that?
> > >
> > > Or is it something you like about that face, that you want to
> > > use for your face?
> >
> > It will let users easily change the face. that occurs in various places
> > in the .el file. Would also like to define my own face and call that in
> > "tface", for instance use "tfcdye" below.
> >
> > (defface tfcdye
> > '( (default :inherit bold)
> > ( ((class color) (min-colors 88) (background light))
> > :foreground "#FF0000" )
> > ( ((class color) (min-colors 88) (background dark))
> > :foreground "#FF0000" )
> > (t :inherit font-lock-builtin-face) )
> > "Colour typeface for tex commands.")
> >
> >
> > > --
> > > underground experts united
> > > http://user.it.uu.se/~embe8573
> > > https://dataswamp.org/~incal
> > >
> > >
> > >
> >
> >
>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2021-02-15 23:01 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
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).