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

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

Re: custom-set-faces for various file types


From: Christopher Dimech
Subject: Re: custom-set-faces for various file types
Date: Sun, 22 Nov 2020 23:53:47 +0100

Would this be good

(add-hook 'org-mode-hook
   (lambda ()
      (face-remap-add-relative
         '(org-level-1 ((t (:foreground "cyan1"))))
         '(org-level-2 ((t (:foreground "chartreuse"))))
         '(org-level-3 ((t (:foreground "dark orange"))))
         '(org-level-4 ((t (:foreground "yellow"))))
         '(org-level-5 ((t (:foreground "magenta"))))
         '(org-level-6 ((t (:foreground "tan1"))))
         '(org-level-7 ((t (:foreground "deep sky blue"))))
         '(org-level-8 ((t (:foreground "orange red")))) )))



> Sent: Sunday, November 22, 2020 at 11:10 PM
> From: "Christopher Dimech" <dimech@gmx.com>
> To: "Michael Heerdegen" <michael_heerdegen@web.de>
> Cc: help-gnu-emacs@gnu.org
> Subject: Re: custom-set-faces for various file types
>
> Could you help me redo the following using face-remap
>
> (add-hook 'texinfo-mode-hook
>    (custom-set-faces
>       '(font-lock-variable-name-face ((t (:foreground "green"))))
>       '(font-lock-builtin-face ((t (:foreground "green"))))       ))
>
> ;; ----------------------------------------------------------------------
> ;; Colourise Texinfo Outlines Levels (Chapters, Sections, Headlines)
> (custom-set-faces
>    '(texinfo-heading
>        ((t (:inherit font-lock-function-name-face
>             :foreground "#ffdd00"))) ))
>
> ;; ----------------------------------------------------------------------
> ;; Colourise Org-Mode Heading Levels
> (custom-set-faces
>    '(org-level-1 ((t (:foreground "cyan1"))))
>    '(org-level-2 ((t (:foreground "chartreuse"))))
>    '(org-level-3 ((t (:foreground "dark orange"))))
>    '(org-level-4 ((t (:foreground "yellow"))))
>    '(org-level-5 ((t (:foreground "magenta"))))
>    '(org-level-6 ((t (:foreground "tan1"))))
>    '(org-level-7 ((t (:foreground "deep sky blue"))))
>    '(org-level-8 ((t (:foreground "orange red"))))    )
>
>
>
> > Sent: Sunday, November 22, 2020 at 10:39 PM
> > From: "Michael Heerdegen" <michael_heerdegen@web.de>
> > To: help-gnu-emacs@gnu.org
> > Subject: Re: custom-set-faces for various file types
> >
> > Christopher Dimech <dimech@gmx.com> writes:
> >
> > > > What is your goal?  Faces looking differently depending on the major
> > > > mode?
> > >
> > > I would like that some special constructs are highligthed so that the
> > > contrast would be suitable for assistive reasons.  For instance, in
> > > current texinfo modes, constructs in pure tex do not get highlighted.
> > > So I have some code that uses custom-set-faces in texi-init.el.
> > >
> > > The Manual says that custom-set-variables must be only called once.
> > > [...]
> >
> > I don't think custom is the right tool for your purpose.  Face
> > definitions are global.  You can switch between settings ("themes"), but
> > the effect is always global.
> >
> > For texinfo, maybe you could instead change the font-locking of the
> > mode?  It's defined in `texinfo-font-lock-keywords'.  Maybe it's enough
> > to add an entry to that list?
> >
> > Emacs also supports per-buffer modifications of faces.  The mechanism is
> > called "face-remap".  You could use it in the mode's hooks to change how
> > a face looks like in buffers using that mode.  `face-remap-add-relative'
> > is the function to use, takes a face and a list of specs.  Using that
> > would be a cleaner solution for your case I think.
> >
> > Michael.
> >
> >
> >
>
>



reply via email to

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