emacs-devel
[Top][All Lists]
Advanced

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

Re: jit-lock refontifies too much


From: Stefan Monnier
Subject: Re: jit-lock refontifies too much
Date: Wed, 14 Sep 2005 07:53:50 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

>>>>> "martin" == martin rudalics <address@hidden> writes:

>>> (when font-lock-multiline
>>> (setq end (or (text-property-any end (point-max)
>>> 'font-lock-multiline nil)
>>> (point-max)))
>>> (goto-char end)
>>> (setq end (line-beginning-position 2)))
>>> ;; Now do the fontification.
>> 
>> 
>> I'd rather change jit-lock, since font-lock may be used without jit-lock.

> It would be unsafe to change jit-lock.  Currently it is not mandatory
> for a "font-lock-fontify-region-function" to adjust the end of the
> region.  delphi-fontify-region, for example, doesn't.  It does rely on
> jit-lock-fontify-now to provide correct endpoints.  Put this the other
> way round.  If font-lock-default-fontify-region's present approach to
> fontify an additional line were indeed mandatory, most current
> font-lock-fontify-region-functions would be invalid since they do not
> adjust the end of the region.

Indeed, you're right.  The problem has nothing to do with jit-lock:
font-lock does the same double-rounding even when jit-lock is turned off,
because font-lock-after-change-function also does the rounding.

> Anyway, my first solution should emulate your proposal.  It would
> suppress fontification of the second line iff jit-lock is turned on.
> Using font-lock without jit-lock would not change the current behavior:

In light of the above, I think that checking jit-lock-mode is not the
right approach.

How 'bout the patch below instead?


        Stefan


--- orig/lisp/font-lock.el
+++ mod/lisp/font-lock.el
@@ -1058,7 +1058,8 @@
                                           'font-lock-multiline nil)
                        (point-max)))
          (goto-char end)
-         (setq end (line-beginning-position 2))
+          ;; Round up to a whole line.
+          (unless (bolp) (setq end (line-beginning-position 2)))
          ;; Now do the fontification.
          (font-lock-unfontify-region beg end)
          (when font-lock-syntactic-keywords




reply via email to

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