unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
Cc: emacs-devel@gnu.org
Subject: Re: font-lock-extend-region-function: Final refinements.
Date: Fri, 4 Aug 2006 09:55:36 +0100	[thread overview]
Message-ID: <20060804085536.GA1107@muc.de> (raw)
In-Reply-To: <jwvirl9llf2.fsf-monnier+emacs@gnu.org>

Morning, Stefan!

[ cc: emacs-devel added.]

On Thu, Aug 03, 2006 at 02:43:23PM -0400, Stefan Monnier wrote:
> > One small point - there are slightly different mechanisms in
> > jit-lock-after-change and font-lock-after-change-function for
> > extending the region.  Is there a reason for this?

> Yes.

> Basically here is what happens in f-l-after-change:
> A1 - obey f-l-extend-after-change-function.

> Here is what happens in j-l-after-change (via
> f-l-extend-jit-lock-region-after-change):
> B1 - obey f-l-extend-after-change-function.
> B2 - obey font-lock-multiline (just once: no looping).
> B3 - round up to whole lines.

> - A1 == B1.

That's not quite true.  B1 uses j-l-after-change-extend-region-functions,
which has the same purpose as f-l-extend-after-change-function, but a
different calling convention.  I can't see any reason why these two need
to be different - it seems to be an unnecessary complication.

font-lock-extend-region-functions uses yet a third calling convention,
although what it is doing is almost (but not quite) the same as A1 and
B1.

Could we not decide on the one or the other calling convention and use it
in both places?  At the very least, could we not use just one pair of
variables rather than both `font-lock-beg/end' and `jit-lock-start/end'?
With both pairs of variables, I can foresee lots of major mode code
ugliness like this:

   (set (if from-jit-a-c 'jit-lock-start 'font-lock-beg) construct-start)

> - B3 is only present so as to avoid double redisplay.  I.e. it's not needed
>   for correctness.  It could/should be replaced by the same code as what is
>   done in f-l-default-fontify-region, except that would be potentially
>   too costly.
> - B2 OTOH is important: it's the main way font-lock-multiline works: it
>   marks the part of the text that will need to be refontified before being
>   redisplayed.  It does not care about it being refontified atomically,
>   which is why it does not loop.

> Why is there no corresponding A2?  Because f-l-after-change ends up
> calling f-l-fontify-region where f-l-multiline is obeyed anyway.

I've thought this over for some time, and I'm convinced that's all
right.

> Note that the use of f-l-multiline in f-l-fontify-region is not
> reliable: it's basically using it to do /identification/ which is
> known not be reliable, but experience shows that it can be useful to
> do it, so that if a piece of text does get identified somehow at some
> point, its multilineness will usually be preserved.

I can't see that it's unreliable, but I'll take your word for it.  The
lack of f-l-multiline (or like-minded hook function) is what fouled up
the highlighting in the example I gave a day or two ago, after 500
bytes:

[This one:
#ifndef VMS   /* VMS hates multi-line '#if's */
# if !defined(ibm032)                    && \
     !defined(__convex__)                &&          \
     !(defined(vax) && !defined(ultrix)) &&           \
...
...
]

I agree with you that f-l-multiline needs to be checked in
f-l-fontify-region.

>         Stefan

-- 
Alan.

  parent reply	other threads:[~2006-08-04  8:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-30 12:48 font-lock-extend-region-function: Final refinements Alan Mackenzie
2006-04-30 14:55 ` Stefan Monnier
2006-04-30 20:54 ` Richard Stallman
     [not found] ` <jwv8xm6p9jx.fsf-monnier+emacs@gnu.org>
     [not found]   ` <20060803163040.GC1282@muc.de>
     [not found]     ` <jwvirl9llf2.fsf-monnier+emacs@gnu.org>
2006-08-04  8:55       ` Alan Mackenzie [this message]
2006-08-04 14:59         ` Stefan Monnier
2006-08-06 13:48           ` Alan Mackenzie
2006-08-07 17:45             ` Stefan Monnier
2006-08-07 22:49               ` Alan Mackenzie

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=20060804085536.GA1107@muc.de \
    --to=acm@muc.de \
    --cc=emacs-devel@gnu.org \
    /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).