[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: perl mode color highlighting working badly
From: |
martin rudalics |
Subject: |
Re: perl mode color highlighting working badly |
Date: |
Wed, 02 Nov 2005 13:54:24 +0100 |
User-agent: |
Mozilla Thunderbird 1.0 (Windows/20041206) |
Half-baken ideas ahead - don't pay too much attention.
>>I believe that `jit-lock-after-change'
>>should contain something like
>
>
>> (setq font-lock-syntactically-fontified
>> (min font-lock-syntactically-fontified start))
>
>
> Note that jit-lock is supposed to be a generic framework used by packages
> such as font-lock (and glasses-mode). So adding font-lock specific code to
> it is ugly.
>
`jit-lock-after-change' already contains that (pretty useless) check for
`font-lock-multiline'. Though, `font-lock-turn-on-thing-lock' could put
this in a separate after-change-hook that got executed for jit-lock-mode
only.
> Let's say you have already fontified the whole buffer,
> and the following things happen:
> - someone modifies text between positions 50 and 60.
An after-change-hook would have set `font-lock-syntactically-fontified'
to something <= 50 here ...
> - font-lock-fontify-region is called on 50..60.
... which would set `font-lock-syntactically-fontified' to 60 ...
> The syntax-ppss state
> at position 60 may be different from what it used to be because
> syntactic-keywords may have added some syntax-table properties.
> - font-lock-fontify-region is called on 100..200.
> If font-lock-syntactic-keywords uses syntax-ppss, that means that the
> syntax-table properties placed on the text between 60-100 may depend on the
> syntax-ppss state at position 60. So in order to get the correct
> syntax-ppss at position 100, we should re-apply syntactic-keywords between
> 60 and 100.
>
... which would get done automatically with the after-change-hook since
`font-lock-syntactically-fontified' is 60 and that's where both the
syntactic-keywords pass and the syntactic pass would start.
Note that with `font-lock-syntax-props-depend-on-themselves' you have
the following problem:
1. Jump to a position X such that some portion of the buffer before X is
not keyword-fontified yet. `font-lock-syntactically-fontified' will
be around X. Essentially the configuration that started this thread.
2. Jump or scroll to some unfontified position Y < X.
`font-lock-syntactically-fontified' will now be around Y.
3. Jump or scroll to some unfontified position Z > X. You will have to
syntactically/syntactic-keyword refontify the buffer from Y to Z
although you have not modified a thing. And you also syntactically
refontify text that has been keyword-fontified before.
With an after-change-hook you wouldn't suffer this.
By the way, wouldn't it make sense to define `syntax-begin-function' for
perl-mode? Something like a "well-formed" `sub' starting in column zero
- ignoring any syntax-table properties. I believe it would be less
costly to run both `font-lock-fontify-syntactic-keywords-region' and
`font-lock-fontify-syntactically-region' from such a position.
- Re: perl mode color highlighting working badly, martin rudalics, 2005/11/01
- Re: perl mode color highlighting working badly, Stefan Monnier, 2005/11/01
- Re: perl mode color highlighting working badly,
martin rudalics <=
- Re: perl mode color highlighting working badly, Stefan Monnier, 2005/11/02
- Re: perl mode color highlighting working badly, Stefan Monnier, 2005/11/02
- Re: perl mode color highlighting working badly, martin rudalics, 2005/11/03
- Re: perl mode color highlighting working badly, Stefan Monnier, 2005/11/03
- Re: perl mode color highlighting working badly, martin rudalics, 2005/11/04
- Re: perl mode color highlighting working badly, Stefan Monnier, 2005/11/04
Re: perl mode color highlighting working badly, Stefan Monnier, 2005/11/02