From: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: "Richard M. Stallman" <rms@gnu.org>,
Ralf Angeli <angeli@iwi.uni-sb.de>,
martin rudalics <rudalics@gmx.at>,
emacs-devel@gnu.org, bug-cc-mode@gnu.org
Subject: Re: font-lock-extend-region
Date: Mon, 20 Mar 2006 12:18:49 -0500 [thread overview]
Message-ID: <jwv7j6pqdq4.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <Pine.LNX.3.96.1060320110347.318B-100000@acm.acm> (Alan Mackenzie's message of "Mon, 20 Mar 2006 13:01:00 +0000 (GMT)")
[ I hope some of this exchange can get into some documentation somewhere.
I find it very useful to have to explain it in such details. ]
> Before I get going, I'd like to say I've spent some time getting to grips
> with jit-lock, and I think I now understand some of the things you were
> telling me. I also apologize for getting a bit grumpy about it last
> week.
Don't worry about it. I've been so edgy these days that I wouldn't notice
anyone else getting grumpy.
> I think there are two distinct issues here that we're confusing, and this
> is why we've found it so hard to agree:
> (i) calculating the region which needs refontifying.
> (ii) finding a safe place to start fontifying a single chunk.
Right. The first is generally handled by jit-lock-context-* (including the
jit-lock-defer-multiline property). The second is generally handled by the
font-lock-multiline property and by rounding up to a whole number of lines.
> font-lock-extend-region-function is intended to do (i). The functionality
> you're suggesting for f-l-default-fontify-region is for doing (ii).
In other words your use of font-lock-extend-region-function is specifically
to deal with issues that jit-lock-context-* tries to handle as well.
> I think the essence of the font-lock-multiline property is that it marks
> a chunk of text to be fontified atomically. Please confirm this
> impression or correct it for me.
Correct.
> Here's why I think the font-lock-multiline way is wrong. Taking my AWK
> example again:
> 1. "string \
> 2. over \
> 3. several \ <=========
> 4. #lines."
> Suppose the user replaces the backslash on L3 with 20k of code from the
> kill ring with M-y. The region to fontify now extends from L1 to EOL4
> (actually, it's now L1073). The display engine is going to request
> fontification from L1034. If I mark this entire region with
> font-lock-multiline, these 1073 lines will be (unnecessarily) fontified
> atomically, defeating the aims of jit-lock in this case.
The region is not automatically marked with font-lock-multiline, so you
can't really fault font-lock-multiline for it: it's your code that marks it
that is at fault.
[ Now don't get me wrong: the font-lock-multiline property is not perfect. ]
> What I think we need is a function called from f-l-default-f-region which
> will get a safe starting position at or before L1034.
Agreed. And I suggested we name it font-lock-extend-region-function.
You seem to be saying that you'd also want such a thing in
after-change-functions.
My belief is that you don't need it for the following reason: if you need to
refontify more than the 20K of code you just yanked, it can only be because
of elements at the beginning/end that need to be refontified atomically, so
you can just either place a font-lock-multiline property on them or extend
the region from f-l-default-fontify-region.
But maybe this is only true in theory, and reasons of performance (or
presence/absence of various info in different contexts) make it that you do
need an "extend-region" in font-lock-after-change-function. Is that what
you are saying?
Or is there some other reason to extend the region from
after-change-functions, other than atomic elements at the boundaries?
> What I think we should do is to put a hook into f-l-default-f-region to
> calculate a safe starting position (and probably also a safe stopping
> position).
Yes, we agree on that.
> Incidentally, referring to my diagram above, the region gets extended to
> whole lines more than once. For demand fontification, it is done first
> in jit-lock-fontify-now then in font-lock-default-fontify-region. For
> after-change fontification, it is done yet a third time in
> jit-lock-after-change.
Yes, it's a bit messy, partly for historical reasons.
> How about doing this only in f-l-default-f-r? This would make it easier
> for a mode maintainer to switch off this action, since he would then just
> have to put a modified function into the hook
> font-lock-fontify-region-function.
I believe the one in jit-lock-fontify-now could be removed (but this
function is also sadly called from external packages, so there may be some
minor compatibility issues).
But the one in jit-lock-after-change is needed because of what the comment
there says. Basically here is the scenario:
start with C code like
void foo
and add an open parenthesis at the end. The modified chunk is just the
open paren, so if you don't reset the `fontified' property on the whole
line, the redisplay engine will not redisplay `foo' and even if jit-lock
changes the `face' property on `foo' it does it after the display engine
decided what `foo' would look like. So if jit-lock-after-change doesn't
round up to whole lines, `foo' in the above scenario would only be
refontified at the next screen refresh :-(
I'd like to be able to solve this problem elsewhere than in
jit-lock-after-change (e.g. some way for jit-lock to say "hey, font-lock
modified this text before BEGIN, please make sure you redisplay it
immediately"), but even if I knew how to do that, I'd probably not use it
for whole-line-round-up because it would simply cause (almost) all redisplay
to be done twice.
Stefan
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
next prev parent reply other threads:[~2006-03-20 17:18 UTC|newest]
Thread overview: 102+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <E1D94Wo-0006AP-W2@fencepost.gnu.org>
2005-03-09 21:18 ` [sigra@home.se: C++-mode: Syntax highlighting: wrong color for function identifier depending on the kind of whitespace that follows] Alan Mackenzie
2005-03-09 22:35 ` Stefan Monnier
2005-03-10 8:00 ` Alan Mackenzie
2005-03-10 13:01 ` Stefan Monnier
2005-03-10 15:16 ` D. R. E. Moonfire
2005-03-10 17:01 ` Stefan Monnier
2005-03-10 20:09 ` Alan Mackenzie
2005-03-10 20:53 ` Stefan Monnier
2005-03-10 22:42 ` Alan Mackenzie
2005-03-11 20:28 ` Richard Stallman
2005-03-11 1:48 ` Richard Stallman
2005-03-11 19:43 ` Alan Mackenzie
2005-03-10 22:13 ` Martin Stjernholm
2005-03-10 22:59 ` Stefan Monnier
2005-03-11 20:27 ` Richard Stallman
2005-03-13 16:19 ` Martin Stjernholm
2005-03-14 1:07 ` Stefan Monnier
2005-03-19 22:23 ` Martin Stjernholm
2005-03-19 22:30 ` Stefan Monnier
2005-03-11 1:47 ` Richard Stallman
2005-03-11 4:47 ` Stefan Monnier
2005-03-12 0:56 ` Richard Stallman
2005-03-12 1:00 ` Stefan Monnier
2005-03-13 15:30 ` Richard Stallman
2005-03-11 1:46 ` Richard Stallman
2005-03-11 1:46 ` Richard Stallman
2006-02-12 13:06 ` Ralf Angeli
2006-02-12 16:20 ` Stefan Monnier
2006-02-12 22:58 ` Ralf Angeli
2006-02-13 22:10 ` Stefan Monnier
2006-02-14 7:53 ` martin rudalics
2006-02-14 19:00 ` Stefan Monnier
2006-02-14 20:13 ` martin rudalics
2006-02-14 21:08 ` Stefan Monnier
2006-02-15 10:17 ` martin rudalics
2006-02-15 10:38 ` Ralf Angeli
2006-02-15 14:20 ` martin rudalics
2006-02-15 14:56 ` Ralf Angeli
2006-02-15 16:40 ` martin rudalics
2006-02-15 17:03 ` Ralf Angeli
2006-02-16 11:10 ` Alan Mackenzie
2006-02-16 11:54 ` Vivek Dasmohapatra
2006-02-16 15:21 ` Stefan Monnier
2006-02-16 23:28 ` David Kastrup
2006-02-17 14:19 ` Stefan Monnier
2006-02-16 17:21 ` martin rudalics
2006-02-15 20:44 ` Alan Mackenzie
2006-02-16 0:40 ` Stefan Monnier
2006-02-15 20:56 ` Alan Mackenzie
2006-02-16 8:56 ` martin rudalics
2006-02-15 20:13 ` Alan Mackenzie
2006-02-16 9:02 ` martin rudalics
2006-02-14 8:18 ` Werner LEMBERG
2006-02-14 8:49 ` Ralf Angeli
2006-02-14 19:05 ` Stefan Monnier
2006-02-14 21:12 ` Ralf Angeli
2006-02-15 13:35 ` Stefan Monnier
2006-02-15 14:05 ` Ralf Angeli
2006-02-15 14:21 ` Ralf Angeli
2006-02-15 20:33 ` Alan Mackenzie
2006-02-15 21:13 ` Stefan Monnier
2006-02-15 21:59 ` Alan Mackenzie
2006-02-16 14:59 ` Kim F. Storm
2006-02-16 16:37 ` Stefan Monnier
2006-02-15 19:07 ` Alan Mackenzie
2006-02-15 21:42 ` Ralf Angeli
2006-02-16 11:20 ` Alan Mackenzie
2006-02-16 11:54 ` Ralf Angeli
2006-02-16 15:12 ` Alan Mackenzie
2006-02-17 7:56 ` martin rudalics
2006-02-17 11:32 ` Ralf Angeli
2006-02-17 13:22 ` martin rudalics
2006-02-17 13:33 ` Ralf Angeli
2006-02-16 16:32 ` Stefan Monnier
2006-02-16 0:38 ` Stefan Monnier
2006-02-16 9:51 ` Alan Mackenzie
2006-02-16 16:27 ` Stefan Monnier
2006-02-17 7:48 ` martin rudalics
2006-02-17 14:36 ` Stefan Monnier
2006-02-16 18:46 ` martin rudalics
2006-02-16 9:09 ` martin rudalics
2006-02-13 4:40 ` Richard M. Stallman
2006-02-13 5:25 ` Stefan Monnier
2006-02-14 0:39 ` Richard M. Stallman
2006-03-14 19:23 ` Alan Mackenzie
2006-03-14 22:11 ` Stefan Monnier
2006-03-15 8:52 ` martin rudalics
2006-03-15 9:02 ` Ralf Angeli
2006-03-15 10:22 ` Stefan Monnier
2006-03-15 11:40 ` Alan Mackenzie
2006-03-15 16:16 ` Stefan Monnier
2006-03-15 20:20 ` Richard Stallman
2006-03-20 8:16 ` font-lock-extend-region (was: [sigra@home.se: C++-mode: Syntax highlighting: wrong color for function identifier depending on the kind of whitespace that follows]) Stefan Monnier
2006-03-20 13:01 ` Alan Mackenzie
2006-03-20 17:18 ` Stefan Monnier [this message]
2006-03-21 16:05 ` font-lock-extend-region Alan Mackenzie
2006-03-21 21:32 ` font-lock-extend-region Stefan Monnier
2006-03-23 15:23 ` font-lock-extend-region Alan Mackenzie
2006-03-23 16:18 ` font-lock-extend-region Stefan Monnier
2006-02-15 19:34 ` [sigra@home.se: C++-mode: Syntax highlighting: wrong color for function identifier depending on the kind of whitespace that follows] Alan Mackenzie
2006-02-16 9:07 ` Ralf Angeli
2006-02-16 9:07 ` martin rudalics
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwv7j6pqdq4.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=angeli@iwi.uni-sb.de \
--cc=bug-cc-mode@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=rms@gnu.org \
--cc=rudalics@gmx.at \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).