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#18970: 24.3; indent region fails in C++ mode after adding a #include Date: Fri, 7 Nov 2014 23:24:44 +0000 Message-ID: <20141107232444.GE2865@acm.acm> References: <20141106115429.80515.qmail@mail.muc.de> <545D3F5E.8030801@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1415402798 13021 80.91.229.3 (7 Nov 2014 23:26:38 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 7 Nov 2014 23:26:38 +0000 (UTC) Cc: 18970@debbugs.gnu.org To: Piotr Sipika Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Nov 08 00:26:31 2014 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 1XmsvF-0004Ut-QU for geb-bug-gnu-emacs@m.gmane.org; Sat, 08 Nov 2014 00:26:30 +0100 Original-Received: from localhost ([::1]:34265 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XmsvF-0005iW-8W for geb-bug-gnu-emacs@m.gmane.org; Fri, 07 Nov 2014 18:26:29 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57474) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xmsv4-0005gd-O1 for bug-gnu-emacs@gnu.org; Fri, 07 Nov 2014 18:26:26 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xmsux-00009u-6Z for bug-gnu-emacs@gnu.org; Fri, 07 Nov 2014 18:26:18 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:56043) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xmsuo-00008p-Tu; Fri, 07 Nov 2014 18:26:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Xmsuo-0003GC-JQ; Fri, 07 Nov 2014 18:26:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Fri, 07 Nov 2014 23:26:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18970 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: Original-Received: via spool by 18970-submit@debbugs.gnu.org id=B18970.141540272912489 (code B ref 18970); Fri, 07 Nov 2014 23:26:02 +0000 Original-Received: (at 18970) by debbugs.gnu.org; 7 Nov 2014 23:25:29 +0000 Original-Received: from localhost ([127.0.0.1]:53256 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XmsuG-0003FM-5w for submit@debbugs.gnu.org; Fri, 07 Nov 2014 18:25:28 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:52187 helo=mail.muc.de) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XmsuC-0003FA-FK for 18970@debbugs.gnu.org; Fri, 07 Nov 2014 18:25:25 -0500 Original-Received: (qmail 59007 invoked by uid 3782); 7 Nov 2014 23:25:23 -0000 Original-Received: from acm.muc.de (pD951BADF.dip0.t-ipconnect.de [217.81.186.223]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sat, 08 Nov 2014 00:25:21 +0100 Original-Received: (qmail 4972 invoked by uid 1000); 7 Nov 2014 23:24:44 -0000 Content-Disposition: inline In-Reply-To: <545D3F5E.8030801@gmail.com> 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.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.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:95694 Hello, Piotr. On Fri, Nov 07, 2014 at 04:53:34PM -0500, Piotr Sipika wrote: > Hi Alan, > > This bug will be dependent on the exact contents of the file, or at least > > the first few hundred or thousand bytes in it. Is there any chance you > > could post the file as it was just before you edited it in step 1., and > > say exactly what keys you used for 1. - 4.? > Hope this will help you: it seems that this problem has a higher rate of > occurrence when I kill the line with the #include (C-k) and then paste > it in (C-y). The buffer where the #include is inserted is the one where > the indentation problem occurs (it may be the same buffer in which the > line was killed). Yes, indeed, that helps a great deal! There was a problem with C-y'ing #include lines into a buffer back in May 2013, which was fixed, and the fix got into Emacs 24.4 (which was released a few days ago). To confirm that your problem is the same one, would you please do the following: (i) Kill a line starting with "#include" with C-k, then yank it back again with C-y. (ii) Move point to the beginning of that line and type C-u C-x = (`what-cursor-position' with a C-u prefix argument). (iii) You should see something like this: ######################################################################## position: 63 of 1339 (5%), column: 0 character: # (displayed as #) (codepoint 35, #o43, #x23) preferred charset: ascii (ASCII (ISO646 IRV)) code point in charset: 0x23 syntax: . which means: punctuation category: .:Base, a:ASCII, l:Latin, r:Roman to input: type "C-x 8 RET HEX-CODEPOINT" or "C-x 8 RET NAME" buffer code: #x23 file code: #x23 (encoded by coding system undecided-unix) display: terminal code #x23 Character code properties: customize what to show name: NUMBER SIGN general-category: Po (Punctuation, Other) decomposition: (35) ('#') There are text properties here: c-in-sws t c-is-sws t category c-cpp-delimiter face font-lock-preprocessor-face fontified t risky-local-variable t syntax-table nil <=================================================== [back] ######################################################################## If you see the syntax-table text property set to nil, as in the above, then we have found the bug. Either upgrade your Emacs to version 24.4, or apply the following patch to ..../emacs-24.3/lisp/progmodes/cc-mode.el: === modified file 'lisp/progmodes/cc-mode.el' --- lisp/progmodes/cc-mode.el 2013-05-02 11:18:18 +0000 +++ lisp/progmodes/cc-mode.el 2013-05-27 13:30:21 +0000 @@ -1077,12 +1077,13 @@ (setq beg end))) ;; C-y is capable of spuriously converting category properties - ;; c--as-paren-syntax into hard syntax-table properties. Remove - ;; these when it happens. + ;; c--as-paren-syntax and c-cpp-delimiter into hard syntax-table + ;; properties. Remove these when it happens. (c-clear-char-property-with-value beg end 'syntax-table c-<-as-paren-syntax) (c-clear-char-property-with-value beg end 'syntax-table c->-as-paren-syntax) + (c-clear-char-property-with-value beg end 'syntax-table nil) (c-trim-found-types beg end old-len) ; maybe we don't need all of these. (c-invalidate-sws-region-after beg end) [If you have any problems applying the patch, get back to me privately.] After applying the patch, byte compile cc-mode.el either with "M-x byte-compile-file" inside emacs, or do it from the command line like this: $ emacs -Q -batch -f batch-byte-compile .../emacs-24.3/lisp/progmodes/cc-mode.el Then copy the compiled file cc-mode.elc to where emacs normally loads it from. You can find this with "M-x locate-librarycc-mode" from inside emacs. Restart Emacs, and hopefully the bug will be gone. Please let me know whether or not this works. Thanks! > Piotr -- Alan Mackenzie (Nuremberg, Germany).