From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#46400: bug#45375: cc-mode indentation sometimes doesn't work Date: Sat, 13 Feb 2021 14:39:27 +0000 Message-ID: References: <87r1ll9e9n.fsf@tcd.ie> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="749"; mail-complaints-to="usenet@ciao.gmane.io" Cc: acm@muc.de, 46400@debbugs.gnu.org, =?UTF-8?Q?G=C3=A9za?= Herman , 45375@debbugs.gnu.org To: "Basil L. Contovounesios" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Feb 13 15:40:26 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lAw5y-00005b-99 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 13 Feb 2021 15:40:26 +0100 Original-Received: from localhost ([::1]:38096 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lAw5x-0000ro-7k for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 13 Feb 2021 09:40:25 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36610) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lAw5a-0000rC-RM for bug-gnu-emacs@gnu.org; Sat, 13 Feb 2021 09:40:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:50598) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lAw5a-0003oz-E7 for bug-gnu-emacs@gnu.org; Sat, 13 Feb 2021 09:40:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lAw5a-0004FI-Bj for bug-gnu-emacs@gnu.org; Sat, 13 Feb 2021 09:40:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 13 Feb 2021 14:40:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46400 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed Original-Received: via spool by 46400-submit@debbugs.gnu.org id=B46400.161322717716274 (code B ref 46400); Sat, 13 Feb 2021 14:40:02 +0000 Original-Received: (at 46400) by debbugs.gnu.org; 13 Feb 2021 14:39:37 +0000 Original-Received: from localhost ([127.0.0.1]:33910 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lAw5B-0004EK-7U for submit@debbugs.gnu.org; Sat, 13 Feb 2021 09:39:37 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:16117 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1lAw58-0004Dy-SP for 46400@debbugs.gnu.org; Sat, 13 Feb 2021 09:39:35 -0500 Original-Received: (qmail 68114 invoked by uid 3782); 13 Feb 2021 14:39:28 -0000 Original-Received: from acm.muc.de (p2e5d52cc.dip0.t-ipconnect.de [46.93.82.204]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Sat, 13 Feb 2021 15:39:27 +0100 Original-Received: (qmail 1069 invoked by uid 1000); 13 Feb 2021 14:39:27 -0000 Content-Disposition: inline In-Reply-To: <87r1ll9e9n.fsf@tcd.ie> X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:199932 Archived-At: Hello, Basil, Géza and Konstantin. Sorry I missed this bug report in December, and thanks, Basil, for drawing it to my attention. On Fri, Feb 12, 2021 at 21:17:56 +0000, Basil L. Contovounesios wrote: > reassign 45375 emacs,cc-mode > quit > [CCed CC Mode maintainer.] > Herman@debbugs.gnu.org, Géza writes: > > On current master (6af31fd71ff1a403c199c479577bcc145a547db1) indentation of > > C/C++ files sometimes doesn't work. I've bisected it: commit "9022df7027 > > Optimise c-parse-state for large buffers with few (if any) braces." introduced > > this behavior. > > This is how to reproduce: check out 9022df70270243f211c54ccd66800320148b8434, > > and execute "emacs -Q xdisp.c". Jump to line 2989 with M-g M-g 2989, move the > > cursor to the end of line of "Lisp_Object retval;", and press enter. The cursor > > will be moved to the correct place (correctly indented, cursor will be placed > > below the 'L' character of the previous line). Then push enter at end of line of > > "va_list ap;". For me, cursor will jump to the beginning of the line, it won't > > be indented. If I keep pressing enters, the next failure will be at "va_end > > (ap);". I'm not sure whether this exact steps reproduces for everyone, but it > > happened me 5 of 5 trials. If I don't press enter at the first line > > ("Lisp_Object retval;"), the problem doesn't happen for any of this function > > lines. But it will happen for somewhere else, if I keep trying (move around the > > file, press enter at random places: if will fail sooner or later). > > For my configuration (without -Q), this problem happens quite frequently during > > editing C++ code. > I tried following your recipe (the lines in xdisp.c have since moved > around a bit), but was unable to reproduce the issue. > Can you still reproduce it on your end? I can reproduce it easily on the indicated commit, and I have found where the problem is. It's in the handling of the c-state-cache (the cache which tracks the positions of certain braces/brackets/parentheses). Fixing it could be quite tricky, particularly given the need to retain optimisation for the case that the above commit "fixed". I am fairly, but not absolutely, sure that this is the same bug as 46400, but the bug scenario here is easier to reproduce than the other one, so I will concentrate on this bug first. Maybe we can join the bug reports later. > Thanks, > -- > Basil -- Alan Mackenzie (Nuremberg, Germany).