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#18826: 24.3.94; c++-mode bad indentation after programmatic insert with locally changed syntax table Date: 25 Oct 2014 19:34:41 -0000 Organization: muc.de e.V. Message-ID: <20141025193441.10278.qmail@mail.muc.de> References: <86egtwgra0.fsf@yandex.ru> NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1414265729 17491 80.91.229.3 (25 Oct 2014 19:35:29 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 25 Oct 2014 19:35:29 +0000 (UTC) Cc: 18826@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Oct 25 21:35:23 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 1Xi77T-0005hs-5Y for geb-bug-gnu-emacs@m.gmane.org; Sat, 25 Oct 2014 21:35:23 +0200 Original-Received: from localhost ([::1]:54482 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xi77S-0002Wy-Oj for geb-bug-gnu-emacs@m.gmane.org; Sat, 25 Oct 2014 15:35:22 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58581) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xi77M-0002Ws-Lq for bug-gnu-emacs@gnu.org; Sat, 25 Oct 2014 15:35:20 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xi77I-0004sv-HX for bug-gnu-emacs@gnu.org; Sat, 25 Oct 2014 15:35:16 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:43389) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xi778-0004gv-L1; Sat, 25 Oct 2014 15:35:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Xi778-0000Jf-5U; Sat, 25 Oct 2014 15:35:02 -0400 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: Sat, 25 Oct 2014 19:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18826 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: Original-Received: via spool by 18826-submit@debbugs.gnu.org id=B18826.14142656881191 (code B ref 18826); Sat, 25 Oct 2014 19:35:02 +0000 Original-Received: (at 18826) by debbugs.gnu.org; 25 Oct 2014 19:34:48 +0000 Original-Received: from localhost ([127.0.0.1]:35487 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xi76t-0000J8-2E for submit@debbugs.gnu.org; Sat, 25 Oct 2014 15:34:47 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:35066 helo=mail.muc.de) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xi76p-0000Iy-8s for 18826@debbugs.gnu.org; Sat, 25 Oct 2014 15:34:44 -0400 Original-Received: (qmail 10279 invoked by uid 3782); 25 Oct 2014 19:34:41 -0000 In-Reply-To: X-Newsgroups: gnu.emacs.bug User-Agent: tin/2.2.0-20131224 ("Lochindaal") (UNIX) (FreeBSD/8.4-RELEASE (amd64)) 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:95081 Hello, Dmitry. In article you wrote: > I think the following should be harmless. Why does it result in broken > indentation? Why do you think it should be harmless? > 1. Open in c++-mode buffer with following contents: > int main(int argc, char** argv) { > fgets(0, 1, 2); > } > 2. Add an empty line after the semicolon, move cursor there, and > evaluate this: > (with-syntax-table (make-char-table 'syntax-table nil) > (modify-syntax-entry ?\( "(") > (modify-syntax-entry ?\) ")") > (modify-syntax-entry ?< "(") > (modify-syntax-entry ?> ")") > (insert "fgets(0, 1, 2)")) > 3. Press `;', see the indentation of the current line change, and > include (erroneously) two extra spaces: > int main(int argc, char** argv) { > fgets(0, 1, 2); > fgets(0, 1, 2); > } If you go to the semicolon at the end of line 2 and do C-u C-x = you'll see that that character has these text-properties: c-in-sws t c-is-sws t fontified t . The c-in-sws and c-is-sws indicate that the semicolon has been recognised and marked as syntactic whitespace. The second line thus gets parsed as "statement-cont", i.e. a continued statement, so it gets indented an extra level. If you cripple C++ Mode by substituting a wrong syntax table, you shouldn't be too surprised when things go "wrong". This seems like one of these "well, don't do that, then" bugs. Question: why do you want to play around with the syntax table in this manner? What are you trying to achieve? > Originally: https://github.com/company-mode/company-mode/issues/212 > In GNU Emacs 24.3.94.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.10.8) > of 2014-10-06 on axl > Repository revision: 117555 sdl.web@gmail.com-20141005005838-oyl694hqhu2d3632 > Windowing system distributor `The X.Org Foundation', version 11.0.11501000 > System Description: Ubuntu 14.04.1 LTS -- Alan Mackenzie (Nuremberg, Germany).