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

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

Re: Changing highlight colours of headings when using outline-minor-mode


From: Eli Zaretskii
Subject: Re: Changing highlight colours of headings when using outline-minor-mode
Date: Sat, 17 Jun 2023 08:41:44 +0300

> Date: Fri, 16 Jun 2023 18:37:39 +0000
> From: uzibalqa <uzibalqa@proton.me>
> Cc: help-gnu-emacs@gnu.org
> 
> > > Have spent quite some time writing a function to do this but I am finding 
> > > it very hard
> > > to get something that actually works.
> > 
> > 
> > I don't understand what could be hard here. Just use
> > set-face-foreground and set-face-background.
> 
> I had written this, but which has got resulted in any effect upon heading 
> colours.

This doesn't use set-face-background and set-face-foreground.

> (defun heading-tyface ()
>   "Set colours for headings in `outline-minor-mode'."
>   (interactive)
> 
>   (let ( (beg (point-min))
>          (end (point-max)) )
> 
>     (outline-map-region
> 
>      (lambda ()
>        (let* ( ($hglevl (funcall outline-level))
>                ($tyface (cond
>                          ((= $hglevl 1) '(:foreground "red"))
>                          ((= $hglevl 2) '(:foreground "blue"))
>                          ((= $hglevl 3) '(:foreground "green"))
>                          (t '(:foreground "white")))) )
>          ;;--------------------------
>          (when (looking-at outline-regexp)
>            (put-text-property (point-at-bol) (point-at-eol)
>                               '$tyface $tyface))))
> 
>      beg end)
> 
>     (font-lock-flush)))

You cannot usefully use put-text-property to change faces in a buffer
in which font-lock-mode is turned on, because font-lock-mode begins by
erasing all the 'face' text properties, then puts its own 'face'
properties.



reply via email to

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