all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: JD Smith <jdtsmith@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 71345@debbugs.gnu.org, Stefan Monnier <monnier@iro.umontreal.ca>
Subject: bug#71345: Feature: unleash font-lock's secret weapon; handle Qfontified = non-nil
Date: Wed, 5 Jun 2024 11:52:37 -0400	[thread overview]
Message-ID: <9B55EAF1-C0FC-4B5B-A438-3B3C33430816@gmail.com> (raw)
In-Reply-To: <86a5jzjvar.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 3423 bytes --]



> On Jun 5, 2024, at 10:53 AM, Eli Zaretskii <eliz@gnu.org> wrote:
> 
>> From: JD Smith <jdtsmith@gmail.com>
>> Cc: monnier@iro.umontreal.ca, 71345@debbugs.gnu.org
>> Date: Wed, 5 Jun 2024 10:02:23 -0400
>> 
>> In general, yes.  In my case having the scope be per-buffer not per window makes the most sense in
>> terms of
>> 
>> the functionality.
>> 
>> Given the feature of redisplay I just mentioned, you will actually get
>> 
>> a per-window functionality, at least as far as the position of point
>> 
>> is concerned.
>> 
>> Not in my case, since I am discriminating between point in the selected window and other windows showing the
>> same buffer, such that switching windows = changing point. Since much of the work in my mode is not
>> position-dependent but depends on text content, updating face is the natural thing.  
> 
> Sorry, I don't think I understand you.  But if the fact that redisplay
> moves point to window-point doesn't bother me, we can drop this issue.

I use treesitter to identify nodes of interest, and do that in a PCH.  So there is one buffer-local record of where that node of interest is.  Thus different windows showing the same buffer is immaterial; the window where the last PCH ran controls.

>> Thinking more about what makes font-lock “special” as a jit-lock backend, it is exactly this: font-lock claims
>> exclusive ownership of `face'.  Solutions I can see:
>> 
>> 1 Make font-lock a good citizen by using its own alias for face. 
>> 2 Give other jit-lock backends which may alter face and potentially conflict with font-lock the ability to specify
>> to jit-lock “if you re-run font lock on a region, re-run me too after that.”
> 
> I don't understand.  The solution to this dilemma is well known: Lisp
> programs that want to control faces without turning off font-lock mode
> should set font-lock-face property, instead of the face property.  Why
> do you need to find another solution?

Because such programs may need to override locations where font-lock has already applied 'face.  In contrast to the documentation[1], font-lock does not itself use font-lock-face, but only configures it for other programs to use.  The issue is that 'face, where applied, always outranks any alias to 'face placed on the same text:

>>>>>> 
;; TEST (1st disable font-lock-mode)
(push 'my-face-prop (alist-get 'face char-property-alias-alist))
(put-text-property 1 8 'face 'error)
(put-text-property 1 8 'my-face-prop 'success) ; outranked by 'face
(remove-text-properties 1 8 '(face nil)) ; now we can see my-face-prop
<<<<<<<

It would be wonderful if font-lock cleared and applied a suitable face alias (perhaps 'font-lock-face itself).  This is what I mean by making font-lock a "good citizen": let other backends be able to override the faces it sets.  Currently, if font-lock-mode is enabled, it has effectively exclusive rights to the use of 'face on the locations it matches.  The only hope then is to arrange to run after font-lock, and use the "heavy hammer" of overwriting 'face yourself.

[1] From `Search-based Fontification': 
If it is ‘prepend’, the face specified by FACESPEC is added to the beginning of the ‘font-lock-face’ property.  If it is ‘append’, the face is added to the end of the ‘font-lock-face’ property.
But I believe all font-lock keywords actually just set the 'face property.

[-- Attachment #2: Type: text/html, Size: 9685 bytes --]

  reply	other threads:[~2024-06-05 15:52 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-03 16:35 bug#71345: Feature: unleash font-lock's secret weapon; handle Qfontified = non-nil JD Smith
2024-06-03 16:56 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-03 21:14   ` JD Smith
2024-06-04  1:44     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-04 12:08       ` JD Smith
2024-06-04 14:15         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-04 15:38           ` JD Smith
2024-06-04 21:52             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-04 22:41               ` JD Smith
2024-06-05 11:29                 ` Eli Zaretskii
2024-06-05 14:02                   ` JD Smith
2024-06-05 14:53                     ` Eli Zaretskii
2024-06-05 15:52                       ` JD Smith [this message]
2024-06-05 17:00                       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-05 17:24                         ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-05 11:24               ` Eli Zaretskii
2024-06-05 14:05                 ` JD Smith
2024-06-05 16:28                 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-05 16:38                   ` Eli Zaretskii
2024-06-05 16:59                     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-05 17:52                       ` Eli Zaretskii
2024-06-05 18:13                         ` JD Smith
2024-06-07  3:27                         ` JD Smith

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9B55EAF1-C0FC-4B5B-A438-3B3C33430816@gmail.com \
    --to=jdtsmith@gmail.com \
    --cc=71345@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.