[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: font-locking and open parens in column zero
From: |
martin rudalics |
Subject: |
Re: font-locking and open parens in column zero |
Date: |
Tue, 19 Sep 2006 11:00:38 +0200 |
User-agent: |
Mozilla Thunderbird 1.0 (Windows/20041206) |
> It can't. C mode uses its own `beginning-of-defun-function' and Emacs
> doesn't bother in that case (font-lock isn't clairvoyant).
>
> Where is the code which does this? We could look at making it
> handle the case where there is a beginning-of-defun-function,
> if you show me which code would need to be changed.
I lied. It fails because in the following check in font-lock.el
(if (and regexp
(eq (or syntax-begin-function
font-lock-beginning-of-syntax-function)
'beginning-of-defun)
(not beginning-of-defun-function))
;; Try to detect when a string or comment contains something that
;; looks like a defun and would thus confuse font-lock.
`syntax-begin-function' eqs `c-beginning-of-syntax'. That is, the
second conjunct fails and not the third one as I thought before. It
would be simple to fix this, e.g., by writing
(if (and regexp
(or (eq (or syntax-begin-function
font-lock-beginning-of-syntax-function)
'beginning-of-defun)
(get 'font-lock-beginning-of-syntax-function
'font-lock-warn-about-open-paren-in-column-0))
(not beginning-of-defun-function))
and adding
(put 'font-lock-beginning-of-syntax-function
'font-lock-warn-about-open-paren-in-column-0 t)
to the code of `c-font-lock-init' (or put that in `c-mode-hook').
But `font-lock-beginning-of-syntax-function' is "semi-obsolete" and it
might be therefore reasonable to have font-lock provide a buffer-local
variable, say `font-lock-warn-about-open-paren-in-column-0', let major
modes set this, and simplify the condition above accordingly.
> > My point is that the ( usually does not appear in red
> > because Emacs usually does not get confused by it.
>
> With `syntax-ppss' Emacs usually doesn't get confused for Elisp either.
> It will get confused iff it has to use `beginning-of-defun' when there's
> no suitable cache entry. Hence, whatever holds for Elisp holds for C.
>
> I can't follow what you are saying. It sounds like you are saying that
> this feature does NOT work as designed either for Lisp or for C.
> Is that what you mean?
With the introduction of `syntax-ppss' Emacs hardly ever fails to find
strings and comments. If and when it fails, the "paint misplaced parens
red" feature works as designed for Lisp. It does not work at all for C.
- font-locking and open parens in column zero, martin rudalics, 2006/09/10
- Re: font-locking and open parens in column zero, Richard Stallman, 2006/09/10
- Re: font-locking and open parens in column zero, martin rudalics, 2006/09/11
- Re: font-locking and open parens in column zero, Stefan Monnier, 2006/09/11
- Re: font-locking and open parens in column zero, Richard Stallman, 2006/09/11
- Re: font-locking and open parens in column zero, martin rudalics, 2006/09/14
- Re: font-locking and open parens in column zero, Richard Stallman, 2006/09/17
- Re: font-locking and open parens in column zero, martin rudalics, 2006/09/17
- Re: font-locking and open parens in column zero, Richard Stallman, 2006/09/18
- Re: font-locking and open parens in column zero,
martin rudalics <=
- Re: font-locking and open parens in column zero, Richard Stallman, 2006/09/22
- Re: font-locking and open parens in column zero, martin rudalics, 2006/09/23
- Re: font-locking and open parens in column zero, Richard Stallman, 2006/09/23
- Re: font-locking and open parens in column zero, martin rudalics, 2006/09/24
- Re: font-locking and open parens in column zero, Stefan Monnier, 2006/09/24
- Re: font-locking and open parens in column zero, martin rudalics, 2006/09/25
- Re: font-locking and open parens in column zero, Richard Stallman, 2006/09/24
- Re: font-locking and open parens in column zero, martin rudalics, 2006/09/25
Re: font-locking and open parens in column zero, Stefan Monnier, 2006/09/10