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

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

Re: Adding colour when font-lock in disabled


From: Eli Zaretskii
Subject: Re: Adding colour when font-lock in disabled
Date: Fri, 09 Dec 2022 14:06:23 +0200

> Date: Fri, 09 Dec 2022 08:09:08 +0000
> From: Heime <heimeborgia@protonmail.com>
> Cc: help-gnu-emacs@gnu.org
> 
> > What is weird about it? font-lock-mode places face properties
> > according to the mode's definitions, so it will overwrite any face
> > properties you put manually. Thus the need to use a different
> > property, which font-lock-mode doesn't control.
> 
> But them when a user wants to introduce some text with some properties (e.g. 
> colour), what is supposed to do.  

Users aren't supposed to introduce text properties, except via Lisp
programs.

> Would you expect someone to use font-lock-face when font-lock is enabled
> 
> (propertize "G" 'font-lock-face '(:foreground "green"))
> 
> --------
> 
> And use 
> 
> (propertize "G" 'face '(:foreground "green"))
> 
> when font lock is disabled.

The Lisp program which allows users to add faces should do something
like that, yes.

> Why places face properties according to the mode's definitions but not allow 
> us to change the properties of inserted text, when we can do that anyway?

Because font-lock must be in full control of face property to support
the situation where the user edits the text, and as result the faces
should change (e.g., because something that was previously just text
became a comment or a string, or vice versa).

> After calling a particular mode definitions, I should be able te change 
> properties rather than having a lock.

See above: the faces change dynamically to follow editing of the
buffer text.  It is not a one-time operation.

If a user wants to highlight addition portions of the buffer, the
user-level feature we provide is hi-lock-mode (a minor mode).  It
solves the complexity under the hood, and only requires the user to
specify the patterns to highlight.  So if you want an easy user-level
interface, I suggest to use that minor mode.



reply via email to

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