[Top][All Lists]

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

Re: AW: font-locking and open parens in column 0

From: martin rudalics
Subject: Re: AW: font-locking and open parens in column 0
Date: Fri, 03 Nov 2006 15:02:33 +0100
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

Good afternoon, Alan

>          1         2         3         4         5         6         7  3
> I agree with you.  :-)  However, my patch is to do with
> beginning-of-defun-raw, not font-locking.

My problem is with font-locking and I thought your patch wanted to
address that problem (as you also stated some lines below).

> Are you saying that
> open-paren-in-column-0-is-defun-start shouldn't exist at all?  When it is
> nil, a paren in column 0 may not, of itself, be regarded as a defun
> start.

I fail to understand the present state of things.  On the one hand,
`open-paren-in-column-0-is-defun-start' is customizable which means a
user should be able to set it and a major mode should respect that.  On
the other hand, c-mode deliberately sets this to nil.  I think users
should be free to express their choice here if they consider their
machine inapt for scanning from bob.

> I would say, rather, that font-locking should not use b-o-defun-raw when
> o-p-i-c-0-i-d-s is nil, except in exceptional circumstances.

Font-lock uses `syntax-ppss' which may call `syntax-begin-function'
which may be defined as `beginning-of-defun' which usually calls
`beginning-of-defun-raw'.  When I open a C file and jump to a position
before stealth fontification gets there, that's the way things behave.

> The case
> you spotted in syntax.c (and I've really no idea how you did ;-), is
> such an exceptional case.

I spotted that incidentally when scrolling backwards through syntax.c.
Anyway, it *is* exceptional and thus should not warrant any major
change.  Richard's patch just comes in handy.

> CC Mode caches parenthesis structures.

... which parallels the work of `syntax-ppss', hence we currently end up
with two caches for the same structures - I know c-mode has to work hard
to handle all sorts of older (X)Emacsen ...

> My patch did fix the bug (a whole screenful of misfontified string in
> syntax.c), though, didn't it?

It does fix it, and it's even pretty fast ;-).  But I still think the
"bug" is with the author who put the left paren in column zero of that
comment.  That author should be warned just as in emacs-lisp-mode.

> You're talking about my patch to beginning-of-defun-raw, here, not the
> stuff in CC Mode.  I don't have the source files to hand at the moment.
>>(1) Consult `syntax-ppss' first.
>>(2) Try to use the 9th field of the return value of
>>to find the outermost paren instead of up-/forward-/backward-listing.
>>(3) Crowd the cache of `syntax-ppss' in order to avoid further scans.
> OK, thanks!  I'll need to learn about these optimisations.
> begining-of-defun-raw, when used in font locking, could be distressingly
> slow without them.

Suggestion (1) obviously has nothing to do with font-locking (otherwise
we would end up with `syntax-ppss' calling `beginning-of-defun' calling
`syntax-ppss' ...) but with using `beginning-of-defun' interactively for
jumping to the beginning of the current function.  However, that's
something `c-beginning-of-defun' does perfectly for c-mode.

reply via email to

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