From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: The current state of the comment-cache branch Date: Sat, 24 Dec 2016 14:00:03 +0200 Message-ID: <838tr5zge4.fsf@gnu.org> References: <20161223215056.GA2771@acm.fritz.box> <83fuldzre1.fsf@gnu.org> <20161224083054.GA2212@acm.fritz.box> <83bmw1zoy8.fsf@gnu.org> <20161224094246.GD2212@acm.fritz.box> <20161224113620.GF2212@acm.fritz.box> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1482580837 3049 195.159.176.226 (24 Dec 2016 12:00:37 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 24 Dec 2016 12:00:37 +0000 (UTC) Cc: lokedhs@gmail.com, emacs-devel@gnu.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Dec 24 13:00:28 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cKkzz-00088m-Mx for ged-emacs-devel@m.gmane.org; Sat, 24 Dec 2016 13:00:27 +0100 Original-Received: from localhost ([::1]:43206 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cKl04-0005ER-DC for ged-emacs-devel@m.gmane.org; Sat, 24 Dec 2016 07:00:32 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48186) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cKkzy-0005EM-JK for emacs-devel@gnu.org; Sat, 24 Dec 2016 07:00:27 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cKkzv-0007E9-HE for emacs-devel@gnu.org; Sat, 24 Dec 2016 07:00:26 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:48039) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cKkzv-0007Dv-Dj; Sat, 24 Dec 2016 07:00:23 -0500 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:3697 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1cKkzu-0003hq-DD; Sat, 24 Dec 2016 07:00:22 -0500 In-reply-to: <20161224113620.GF2212@acm.fritz.box> (message from Alan Mackenzie on Sat, 24 Dec 2016 11:36:20 +0000) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:210783 Archived-At: > Date: Sat, 24 Dec 2016 11:36:20 +0000 > Cc: emacs-devel , Eli Zaretskii > From: Alan Mackenzie > > > Could you or someone else explain why an open paren in column 0 can affect > > the parsing of syntax in cc-mode at all? After all, such parens have no > > special syntactic nor semantic meaning in C nor C++. > > It is a convention established in Emacs around ?40 years ago, that such > an open paren signalled the start of a defun. This sped Emacs up > enormously, since the alternative was searching back to the beginning of > the buffer to check whether the paren was at the top level. > > Currently, the only piece of low-level code which uses this convention is > back_comment in .../src/syntax.c. This scans backward over a comment to > its beginning. Scanning backwards is difficult, because you can't really > tell whether a string quote is contained within a comment, or a comment > marker might be contained within a string, .... back_comment is > heuristic, and sort of works OK. But it uses the open defun convention > to speed itself up. I think one missing piece of the puzzle, which is what confused Elias, is that open-paren-in-column-0-is-defun-start is not only about '(', it's about any character that has the "open parenthesis" syntax class under the current syntax tables. And in C mode, that includes '{' and '[', with the former being the important one. I think.