From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.cc-mode.general,gmane.emacs.devel Subject: Re: font-locking and open parens in column zero Date: Sun, 17 Sep 2006 23:13:55 +0200 Message-ID: <450DBA93.6000705@gmx.at> References: <4503E44B.5020406@gmx.at> <45055F33.4030007@gmx.at> <450915CA.40108@gmx.at> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1158527662 14218 80.91.229.2 (17 Sep 2006 21:14:22 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 17 Sep 2006 21:14:22 +0000 (UTC) Cc: bug-cc-mode@gnu.org, monnier@iro.umontreal.ca, emacs-devel@gnu.org Original-X-From: cc-mode-help-bounces@lists.sourceforge.net Sun Sep 17 23:14:20 2006 Return-path: Envelope-to: sf-cc-mode-help@m.gmane.org Original-Received: from lists-outbound.sourceforge.net ([66.35.250.225]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GP3xx-0004Nu-C2 for sf-cc-mode-help@m.gmane.org; Sun, 17 Sep 2006 23:14:17 +0200 Original-Received: from sc8-sf-list1-new.sourceforge.net (unknown [10.3.1.93]) by sc8-sf-spam2.sourceforge.net (Postfix) with ESMTP id A2B83129AC; Sun, 17 Sep 2006 14:14:16 -0700 (PDT) Original-Received: from sc8-sf-mx2-b.sourceforge.net ([10.3.1.92] helo=mail.sourceforge.net) by sc8-sf-list1-new.sourceforge.net with esmtp (Exim 4.43) id 1GP3xv-00016q-Ab for cc-mode-help@lists.sourceforge.net; Sun, 17 Sep 2006 14:14:15 -0700 Original-Received: from fencepost.gnu.org ([199.232.76.164]) by mail.sourceforge.net with esmtps (TLSv1:RC4-SHA:128) (Exim 4.44) id 1GP3xu-0000LT-CB for cc-mode-help@lists.sourceforge.net; Sun, 17 Sep 2006 14:14:15 -0700 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by fencepost.gnu.org with esmtp (Exim 4.34) id 1GP3xr-0003n2-OK for bug-cc-mode@gnu.org; Sun, 17 Sep 2006 17:14:11 -0400 Original-Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.52) id 1GP40V-0007C5-PC for bug-cc-mode@gnu.org; Sun, 17 Sep 2006 17:16:58 -0400 Original-Received: from [213.165.64.20] (helo=mail.gmx.net) by monty-python.gnu.org with smtp (Exim 4.52) id 1GP40V-0007Br-7f for bug-cc-mode@gnu.org; Sun, 17 Sep 2006 17:16:55 -0400 Original-Received: (qmail invoked by alias); 17 Sep 2006 21:14:05 -0000 Original-Received: from N728P019.adsl.highway.telekom.at (EHLO [62.47.34.243]) [62.47.34.243] by mail.gmx.net (mp037) with SMTP; 17 Sep 2006 23:14:05 +0200 X-Authenticated: #14592706 User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: de-DE, de, en-us, en Original-To: rms@gnu.org In-Reply-To: X-Y-GMX-Trusted: 0 X-Spam-Checker-Version: SpamAssassin 3.0.4 (2005-06-05) on monty-python X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=failed version=3.0.4 X-Spam-Score: 1.0 (+) X-Spam-Report: Spam Filtering performed by sourceforge.net. See http://spamassassin.org/tag/ for more details. Report problems to http://sf.net/tracker/?func=add&group_id=1&atid=200001 1.0 FORGED_RCVD_HELO Received: contains a forged HELO X-BeenThere: cc-mode-help@lists.sourceforge.net X-Mailman-Version: 2.1.8 Precedence: list List-Id: "Bug reports, feature requests, and general talk about CC Mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: cc-mode-help-bounces@lists.sourceforge.net Errors-To: cc-mode-help-bounces@lists.sourceforge.net Xref: news.gmane.org gmane.emacs.cc-mode.general:3846 gmane.emacs.devel:59945 Archived-At: > 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