From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#13244: cc-mode indentation fails depending on the phase of the moon Date: Thu, 27 Dec 2012 16:20:54 +0000 Message-ID: <20121227162054.GA3235@acm.acm> References: <7067FC50-22E1-4FF5-B634-A9062EF2849A@zdome.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1356625701 7405 80.91.229.3 (27 Dec 2012 16:28:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 27 Dec 2012 16:28:21 +0000 (UTC) Cc: 13244@debbugs.gnu.org To: Dietrich Epp Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Dec 27 17:28:36 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ToGJw-0000SH-Lk for geb-bug-gnu-emacs@m.gmane.org; Thu, 27 Dec 2012 17:28:36 +0100 Original-Received: from localhost ([::1]:45735 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ToGJi-0000JW-6e for geb-bug-gnu-emacs@m.gmane.org; Thu, 27 Dec 2012 11:28:22 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:37774) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ToGJf-0000Ic-FB for bug-gnu-emacs@gnu.org; Thu, 27 Dec 2012 11:28:20 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ToGJd-00066E-9k for bug-gnu-emacs@gnu.org; Thu, 27 Dec 2012 11:28:19 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:51771) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ToGJa-00065f-Ry; Thu, 27 Dec 2012 11:28:14 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1ToGKM-00083s-B3; Thu, 27 Dec 2012 11:29:02 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: <7067FC50-22E1-4FF5-B634-A9062EF2849A@zdome.net> Resent-From: Alan Mackenzie Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Thu, 27 Dec 2012 16:29:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13244 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: Original-Received: via spool by 13244-submit@debbugs.gnu.org id=B13244.135662570430936 (code B ref 13244); Thu, 27 Dec 2012 16:29:02 +0000 Original-Received: (at 13244) by debbugs.gnu.org; 27 Dec 2012 16:28:24 +0000 Original-Received: from localhost ([127.0.0.1]:33788 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1ToGJk-00082v-Ff for submit@debbugs.gnu.org; Thu, 27 Dec 2012 11:28:24 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:38594 helo=mail.muc.de) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1ToGJi-00082o-QS for 13244@debbugs.gnu.org; Thu, 27 Dec 2012 11:28:24 -0500 Original-Received: (qmail 37350 invoked by uid 3782); 27 Dec 2012 16:27:32 -0000 Original-Received: from acm.muc.de (pD9519CF7.dip.t-dialin.net [217.81.156.247]) by colin.muc.de (tmda-ofmipd) with ESMTP; Thu, 27 Dec 2012 17:27:30 +0100 Original-Received: (qmail 3385 invoked by uid 1000); 27 Dec 2012 16:20:55 -0000 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 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.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:69074 Archived-At: Hello, Dietrich. >This bug is weird. I couldn't use auto-indentation in a certain file. >I tried restarting Emacs, behavior persists. I upgraded to the latest >version from Bzr, behavior persists. I created a new account with no >.emacs file and tried from there, behavior persists. In comparison, >indentation works correctly in the Emacs that in the current Debian >Wheezy repository, which is 24.3.50.1. >Trying to automatically indent code inside the last function in the >attached file fails. It succeeds if I make almost any modification to >code above the last function in the file -- it could be something as >minor as adding a space on an empty line, but changing text in the >comments seems to have no effect. Indentation works in every function >but the last one (or any one you create below it). >The point at which indentation breaks is somewhere very close to the >bottom of the file, I deleted code from the bottom of the file until I >found the location where it breaks. What is happening is this: CC Mode maintains a cache of "safe positions" (i.e. positions not in a string or comment) approximately every 3000 bytes. By pure chance, one of these supposed positions in your file is at pos. 21002, which happens to be between the "/" and the "*" of the comment opener on L836. This position isn't safe at all, and is found due to a bug in a low level scanning routine (`parse-partial-sexp') in Emacs. Furthermore, that comment contains an "unbalanced" "'". So when CC Mode scans forward from that supposed safe position, it finds the "'" and thinks it's inside a string. This is why indentation isn't working in your file after that comment. As you've noted, the slightest change to the buffer and the error no longer happens (since the "safe" position is no longer inside the comment opener). Thank you very much indeed for taking the trouble to report this arcane bug. We actually noticed the possibility of this bug in December 2011 and discussed it a bit, but nobody actually got around to fixing it then. Maybe we should now. -- Alan Mackenzie (Nuremberg, Germany).