[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: |
Thu, 03 Nov 2005 13:59:44 +0100 |
User-agent: |
Mozilla Thunderbird 1.0 (Windows/20041206) |
> Setting syntax-begin-function is not enough because currently the
> font-lock-syntactically-fontified logic does not take advantage of
> syntax-begin-function.
A short excursion:
-- Function: syntax-ppss &optional pos
This function returns the state that the parser would have at
position POS, if it were started with a default start state at the
beginning of the buffer. Thus, it is equivalent to
`(parse-partial-sexp (point-min) POS)' ...
We know that's not always true: `syntax-begin-function' may find a stray
left paren in column zero and the values of `parse-partial-sexp' run
from `point-min' and `syntax-ppss' will differ.
-- Variable: syntax-begin-function
If this is non-`nil', it should be a function that moves to an
earlier buffer position where the parser state is equivalent to
`nil'--in other words, a position outside of any comment, string,
or parenthesis.
We know that writing such a function is impractical in general: The only
such position - when the language syntax allows some kind of nesting and
syntax-table properties may be used - is `point-min'.
Both issues are resolved by the "Left Margin Convention". A convention
that in last consequence precludes the use of syntax-table properties in
`syntax-begin-function'. Thus `syntax-begin-function' can establish a
safe position to start `font-lock-fontify-syntactic-keywords-region' and
`font-lock-fontify-syntactically-region' - if the latter is allowed to
set syntax-table properties. More precisely, the first safe position
preceding recent buffer changes and the first position to be fontified
otherwise.
What I'm interested in is whether that convention can be reasonably
adapted for languages that do not rely on opening delimiters in column
zero. For example a well-formed `sub' in Perl mode. Otherwise, such
languages continue to suffer the classic problem that you always have to
scan from `point-min' in order to establish a safe syntactic context.
If such a convention is reasonable I don't see great difficulties using
`syntax-begin-function' in `font-lock-fontify-syntactic-keywords-region'
`font-lock-fontify-syntactically-region' and (why not?) `syntax-ppss'.
To summarize: I believe we agree that font-locking without the "Left
Margin Convention" would be impractical for C or Lisp. I'm afraid that
font-locking without some equivalent convention is impractical for Perl.
- 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, 2005/11/02
- 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 <=
- 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