* Font-lock seemingly interacting with insertion
@ 2018-03-21 5:28 Marcin Borkowski
2018-03-21 6:54 ` Eli Zaretskii
0 siblings, 1 reply; 14+ messages in thread
From: Marcin Borkowski @ 2018-03-21 5:28 UTC (permalink / raw)
To: Help Gnu Emacs mailing list
Hi all,
I want to insert a string with a part made bold (using
`add-face-text-property'). In certain buffers (e.g. in Fundamental
mode) this works, but in some other ones (e.g. in Org-mode or
message-mode) it does not. After turning font-lock off, it works back
again. This means that font-lock kicks in right after inserting and
disables my boldface.
Is there a way to make it not happen, without turning font lock off?
I understand that my description is slightly vague, but I suspect that
knowledgeable people might know the answer right away. If not, I can
provide code to show exactly what I am talking about.
TIA,
--
Marcin Borkowski
http://mbork.pl
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Font-lock seemingly interacting with insertion
2018-03-21 5:28 Font-lock seemingly interacting with insertion Marcin Borkowski
@ 2018-03-21 6:54 ` Eli Zaretskii
2018-03-21 7:24 ` Marcin Borkowski
2018-03-21 14:11 ` Michael Heerdegen
0 siblings, 2 replies; 14+ messages in thread
From: Eli Zaretskii @ 2018-03-21 6:54 UTC (permalink / raw)
To: help-gnu-emacs
> From: Marcin Borkowski <mbork@mbork.pl>
> Date: Wed, 21 Mar 2018 06:28:36 +0100
>
> I want to insert a string with a part made bold (using
> `add-face-text-property'). In certain buffers (e.g. in Fundamental
> mode) this works, but in some other ones (e.g. in Org-mode or
> message-mode) it does not. After turning font-lock off, it works back
> again. This means that font-lock kicks in right after inserting and
> disables my boldface.
Yes.
> Is there a way to make it not happen, without turning font lock off?
Not really. You can turn off JIT font-lock, but then you will have to
refontify manually, and I suspect that this would, for you, mean
"turning off font-lock".
Bottom line: in buffers with font-lock turned on, font-lock has
absolute control of the faces.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Font-lock seemingly interacting with insertion
2018-03-21 6:54 ` Eli Zaretskii
@ 2018-03-21 7:24 ` Marcin Borkowski
2018-03-21 7:47 ` Eli Zaretskii
2018-03-21 14:11 ` Michael Heerdegen
1 sibling, 1 reply; 14+ messages in thread
From: Marcin Borkowski @ 2018-03-21 7:24 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: help-gnu-emacs
On 2018-03-21, at 07:54, Eli Zaretskii <eliz@gnu.org> wrote:
>> From: Marcin Borkowski <mbork@mbork.pl>
>> Date: Wed, 21 Mar 2018 06:28:36 +0100
>>
>> I want to insert a string with a part made bold (using
>> `add-face-text-property'). In certain buffers (e.g. in Fundamental
>> mode) this works, but in some other ones (e.g. in Org-mode or
>> message-mode) it does not. After turning font-lock off, it works back
>> again. This means that font-lock kicks in right after inserting and
>> disables my boldface.
>
> Yes.
>
>> Is there a way to make it not happen, without turning font lock off?
>
> Not really. You can turn off JIT font-lock, but then you will have to
> refontify manually, and I suspect that this would, for you, mean
> "turning off font-lock".
>
> Bottom line: in buffers with font-lock turned on, font-lock has
> absolute control of the faces.
Thanks. This means that instead of inserting stuff with added faces,
I need either to modify font lock keywords or use overlays.
Best,
--
Marcin Borkowski
http://mbork.pl
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Font-lock seemingly interacting with insertion
2018-03-21 7:24 ` Marcin Borkowski
@ 2018-03-21 7:47 ` Eli Zaretskii
2018-03-21 9:05 ` Marcin Borkowski
0 siblings, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2018-03-21 7:47 UTC (permalink / raw)
To: help-gnu-emacs
> From: Marcin Borkowski <mbork@mbork.pl>
> Cc: help-gnu-emacs@gnu.org
> Date: Wed, 21 Mar 2018 08:24:31 +0100
>
> This means that instead of inserting stuff with added faces, I need
> either to modify font lock keywords or use overlays.
You could use hi-lock-mode instead. It plays well with font-lock.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Font-lock seemingly interacting with insertion
2018-03-21 7:47 ` Eli Zaretskii
@ 2018-03-21 9:05 ` Marcin Borkowski
0 siblings, 0 replies; 14+ messages in thread
From: Marcin Borkowski @ 2018-03-21 9:05 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: help-gnu-emacs
On 2018-03-21, at 08:47, Eli Zaretskii <eliz@gnu.org> wrote:
>> From: Marcin Borkowski <mbork@mbork.pl>
>> Cc: help-gnu-emacs@gnu.org
>> Date: Wed, 21 Mar 2018 08:24:31 +0100
>>
>> This means that instead of inserting stuff with added faces, I need
>> either to modify font lock keywords or use overlays.
>
> You could use hi-lock-mode instead. It plays well with font-lock.
Thanks. It might be a good idea, but you know, when I have a problem,
and I decide to use regexen... But I'll think about it. Thanks again!
Best,
--
Marcin Borkowski
http://mbork.pl
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Font-lock seemingly interacting with insertion
2018-03-21 6:54 ` Eli Zaretskii
2018-03-21 7:24 ` Marcin Borkowski
@ 2018-03-21 14:11 ` Michael Heerdegen
2018-03-21 15:24 ` Eli Zaretskii
1 sibling, 1 reply; 14+ messages in thread
From: Michael Heerdegen @ 2018-03-21 14:11 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: help-gnu-emacs
Eli Zaretskii <eliz@gnu.org> writes:
> > I want to insert a string with a part made bold (using
> > `add-face-text-property'). In certain buffers (e.g. in Fundamental
> > mode) this works, but in some other ones (e.g. in Org-mode or
> > message-mode) it does not. After turning font-lock off, it works back
> > again. This means that font-lock kicks in right after inserting and
> > disables my boldface.
>
> Yes.
>
> > Is there a way to make it not happen, without turning font lock off?
>
> Not really. You can turn off JIT font-lock, but then you will have to
> refontify manually, and I suspect that this would, for you, mean
> "turning off font-lock".
I thought the text property "font-lock-face" was exactly for such
cases. Isn't it appropriate in this case?
Michael.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Font-lock seemingly interacting with insertion
2018-03-21 14:11 ` Michael Heerdegen
@ 2018-03-21 15:24 ` Eli Zaretskii
2018-03-21 15:38 ` Michael Heerdegen
2018-03-25 16:55 ` Marcin Borkowski
0 siblings, 2 replies; 14+ messages in thread
From: Eli Zaretskii @ 2018-03-21 15:24 UTC (permalink / raw)
To: help-gnu-emacs
> From: Michael Heerdegen <michael_heerdegen@web.de>
> Cc: help-gnu-emacs@gnu.org
> Date: Wed, 21 Mar 2018 15:11:49 +0100
>
> I thought the text property "font-lock-face" was exactly for such
> cases. Isn't it appropriate in this case?
That's a possibility, but it will only work in modes/buffers that turn
on font-lock. AFAIU, that was not OP's intent.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Font-lock seemingly interacting with insertion
2018-03-21 15:24 ` Eli Zaretskii
@ 2018-03-21 15:38 ` Michael Heerdegen
2018-03-21 16:22 ` Eli Zaretskii
2018-03-22 0:39 ` Drew Adams
2018-03-25 16:55 ` Marcin Borkowski
1 sibling, 2 replies; 14+ messages in thread
From: Michael Heerdegen @ 2018-03-21 15:38 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: help-gnu-emacs
Eli Zaretskii <eliz@gnu.org> writes:
> That's a possibility, but it will only work in modes/buffers that turn
> on font-lock. AFAIU, that was not OP's intent.
I wasn't sure about the actual use case.
If it should work for both font-lock on and off, would it make sense to
add both a face and a font-lock-face property to the string to be
inserted?
Michael.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Font-lock seemingly interacting with insertion
2018-03-21 15:38 ` Michael Heerdegen
@ 2018-03-21 16:22 ` Eli Zaretskii
2018-03-22 0:39 ` Drew Adams
1 sibling, 0 replies; 14+ messages in thread
From: Eli Zaretskii @ 2018-03-21 16:22 UTC (permalink / raw)
To: help-gnu-emacs
> From: Michael Heerdegen <michael_heerdegen@web.de>
> Cc: help-gnu-emacs@gnu.org
> Date: Wed, 21 Mar 2018 16:38:28 +0100
>
> If it should work for both font-lock on and off, would it make sense to
> add both a face and a font-lock-face property to the string to be
> inserted?
Could be.
^ permalink raw reply [flat|nested] 14+ messages in thread
* RE: Font-lock seemingly interacting with insertion
2018-03-21 15:38 ` Michael Heerdegen
2018-03-21 16:22 ` Eli Zaretskii
@ 2018-03-22 0:39 ` Drew Adams
2018-03-22 6:53 ` Eli Zaretskii
` (2 more replies)
1 sibling, 3 replies; 14+ messages in thread
From: Drew Adams @ 2018-03-22 0:39 UTC (permalink / raw)
To: Michael Heerdegen, Eli Zaretskii; +Cc: help-gnu-emacs
> > That's a possibility, but it will only work in modes/buffers that turn
> > on font-lock. AFAIU, that was not OP's intent.
>
> I wasn't sure about the actual use case.
>
> If it should work for both font-lock on and off, would it make sense to
> add both a face and a font-lock-face property to the string to be
> inserted?
I haven't followed this, so the use case is not clear to me.
But if the OP wants highlighting that will be present whether
font-locking is on or off then font-lock is not the answer (!),
including its use of `font-lock-face'.
That text property just gives font-lock more control, not less.
And `hi-lock.el' just uses font-lock to do its job, so it too
is no escape from control by font-lock-mode.
If you want highlighting that is independent of font-lock then
you might give library `highlight.el' a try. It lets you
highlight using text properties or overlay properties, and the
highlighting can be independent of font-lock (or not - au choix).
If you want to be able to tell font-lock "hands off", i.e., to
ignore particular text, you can alternatively use text property
`font-lock-ignore'. For that, see library `font-lock+.el'.
See:
https://www.emacswiki.org/emacs/HighlightLibrary
See also this Emacs Dev discussion:
http://lists.gnu.org/archive/html/emacs-devel/2014-08/msg00540.html
http://lists.gnu.org/archive/html/emacs-devel/2014-08/msg00583.html
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Font-lock seemingly interacting with insertion
2018-03-22 0:39 ` Drew Adams
@ 2018-03-22 6:53 ` Eli Zaretskii
2018-03-25 17:00 ` Marcin Borkowski
[not found] ` <mailman.11214.1521997256.27995.help-gnu-emacs@gnu.org>
2 siblings, 0 replies; 14+ messages in thread
From: Eli Zaretskii @ 2018-03-22 6:53 UTC (permalink / raw)
To: help-gnu-emacs
> Date: Wed, 21 Mar 2018 17:39:12 -0700 (PDT)
> From: Drew Adams <drew.adams@oracle.com>
> Cc: help-gnu-emacs@gnu.org
>
> And `hi-lock.el' just uses font-lock to do its job, so it too
> is no escape from control by font-lock-mode.
That's not true. From the doc string of hi-lock-mode:
In buffers where Font Lock mode is enabled, patterns are
highlighted using font lock. In buffers where Font Lock mode is
disabled, patterns are applied using overlays
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Font-lock seemingly interacting with insertion
2018-03-22 0:39 ` Drew Adams
2018-03-22 6:53 ` Eli Zaretskii
@ 2018-03-25 17:00 ` Marcin Borkowski
[not found] ` <mailman.11214.1521997256.27995.help-gnu-emacs@gnu.org>
2 siblings, 0 replies; 14+ messages in thread
From: Marcin Borkowski @ 2018-03-25 17:00 UTC (permalink / raw)
To: Drew Adams; +Cc: Michael Heerdegen, help-gnu-emacs
On 2018-03-22, at 01:39, Drew Adams <drew.adams@oracle.com> wrote:
>> > That's a possibility, but it will only work in modes/buffers that turn
>> > on font-lock. AFAIU, that was not OP's intent.
>>
>> I wasn't sure about the actual use case.
>>
>> If it should work for both font-lock on and off, would it make sense to
>> add both a face and a font-lock-face property to the string to be
>> inserted?
>
> I haven't followed this, so the use case is not clear to me.
>
> But if the OP wants highlighting that will be present whether
> font-locking is on or off then font-lock is not the answer (!),
> including its use of `font-lock-face'.
font-lock-face won't work, but for different reasons. As I mentioned in
my previous message, I'll report back (in fact, I'll blog about it some
day) when the issue is solved. Most probably, I will have to use
overlays.
> If you want highlighting that is independent of font-lock then
> you might give library `highlight.el' a try. It lets you
> highlight using text properties or overlay properties, and the
> highlighting can be independent of font-lock (or not - au choix).
That is interesting - I even have that library because of
`hlt-highlight-region' - but in this case I don't want any
dependencies. But thanks anyway!
> If you want to be able to tell font-lock "hands off", i.e., to
> ignore particular text, you can alternatively use text property
> `font-lock-ignore'. For that, see library `font-lock+.el'.
Interesting, but again - external library.
Thanks,
--
Marcin Borkowski
http://mbork.pl
^ permalink raw reply [flat|nested] 14+ messages in thread
[parent not found: <mailman.11214.1521997256.27995.help-gnu-emacs@gnu.org>]
* Re: Font-lock seemingly interacting with insertion
[not found] ` <mailman.11214.1521997256.27995.help-gnu-emacs@gnu.org>
@ 2018-05-15 8:04 ` andlind
0 siblings, 0 replies; 14+ messages in thread
From: andlind @ 2018-05-15 8:04 UTC (permalink / raw)
To: help-gnu-emacs
Hi!
You could add your own custom property to `char-property-alias-alist'. This will work regardless if font-lock is active or not. This is how font-lock implements `font-lock-face', so you might find that it has the same drawbacks as `font-lock-face'.
One drawback that I can see is that some packages that convert buffers with syntax highlighting to other formats might not take this into account.
-- Anders
On Sunday, 25 March 2018 19:00:59 UTC+2, Marcin Borkowski wrote:
> On 2018-03-22, at 01:39, Drew Adams <drew.adams@oracle.com> wrote:
>
> >> > That's a possibility, but it will only work in modes/buffers that turn
> >> > on font-lock. AFAIU, that was not OP's intent.
> >>
> >> I wasn't sure about the actual use case.
> >>
> >> If it should work for both font-lock on and off, would it make sense to
> >> add both a face and a font-lock-face property to the string to be
> >> inserted?
> >
> > I haven't followed this, so the use case is not clear to me.
> >
> > But if the OP wants highlighting that will be present whether
> > font-locking is on or off then font-lock is not the answer (!),
> > including its use of `font-lock-face'.
>
> font-lock-face won't work, but for different reasons. As I mentioned in
> my previous message, I'll report back (in fact, I'll blog about it some
> day) when the issue is solved. Most probably, I will have to use
> overlays.
>
> > If you want highlighting that is independent of font-lock then
> > you might give library `highlight.el' a try. It lets you
> > highlight using text properties or overlay properties, and the
> > highlighting can be independent of font-lock (or not - au choix).
>
> That is interesting - I even have that library because of
> `hlt-highlight-region' - but in this case I don't want any
> dependencies. But thanks anyway!
>
> > If you want to be able to tell font-lock "hands off", i.e., to
> > ignore particular text, you can alternatively use text property
> > `font-lock-ignore'. For that, see library `font-lock+.el'.
>
> Interesting, but again - external library.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Font-lock seemingly interacting with insertion
2018-03-21 15:24 ` Eli Zaretskii
2018-03-21 15:38 ` Michael Heerdegen
@ 2018-03-25 16:55 ` Marcin Borkowski
1 sibling, 0 replies; 14+ messages in thread
From: Marcin Borkowski @ 2018-03-25 16:55 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: help-gnu-emacs
On 2018-03-21, at 16:24, Eli Zaretskii <eliz@gnu.org> wrote:
>> From: Michael Heerdegen <michael_heerdegen@web.de>
>> Cc: help-gnu-emacs@gnu.org
>> Date: Wed, 21 Mar 2018 15:11:49 +0100
>>
>> I thought the text property "font-lock-face" was exactly for such
>> cases. Isn't it appropriate in this case?
>
> That's a possibility, but it will only work in modes/buffers that turn
> on font-lock. AFAIU, that was not OP's intent.
I was quite vague, but indeed that was my intent. However,
font-lock-face generated further problems. I'll report back when
I solve the problem (I know how to do it, I just need more time).
Thanks,
--
Marcin Borkowski
http://mbork.pl
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2018-05-15 8:04 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-21 5:28 Font-lock seemingly interacting with insertion Marcin Borkowski
2018-03-21 6:54 ` Eli Zaretskii
2018-03-21 7:24 ` Marcin Borkowski
2018-03-21 7:47 ` Eli Zaretskii
2018-03-21 9:05 ` Marcin Borkowski
2018-03-21 14:11 ` Michael Heerdegen
2018-03-21 15:24 ` Eli Zaretskii
2018-03-21 15:38 ` Michael Heerdegen
2018-03-21 16:22 ` Eli Zaretskii
2018-03-22 0:39 ` Drew Adams
2018-03-22 6:53 ` Eli Zaretskii
2018-03-25 17:00 ` Marcin Borkowski
[not found] ` <mailman.11214.1521997256.27995.help-gnu-emacs@gnu.org>
2018-05-15 8:04 ` andlind
2018-03-25 16:55 ` Marcin Borkowski
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.