[Top][All Lists]

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

Re: Last steps for pretesting (font-lock-extend-region-function)

From: Alan Mackenzie
Subject: Re: Last steps for pretesting (font-lock-extend-region-function)
Date: Wed, 19 Apr 2006 22:43:12 +0000 (GMT)

Evening, Stefan!

On Wed, 19 Apr 2006, Stefan Monnier wrote:

>> (ii) Writing font-lock-expand-region functions, one for CC Mode as a
>> whole (to replace (setq font-lock-lines-before 2)) and one for AWK Mode
>> (to replace the advising of the Font Lock after-change functions).

>BTW, I still intend to move font-lock-extend-region-function from
>after-change-functions to font-lock-fontify-region (or maybe even

That would radically change the meaning of the function.

Please keep Font Lock working equivalently with and without JIT switched
on.  Edebugging through font-lock-fontify-region (for debugging a mode's
font lock settings) is a nightmare when JIT is enabled.

How about the following compromise?  font-lock-extend-region-function
should get called BOTH in the two after-change functions AND in
jit-lock-fontify-now and font-lock-default-fontify-region.  The third
parameter (OLD-LEN) gets bound to nil in the new case.  In either case
the extend-region function is entitled to return nil.

My AWK extend region function would then look like this:

(defun c-awk-font-lock-extend-region (beg end old-len)
  (cons (c-awk-beginning-of-logical-line beg)
        (if old-len
            ;; From an after-change-function
            (c-awk-end-of-change-region beg end old-len)
          ;; From a fontifying routine
          (c-awk-end-of-logical-line end))))

>So if you really manage to use the current
>font-lock-extend-region-function (called from after-change-functions) in
>a way that's robust, efficient, .....

So far, yes (except, perhaps, for the need of an extend-region function
in j-l-f-n and f-l-d-f-r).

>.... and can't be done as efficiently/elegantly/robustly with a hook in
>font-lock-fontify-region (or with the font-lock-multiline property),
>please scream.


I don't think we're going to agree on the relative elegance of
font-lock-extend-region-function vs. font-lock-multiline.  I think that
the former is more elegant than the latter, and you think the latter is
the more elegant.

I'm convinced that either approach would be robust (hey, we're competent
hackers ;-).

However, I think that f-l-extend-region-function can be done more
efficiently by the major mode maintainer, in the sense that it will
require less time and effort reading manuals, reading fine source, and

>        Stefan


reply via email to

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