From: martin rudalics <rudalics@gmx.at>
Cc: bug-cc-mode@gnu.org, monnier@iro.umontreal.ca, emacs-devel@gnu.org
Subject: Re: font-locking and open parens in column zero
Date: Sun, 17 Sep 2006 23:13:55 +0200 [thread overview]
Message-ID: <450DBA93.6000705@gmx.at> (raw)
In-Reply-To: <E1GOyK7-0004Nf-PI@fencepost.gnu.org>
> It's the standard paren-in-column-zero problem which is decribed in the
> manual and not considered a bug in Elisp fontification either. I think,
> it should happen as frequently for C as it happens for Elisp.
>
> That seems unlikely to me. In my (small) experiments
> I did not observe this to happen at all. You've said it
> can happen, and I will take your word for it, but it appears
> to be unusual in practice.
It likely happens more frequently with stealth-fontification turned off.
> Hence a
> warning face for such parens could be useful just as it is for Elisp.
>
> I suppose so -- and isn't the feature available for C?
> When Emacs does get confused about a ( in C mode,
> does it show that ( in red?
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).
> 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.
> The reason for C mode to set this to nil
> is that C mode specifies its own way to find the start of a defun.
> My understanding is that if open-paren-in-column-0-is-defun-start is t
> then Emacs will ALWAYS look back for the last ( in column 0.
> This is clearly wrong for C mode.
Emacs means `beginning-of-defun-raw' here, I suppose, since that's the
only place where `open-paren-in-column-0-is-defun-start' is consulted.
I think it's of no importance if this is set in one way or the other
since `beginning-of-defun-raw' ALWAYS searches for a plain open paren
in column zero when `defun-prompt-regexp' is nil. Hence if looking back
"for the last ( in column 0" is wrong for C mode, as you say, using
`beginning-of-defun' is wrong for C mode.
BTW, I fail to understand why `open-paren-in-column-0-is-defun-start' is
a user option and what a user would be able to accomplish by setting it.
Doc-string and Info are rather misleading here and your understanding of
this confuses me even more.
> That motivation is strange since, if the c-state-cache does not contain
> anything useful, C mode has to use `beginning-of-defun'.
>
> Are you saying that this is the case where C mode fails to be
> sophisticated about finding the start of the function?
Yes. There's also an appropriate comment in cc-engine.el:
;; The position is far back. Try `c-beginning-of-defun-1'
;; (although we can't be entirely sure it will go to a position
;; outside a comment or string in current emacsen). FIXME:
;; Consult `syntax-ppss' here.
> Is that a bug in CC mode?
It's been that way ever since. It would have been nice if C mode
adopted the same convention as Elisp - namely to paint such parens red.
But my original complaint was about the NEWS entry insinuating that such
a feature existed for C mode. Hence we probably shouldn't bother.
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
next prev parent reply other threads:[~2006-09-17 21:13 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-10 10:09 font-locking and open parens in column zero martin rudalics
2006-09-10 18:52 ` Richard Stallman
2006-09-11 13:05 ` martin rudalics
2006-09-11 14:18 ` Stefan Monnier
2006-09-12 2:01 ` Richard Stallman
2006-09-14 8:41 ` martin rudalics
2006-09-17 15:12 ` Richard Stallman
2006-09-17 21:13 ` martin rudalics [this message]
2006-09-18 23:40 ` Richard Stallman
2006-09-19 9:00 ` martin rudalics
2006-09-23 3:34 ` Richard Stallman
2006-09-23 14:55 ` martin rudalics
2006-09-24 2:10 ` Richard Stallman
2006-09-24 9:42 ` martin rudalics
2006-09-25 0:46 ` Stefan Monnier
2006-09-25 8:05 ` martin rudalics
2006-09-25 3:17 ` Richard Stallman
2006-09-25 8:10 ` martin rudalics
2006-09-10 19:26 ` Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=450DBA93.6000705@gmx.at \
--to=rudalics@gmx.at \
--cc=bug-cc-mode@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).