From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 25 10:26:12 2014 Received: (at submit) by debbugs.gnu.org; 25 Oct 2014 14:26:12 +0000 Received: from localhost ([127.0.0.1]:35374 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xi2IG-0001Lj-AM for submit@debbugs.gnu.org; Sat, 25 Oct 2014 10:26:12 -0400 Received: from eggs.gnu.org ([208.118.235.92]:45901) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xi2ID-0001LQ-Rd for submit@debbugs.gnu.org; Sat, 25 Oct 2014 10:26:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xi2I3-0007Dn-Mi for submit@debbugs.gnu.org; Sat, 25 Oct 2014 10:26:04 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:54823) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xi2I3-0007Dj-K0 for submit@debbugs.gnu.org; Sat, 25 Oct 2014 10:25:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47571) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xi2Hy-0003hW-KW for bug-gnu-emacs@gnu.org; Sat, 25 Oct 2014 10:25:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xi2Ht-0007Cl-Sd for bug-gnu-emacs@gnu.org; Sat, 25 Oct 2014 10:25:54 -0400 Received: from mail-pd0-x234.google.com ([2607:f8b0:400e:c02::234]:59885) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xi2Ht-0007CV-Kj for bug-gnu-emacs@gnu.org; Sat, 25 Oct 2014 10:25:49 -0400 Received: by mail-pd0-f180.google.com with SMTP id ft15so1081627pdb.39 for ; Sat, 25 Oct 2014 07:25:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id:mime-version:content-type; bh=b6+jzlMr7BQB3iKRBBRHwvWAKsCjUD93xIYXWfV60Ds=; b=v1Prwe4/jHWOuCuWVQpdikD6lKO5HvpQORRULS1EoZxpMgXueHskrr2LYKiAqEMZ9l Jfj2KK47R7UdGs3Bi3P+5bhUIy195cP8sAsMPt9lTZYxaLnkeKG+WN4gRI8zcXPeLQkf s1PXaQ2fTIRWkYe50Qu5vRW+Wm+0Z1Ug1pmfvvPj9nCi1LyTukLrqADHUP7qmkl2Mn9o 7m5F4rYRBkfnNdF71lcLIh5gDPpwnIMjo8yezw4NAYrsSnbviefzPV+QlZ4oY/svYr3H NSDKZFfQzsV2DIPV64Xcc60whrB/krzWdpsI2yjVmySuSxXvTQCOwaayMQPNnok+hiVt A/Yw== X-Received: by 10.67.5.41 with SMTP id cj9mr11330968pad.73.1414247147671; Sat, 25 Oct 2014 07:25:47 -0700 (PDT) Received: from axl ([113.160.248.69]) by mx.google.com with ESMTPSA id sa6sm6373031pbb.29.2014.10.25.07.25.45 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 25 Oct 2014 07:25:47 -0700 (PDT) From: Dmitry Gutov To: bug-gnu-emacs@gnu.org Subject: 24.3.94; c++-mode bad indentation after programmatic insert with locally changed syntax table Date: Sat, 25 Oct 2014 21:25:43 +0700 Message-ID: <86egtwgra0.fsf@yandex.ru> MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) I think the following should be harmless. Why does it result in broken indentation? 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); } 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 From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 25 15:34:48 2014 Received: (at 18826) by debbugs.gnu.org; 25 Oct 2014 19:34:48 +0000 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 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 Received: (qmail 10279 invoked by uid 3782); 25 Oct 2014 19:34:41 -0000 Date: 25 Oct 2014 19:34:41 -0000 Message-ID: <20141025193441.10278.qmail@mail.muc.de> From: Alan Mackenzie To: Dmitry Gutov Subject: Re: bug#18826: 24.3.94; c++-mode bad indentation after programmatic insert with locally changed syntax table Organization: muc.de e.V. In-Reply-To: X-Newsgroups: gnu.emacs.bug User-Agent: tin/2.2.0-20131224 ("Lochindaal") (UNIX) (FreeBSD/8.4-RELEASE (amd64)) X-Spam-Score: -2.2 (--) X-Debbugs-Envelope-To: 18826 Cc: 18826@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.2 (--) 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). From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 25 18:45:56 2014 Received: (at 18826) by debbugs.gnu.org; 25 Oct 2014 22:45:56 +0000 Received: from localhost ([127.0.0.1]:35541 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XiA5r-0004sw-QI for submit@debbugs.gnu.org; Sat, 25 Oct 2014 18:45:56 -0400 Received: from mail-pd0-f174.google.com ([209.85.192.174]:52380) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XiA5o-0004sd-MU for 18826@debbugs.gnu.org; Sat, 25 Oct 2014 18:45:53 -0400 Received: by mail-pd0-f174.google.com with SMTP id p10so3374229pdj.5 for <18826@debbugs.gnu.org>; Sat, 25 Oct 2014 15:45:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=7WI1I+PQofobyMM1E2BsF6p9cXSXnxRgLzKha/+8FAU=; b=JtSxjea771Nlu7+oCXtirCcaJuRA1j7XerOt5KhJPERRmVPoMa7DaojdSQjv7vwp7I 0sTHlSfWZxHtrBIEXmH4o3BafDuV6Ja0fbeCD2vDPdRZ/oLK6kmNn6xcDkTGE/Zftb0r LtpfomWyYV+ilTP6gDwnCu6xOlvahyu1TA62sjsANx+WsFXYkhlJ/gEYCFgKIXQNiJhz OFJrkXtj3fJKiOKyrBnnC9lPyqJ6gzgf6Tm2xf1AVH0ct3W9fxGb/2yA45mhV2OjBgUN nykhW5NQEDjx3fVdifijaHwtYxMlz3GVxhD20czi6GyvSlsVdhSX73Pemp3XjVLhfbCz pOQw== X-Received: by 10.68.251.99 with SMTP id zj3mr13592540pbc.105.1414277146416; Sat, 25 Oct 2014 15:45:46 -0700 (PDT) Received: from [192.168.2.52] ([113.160.248.69]) by mx.google.com with ESMTPSA id ib8sm7074927pad.43.2014.10.25.15.45.44 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Oct 2014 15:45:45 -0700 (PDT) Message-ID: <544C2816.8070704@yandex.ru> Date: Sun, 26 Oct 2014 05:45:42 +0700 From: Dmitry Gutov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: Alan Mackenzie Subject: Re: bug#18826: 24.3.94; c++-mode bad indentation after programmatic insert with locally changed syntax table References: <20141025193441.10278.qmail@mail.muc.de> In-Reply-To: <20141025193441.10278.qmail@mail.muc.de> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 18826 Cc: 18826@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) On 10/26/2014 02:34 AM, Alan Mackenzie wrote: > Why do you think it should be harmless? Because the syntax table change is temporary and its effect should be limited to my code? > . 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. Yes, I see that. But how does this happen? > 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? I'm using a different syntax table for sexp movement, where it's necessary for both parens and angle brackets to have paren syntax class. In the actual code I modify the text after it's inserted, and `backward-sexp' is used two times to find necessary search bounds. https://github.com/company-mode/company-mode/blob/42012730da15ffaef7c61722475040babed15332/company-template.el#L155-L173 From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 25 19:24:55 2014 Received: (at 18826) by debbugs.gnu.org; 25 Oct 2014 23:24:55 +0000 Received: from localhost ([127.0.0.1]:35553 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XiAha-0005mo-Ju for submit@debbugs.gnu.org; Sat, 25 Oct 2014 19:24:55 -0400 Received: from colin.muc.de ([193.149.48.1]:49608 helo=mail.muc.de) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XiAhX-0005me-53 for 18826@debbugs.gnu.org; Sat, 25 Oct 2014 19:24:52 -0400 Received: (qmail 90895 invoked by uid 3782); 25 Oct 2014 23:24:49 -0000 Date: 25 Oct 2014 23:24:49 -0000 Message-ID: <20141025232449.90894.qmail@mail.muc.de> From: Alan Mackenzie To: Dmitry Gutov Subject: Re: bug#18826: 24.3.94; c++-mode bad indentation after programmatic insert with locally changed syntax table Organization: muc.de e.V. In-Reply-To: X-Newsgroups: gnu.emacs.bug User-Agent: tin/2.2.0-20131224 ("Lochindaal") (UNIX) (FreeBSD/8.4-RELEASE (amd64)) X-Spam-Score: -2.2 (--) X-Debbugs-Envelope-To: 18826 Cc: 18826@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.2 (--) Hello, Dmitry. In article you wrote: > On 10/26/2014 02:34 AM, Alan Mackenzie wrote: >> Why do you think it should be harmless? > Because the syntax table change is temporary and its effect should be > limited to my code? It's no so limited. The before-change-functions and after-change-functions hooks will be run with that syntax table active. This is not good. >> . 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. > Yes, I see that. But how does this happen? Somewhere in a before- or after-change-functions, c-backward-sws is being called, to go backward over syntactic whitespace. Somehow it gets horribly confused, because the syntax table isn't correct. I don't think the exact details matter too much here. >> 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? > I'm using a different syntax table for sexp movement, where it's > necessary for both parens and angle brackets to have paren syntax class. > In the actual code I modify the text after it's inserted, and > `backward-sexp' is used two times to find necessary search bounds. OK. Can I suggest an alternative? In C++ (and Java) Modes, the template (generic) delimiters are marked with syntax-table text properties. Unfortunately, at the moment this is done as part of font-locking, so isn't done until you display. However, if you put "(sit-for 0)" into your code after inserting "< ... >", this will cause a redisplay, allowing subsequent code to use the text properties, and a backward-sexp will then work. In the medium future (several weeks away), I'm hoping to fix CC Mode so that the text properties are applied to < ... > on an after-change function rather than at redisplay. > https://github.com/company-mode/company-mode/blob/42012730da15ffaef7c61722475040babed15332/company-template.el#L155-L173 -- Alan Mackenzie (Nuremberg, Germany). From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 25 19:25:23 2014 Received: (at 18826) by debbugs.gnu.org; 25 Oct 2014 23:25:23 +0000 Received: from localhost ([127.0.0.1]:35557 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XiAi2-0005nx-Df for submit@debbugs.gnu.org; Sat, 25 Oct 2014 19:25:23 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.181]:40311) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XiAhz-0005nh-C7 for 18826@debbugs.gnu.org; Sat, 25 Oct 2014 19:25:21 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArYGAIDvNVNFpY87/2dsb2JhbABZgwaDSr0vgw6BFxd0giYBAQRWIxALDiYHCxQYDSSIDNIZF456B4Q4AQOpGYFqgXGBWyE X-IPAS-Result: ArYGAIDvNVNFpY87/2dsb2JhbABZgwaDSr0vgw6BFxd0giYBAQRWIxALDiYHCxQYDSSIDNIZF456B4Q4AQOpGYFqgXGBWyE X-IronPort-AV: E=Sophos;i="4.97,753,1389762000"; d="scan'208";a="95199742" Received: from 69-165-143-59.dsl.teksavvy.com (HELO fmsmemgm.homelinux.net) ([69.165.143.59]) by ironport2-out.teksavvy.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 25 Oct 2014 19:25:13 -0400 Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id 651C3AE312; Sat, 25 Oct 2014 19:25:13 -0400 (EDT) From: Stefan Monnier To: Dmitry Gutov Subject: Re: bug#18826: 24.3.94; c++-mode bad indentation after programmatic insert with locally changed syntax table Message-ID: References: <86egtwgra0.fsf@yandex.ru> Date: Sat, 25 Oct 2014 19:25:13 -0400 In-Reply-To: <86egtwgra0.fsf@yandex.ru> (Dmitry Gutov's message of "Sat, 25 Oct 2014 21:25:43 +0700") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 18826 Cc: 18826@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.3 (/) > (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)")) Why do that? Stefan From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 26 10:56:46 2014 Received: (at 18826) by debbugs.gnu.org; 26 Oct 2014 14:56:46 +0000 Received: from localhost ([127.0.0.1]:36067 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XiPFN-0004Q6-CI for submit@debbugs.gnu.org; Sun, 26 Oct 2014 10:56:45 -0400 Received: from mail-pa0-f41.google.com ([209.85.220.41]:51451) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XiPFI-0004Po-LQ for 18826@debbugs.gnu.org; Sun, 26 Oct 2014 10:56:42 -0400 Received: by mail-pa0-f41.google.com with SMTP id rd3so3904326pab.0 for <18826@debbugs.gnu.org>; Sun, 26 Oct 2014 07:56:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=OEHF1rliSGOZ/Li0lwEulPB8VO5m2yMojjlQD/975LY=; b=VZVIVcUoiJU6ye5suBEka7oP874V3IRsCwpnsh8ddrMJ4/uxAUrMwhod22YvXci/o1 h0fNTwJpurwgSkJhusYO0oPOkAZzJpkrvv0N885aENDUu3YwqJ1G4FrEtzxfdGQTIDu+ AUKoyf0KbIfz8hFa3BJmAR9ySQAt+QWL/nqVqiUwauqMpIZ3yBkTptZeeqEEn/anmo7/ mC7LnEublNr7gJQ8PTpVNM1Vqf9Pmgmc9YhsdrQiM7kyQXVGYXumrTOzN+CFM9htbRK3 GCrTOvPhHMYwBUu+KCZpanS9k1Ux/QMiTxgPSpN1Z0L7zyqazE0ilhKoVgI3oPA+O1bC 60ow== X-Received: by 10.69.13.196 with SMTP id fa4mr5697972pbd.65.1414335394145; Sun, 26 Oct 2014 07:56:34 -0700 (PDT) Received: from [192.168.2.52] ([113.160.248.69]) by mx.google.com with ESMTPSA id yw3sm8500350pbc.88.2014.10.26.07.56.32 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 Oct 2014 07:56:33 -0700 (PDT) Message-ID: <544D0B9E.3090606@yandex.ru> Date: Sun, 26 Oct 2014 21:56:30 +0700 From: Dmitry Gutov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: Stefan Monnier Subject: Re: bug#18826: 24.3.94; c++-mode bad indentation after programmatic insert with locally changed syntax table References: <86egtwgra0.fsf@yandex.ru> In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 18826 Cc: 18826@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) On 10/26/2014 06:25 AM, Stefan Monnier wrote: >> (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)")) > > Why do that? To include angle brackets in paren syntax class. Basically, we only need to consider these and the straight parens when converting a method definition into a method call with placeholders, so using an otherwise-empty syntax table seemed appropriate when I wrote the above code. It seems that I should only change the current syntax table only around the `backward-sexp' and `parse-partial-sexp' calls there, but not when doing any text modification. From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 26 10:56:50 2014 Received: (at 18826) by debbugs.gnu.org; 26 Oct 2014 14:56:50 +0000 Received: from localhost ([127.0.0.1]:36070 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XiPFR-0004QL-30 for submit@debbugs.gnu.org; Sun, 26 Oct 2014 10:56:49 -0400 Received: from mail-pa0-f54.google.com ([209.85.220.54]:39842) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XiPFO-0004Pw-Jp for 18826@debbugs.gnu.org; Sun, 26 Oct 2014 10:56:47 -0400 Received: by mail-pa0-f54.google.com with SMTP id rd3so3890268pab.13 for <18826@debbugs.gnu.org>; Sun, 26 Oct 2014 07:56:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=OEHF1rliSGOZ/Li0lwEulPB8VO5m2yMojjlQD/975LY=; b=ojv4Wsk/lldMnjjEwgpjNDddsr0FQC/UHbfEm6GT0WhxB2E8LzwmYhEd/IFKDejWCN wyymZ30yh2E8hrex5PUWSi++R4ZZmL8uyRs5YdK/DRw0p5hufBQpDM5bLK9+Yvk/UWLz RfnV6BVSdBvNtqgoifk3EMLTqpPFh5i+p1FrDS5sJtBvhWmGRQ6a5b9vD26DqL3qssu6 jGSSeMCUpkwfJ50djX7tsUd+sPZG5+oUuzUcyzlc3MgQMbQ3rKfIU9ZOHGFe9kbWtA/u rR+GBui/t3Ok9fuGGnIvkiipBayC8e8djUi43lRrFaelA90ziylsM4lR08FOwz92E+bf t+yA== X-Received: by 10.68.243.3 with SMTP id wu3mr3563549pbc.133.1414335400676; Sun, 26 Oct 2014 07:56:40 -0700 (PDT) Received: from [192.168.2.52] ([113.160.248.69]) by mx.google.com with ESMTPSA id bi5sm2489772pdb.35.2014.10.26.07.56.39 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 Oct 2014 07:56:40 -0700 (PDT) Message-ID: <544D0BA5.7010400@yandex.ru> Date: Sun, 26 Oct 2014 21:56:37 +0700 From: Dmitry Gutov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: Stefan Monnier Subject: Re: bug#18826: 24.3.94; c++-mode bad indentation after programmatic insert with locally changed syntax table References: <86egtwgra0.fsf@yandex.ru> In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 18826 Cc: 18826@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) On 10/26/2014 06:25 AM, Stefan Monnier wrote: >> (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)")) > > Why do that? To include angle brackets in paren syntax class. Basically, we only need to consider these and the straight parens when converting a method definition into a method call with placeholders, so using an otherwise-empty syntax table seemed appropriate when I wrote the above code. It seems that I should only change the current syntax table only around the `backward-sexp' and `parse-partial-sexp' calls there, but not when doing any text modification. From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 26 11:09:37 2014 Received: (at 18826-done) by debbugs.gnu.org; 26 Oct 2014 15:09:37 +0000 Received: from localhost ([127.0.0.1]:36086 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XiPRo-0004jv-QL for submit@debbugs.gnu.org; Sun, 26 Oct 2014 11:09:37 -0400 Received: from mail-pd0-f174.google.com ([209.85.192.174]:60364) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XiPRn-0004jj-2b for 18826-done@debbugs.gnu.org; Sun, 26 Oct 2014 11:09:35 -0400 Received: by mail-pd0-f174.google.com with SMTP id p10so4109204pdj.19 for <18826-done@debbugs.gnu.org>; Sun, 26 Oct 2014 08:09:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=iQl/t1jiND/PMsClGQj+HNXv7LfdrNvOJsj5ti2rPWE=; b=vSASXYSTkuqE//mQh2ny7T3aD6nRBfg6/FE0JznmLAHAiJDXSQHiSrzMSqbxuC0Zdr /bEDRTqJC2hsm/7h/mHViDVMsRZYKh8cN5qLPU6dWAOotNmxPpzDbdxaRI9a2CBUbZTe dv31crgbkF9xzBu/iqaGyAaQ9XVq4hFDa83M1T7lNJE+Dr7zFvEqnyjNn8DSyT61w/d4 Igq84U/EQwv0vfOILk9cQgm6PcfUAoxZkcObdZVjCxZWZKE4New17Pp3IBFFVmTx7F4F QIb/A1gLU1bbx4vKbCMtZ5XMBrbDfxs5Tyu6PohhQdO6Xdi1IeR6cCM+DdhYGqIPRztE /grg== X-Received: by 10.70.15.228 with SMTP id a4mr18119100pdd.77.1414336169168; Sun, 26 Oct 2014 08:09:29 -0700 (PDT) Received: from [192.168.2.52] ([113.160.248.69]) by mx.google.com with ESMTPSA id c10sm8556783pdj.77.2014.10.26.08.09.27 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 Oct 2014 08:09:28 -0700 (PDT) Message-ID: <544D0EA5.50703@yandex.ru> Date: Sun, 26 Oct 2014 22:09:25 +0700 From: Dmitry Gutov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: Alan Mackenzie Subject: Re: bug#18826: 24.3.94; c++-mode bad indentation after programmatic insert with locally changed syntax table References: <20141025232449.90894.qmail@mail.muc.de> In-Reply-To: <20141025232449.90894.qmail@mail.muc.de> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 18826-done Cc: 18826-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) On 10/26/2014 06:24 AM, Alan Mackenzie wrote: >> Because the syntax table change is temporary and its effect should be >> limited to my code? > > It's no so limited. The before-change-functions and after-change-functions > hooks will be run with that syntax table active. This is not good. I see, thanks. Somehow, I figured that those hooks would run before or after the current command, whereas they're triggered right near any code that makes changes to the buffer. Question answered, closing. On the other hand, you're doing some pretty unusual things with this. If `c-in-sws' and `c-is-sws' were added in syntax-propertize-function (which is called on-demand), this conflict wouldn't have manifested. > OK. Can I suggest an alternative? In C++ (and Java) Modes, the template > (generic) delimiters are marked with syntax-table text properties. > Unfortunately, at the moment this is done as part of font-locking, so > isn't done until you display. However, if you put "(sit-for 0)" into > your code after inserting "< ... >", this will cause a redisplay, > allowing subsequent code to use the text properties, and a backward-sexp > will then work. Sounds like it should be performed during `syntax-propertize' instead. Even if you don't like this idea now, I suspect it'll happen eventually anyway, if only for consistency with other major modes. In that sense, the `sit-for' suggestion is not future-proof. So I'll try only changing the syntax table around specific functions that don't modify the buffer text, but just move point, since that was the actual goal. > In the medium future (several weeks away), I'm hoping to fix CC Mode so > that the text properties are applied to < ... > on an after-change > function rather than at redisplay. Hmm. My current workaround is to use a temporary syntax table that inherits from c++-mode-syntax-table (but has angle brackets in the 'paren' class). Sounds like it might also create a conflict, if maybe a more subtle one. From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 26 13:03:50 2014 Received: (at 18826) by debbugs.gnu.org; 26 Oct 2014 17:03:50 +0000 Received: from localhost ([127.0.0.1]:36151 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XiREL-0007gm-84 for submit@debbugs.gnu.org; Sun, 26 Oct 2014 13:03:49 -0400 Received: from pruche.dit.umontreal.ca ([132.204.246.22]:37634) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XiREJ-0007ge-07 for 18826@debbugs.gnu.org; Sun, 26 Oct 2014 13:03:47 -0400 Received: from fmsmemgm.homelinux.net (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id s9QH3jtc016648; Sun, 26 Oct 2014 13:03:45 -0400 Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id B9380AE312; Sun, 26 Oct 2014 13:03:44 -0400 (EDT) From: Stefan Monnier To: Dmitry Gutov Subject: Re: bug#18826: 24.3.94; c++-mode bad indentation after programmatic insert with locally changed syntax table Message-ID: References: <86egtwgra0.fsf@yandex.ru> <544D0BA5.7010400@yandex.ru> Date: Sun, 26 Oct 2014 13:03:44 -0400 In-Reply-To: <544D0BA5.7010400@yandex.ru> (Dmitry Gutov's message of "Sun, 26 Oct 2014 21:56:37 +0700") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV5106=0 X-NAI-Spam-Version: 2.3.0.9393 : core <5106> : inlines <1435> : streams <1326959> : uri <1829070> X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 18826 Cc: 18826@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.9 (-) >>> (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)")) >> >> Why do that? > To include angle brackets in paren syntax class. But `insert' doesn't use that temporary syntax-table (aside from indirect use in before/after-change-functions, obviously). So why use `with-syntax-table' around a call to `insert'? > It seems that I should only change the current syntax table only > around the `backward-sexp' and `parse-partial-sexp' calls there, but > not when doing any text modification. Yes. And even then, this should not be necessary since the major mode already does it (or should do it) for you. Stefan From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 26 13:07:30 2014 Received: (at 18826) by debbugs.gnu.org; 26 Oct 2014 17:07:30 +0000 Received: from localhost ([127.0.0.1]:36155 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XiRHt-0007mW-AF for submit@debbugs.gnu.org; Sun, 26 Oct 2014 13:07:29 -0400 Received: from chene.dit.umontreal.ca ([132.204.246.20]:42311) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XiRHr-0007mL-93 for 18826@debbugs.gnu.org; Sun, 26 Oct 2014 13:07:27 -0400 Received: from fmsmemgm.homelinux.net (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id s9QH7PcM019795; Sun, 26 Oct 2014 13:07:25 -0400 Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id A215CAE312; Sun, 26 Oct 2014 13:07:24 -0400 (EDT) From: Stefan Monnier To: 18826@debbugs.gnu.org Subject: Re: bug#18826: 24.3.94; c++-mode bad indentation after programmatic insert with locally changed syntax table Message-ID: References: <20141025232449.90894.qmail@mail.muc.de> <544D0EA5.50703@yandex.ru> Date: Sun, 26 Oct 2014 13:07:24 -0400 In-Reply-To: <544D0EA5.50703@yandex.ru> (Dmitry Gutov's message of "Sun, 26 Oct 2014 22:09:25 +0700") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV5106=0 X-NAI-Spam-Version: 2.3.0.9393 : core <5106> : inlines <1435> : streams <1326960> : uri <1829071> X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 18826 Cc: dgutov@yandex.ru X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.9 (-) > On the other hand, you're doing some pretty unusual things with this. > If `c-in-sws' and `c-is-sws' were added in syntax-propertize-function > (which is called on-demand), this conflict wouldn't have manifested. ;-) > In that sense, the `sit-for' suggestion is not future-proof. So I'll try > only changing the syntax table around specific functions that don't modify > the buffer text, but just move point, since that was the actual goal. Rather than using a hack like `sit-for', and while waiting for cc-mode to use syntax-propertize for that, you can use `font-lock-ensure' to make sure that the corresponding part of the code has been font-locked. Stefan From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 26 13:38:54 2014 Received: (at 18826) by debbugs.gnu.org; 26 Oct 2014 17:38:54 +0000 Received: from localhost ([127.0.0.1]:36176 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XiRmH-00007G-10 for submit@debbugs.gnu.org; Sun, 26 Oct 2014 13:38:53 -0400 Received: from colin.muc.de ([193.149.48.1]:48834 helo=mail.muc.de) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XiRmE-000075-2t for 18826@debbugs.gnu.org; Sun, 26 Oct 2014 13:38:50 -0400 Received: (qmail 82989 invoked by uid 3782); 26 Oct 2014 17:38:49 -0000 Date: 26 Oct 2014 17:38:49 -0000 Message-ID: <20141026173849.82988.qmail@mail.muc.de> From: Alan Mackenzie To: Dmitry Gutov Subject: Re: bug#18826: 24.3.94; c++-mode bad indentation after programmatic insert with locally changed syntax table Organization: muc.de e.V. In-Reply-To: X-Newsgroups: gnu.emacs.bug User-Agent: tin/2.2.0-20131224 ("Lochindaal") (UNIX) (FreeBSD/8.4-RELEASE (amd64)) X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: 18826 Cc: 18826@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.3 (-) Hi, Dmitry. In article you wrote: > On 10/26/2014 06:24 AM, Alan Mackenzie wrote: >>> Because the syntax table change is temporary and its effect should be >>> limited to my code? >> It's no so limited. The before-change-functions and after-change-functions >> hooks will be run with that syntax table active. This is not good. > I see, thanks. Somehow, I figured that those hooks would run before or > after the current command, whereas they're triggered right near any code > that makes changes to the buffer. Question answered, closing. > On the other hand, you're doing some pretty unusual things with this. If > `c-in-sws' and `c-is-sws' were added in syntax-propertize-function > (which is called on-demand), this conflict wouldn't have manifested. They're not syntax-table text properties, so the setting of them doesn't belong in syntax-propertize. It wouldn't make sense to do these in syntax-propertize for a variety of other reasons, such as efficiency. >> OK. Can I suggest an alternative? In C++ (and Java) Modes, the template >> (generic) delimiters are marked with syntax-table text properties. >> Unfortunately, at the moment this is done as part of font-locking, so >> isn't done until you display. However, if you put "(sit-for 0)" into >> your code after inserting "< ... >", this will cause a redisplay, >> allowing subsequent code to use the text properties, and a backward-sexp >> will then work. > Sounds like it should be performed during `syntax-propertize' instead. > Even if you don't like this idea now, I suspect it'll happen eventually > anyway, if only for consistency with other major modes. Maybe it will, maybe it won't. `syntax-propertize' has the disadvantage of inefficiency; at any buffer change, all syntax-table text properties after the position of the change are effectively wiped out, even where (as is usual) this isn't necessary. Also, restoring them means doing so over a potentially large region of the buffer, rather than just locally around point. But, anyway .... > In that sense, the `sit-for' suggestion is not future-proof. So I'll try > only changing the syntax table around specific functions that don't > modify the buffer text, but just move point, since that was the actual goal. Might it be possible that you could get mixed up with less-than and greater-than (or even shift-right) operators? If so, be careful! >> In the medium future (several weeks away), I'm hoping to fix CC Mode so >> that the text properties are applied to < ... > on an after-change >> function rather than at redisplay. ...., a change to use syntax-propertize needs the above change to happen first. > Hmm. My current workaround is to use a temporary syntax table that > inherits from c++-mode-syntax-table (but has angle brackets in the > 'paren' class). Sounds like it might also create a conflict, if maybe a > more subtle one. Any reason you don't use the current syntax table as the base to add the descriptors for < and > to rather than creating a new, blank one? You could use `copy-syntax-table'. -- Alan Mackenzie (Nuremberg, Germany). From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 26 21:07:04 2014 Received: (at 18826) by debbugs.gnu.org; 27 Oct 2014 01:07:04 +0000 Received: from localhost ([127.0.0.1]:36278 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XiYm0-0002mk-5C for submit@debbugs.gnu.org; Sun, 26 Oct 2014 21:07:04 -0400 Received: from mail-pd0-f180.google.com ([209.85.192.180]:61713) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XiYlw-0002mC-OU for 18826@debbugs.gnu.org; Sun, 26 Oct 2014 21:07:01 -0400 Received: by mail-pd0-f180.google.com with SMTP id ft15so2622997pdb.25 for <18826@debbugs.gnu.org>; Sun, 26 Oct 2014 18:06:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=dkmdxbcX5yfK0QpsC1n2V4Bty50SMRqlM0NXuE3Qc14=; b=TKHL0tRZDpr0GltQC28ZeTwoW8zUNognPeKyhyh9T4sBM8gmUYiJaSZFq9I1Cj030d WWU43q4VhNlsyCBkwtFioog5PtnFs9o1H0lA/RQpg2W07j3zK8R26eYppZDkdpFgHzwZ f4PI7vUfMH6VptdZKiRiuHzGJ1Ml/Rnm5qsZBbBd+3wd7mrW59sDxI0gI72TcwH6IWV6 VvgEK83/60zOhhAwJj1WdNLF9Ubep74qfUyYU+znAnGeDDwtRa4YeTiMMWIbeQ4x+NTU Al81BAqgr7N0UcZrnQHsc5hVhLg/sCMM9t28wbbF0hcz/3T4XmJof3Kzqie0SHPUOqV3 hfuQ== X-Received: by 10.68.135.97 with SMTP id pr1mr20303144pbb.121.1414372013963; Sun, 26 Oct 2014 18:06:53 -0700 (PDT) Received: from [192.168.2.52] ([113.160.248.69]) by mx.google.com with ESMTPSA id dj1sm9296577pdb.10.2014.10.26.18.06.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 Oct 2014 18:06:53 -0700 (PDT) Message-ID: <544D9AA6.5@yandex.ru> Date: Mon, 27 Oct 2014 08:06:46 +0700 From: Dmitry Gutov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: Alan Mackenzie Subject: Re: bug#18826: 24.3.94; c++-mode bad indentation after programmatic insert with locally changed syntax table References: <20141026173849.82988.qmail@mail.muc.de> In-Reply-To: <20141026173849.82988.qmail@mail.muc.de> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 18826 Cc: 18826@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) On 10/27/2014 12:38 AM, Alan Mackenzie wrote: > They're not syntax-table text properties, so the setting of them doesn't > belong in syntax-propertize. Well, they are used to set syntax information, so syntax-propertize is a much better place for them, conceptually, than font-lock. > Maybe it will, maybe it won't. `syntax-propertize' has the disadvantage > of inefficiency; at any buffer change, all syntax-table text properties > after the position of the change are effectively wiped out, even where > (as is usual) this isn't necessary. If it's a actually a problem, maybe you need to be able to use a custom invalidation strategy. Aside from the strategy itself, this shouldn't be too hard to implement. >> In that sense, the `sit-for' suggestion is not future-proof. So I'll try >> only changing the syntax table around specific functions that don't >> modify the buffer text, but just move point, since that was the actual goal. > > Might it be possible that you could get mixed up with less-than and > greater-than (or even shift-right) operators? If so, be careful! Thanks, but there are no "less-than" in a function signature. >>> In the medium future (several weeks away), I'm hoping to fix CC Mode so >>> that the text properties are applied to < ... > on an after-change >>> function rather than at redisplay. > > ...., a change to use syntax-propertize needs the above change to happen > first. Not sure why, but ok. >> Hmm. My current workaround is to use a temporary syntax table that >> inherits from c++-mode-syntax-table (but has angle brackets in the >> 'paren' class). Sounds like it might also create a conflict, if maybe a >> more subtle one. > > Any reason you don't use the current syntax table as the base to add the > descriptors for < and > to rather than creating a new, blank one? You > could use `copy-syntax-table'. Is that much different from what I described above? I do (with-syntax-table (make-syntax-table (syntax-table) ...) From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 27 04:54:13 2014 Received: (at 18826) by debbugs.gnu.org; 27 Oct 2014 08:54:13 +0000 Received: from localhost ([127.0.0.1]:36358 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xig45-0006ht-Ax for submit@debbugs.gnu.org; Mon, 27 Oct 2014 04:54:13 -0400 Received: from colin.muc.de ([193.149.48.1]:58986 helo=mail.muc.de) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xig42-0006hk-8j for 18826@debbugs.gnu.org; Mon, 27 Oct 2014 04:54:11 -0400 Received: (qmail 35834 invoked by uid 3782); 27 Oct 2014 08:54:08 -0000 Received: from acm.muc.de (pD951B8EC.dip0.t-ipconnect.de [217.81.184.236]) by colin.muc.de (tmda-ofmipd) with ESMTP; Mon, 27 Oct 2014 09:54:07 +0100 Received: (qmail 2832 invoked by uid 1000); 27 Oct 2014 08:53:28 -0000 Date: Mon, 27 Oct 2014 08:53:28 +0000 To: Dmitry Gutov Subject: Re: bug#18826: 24.3.94; c++-mode bad indentation after programmatic insert with locally changed syntax table Message-ID: <20141027085328.GA2771@acm.acm> References: <20141026173849.82988.qmail@mail.muc.de> <544D9AA6.5@yandex.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <544D9AA6.5@yandex.ru> User-Agent: Mutt/1.5.21 (2010-09-15) X-Delivery-Agent: TMDA/1.1.12 (Macallan) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: 18826 Cc: 18826@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.3 (-) Hello, Dmitry. On Mon, Oct 27, 2014 at 08:06:46AM +0700, Dmitry Gutov wrote: > On 10/27/2014 12:38 AM, Alan Mackenzie wrote: > > They're not syntax-table text properties, so the setting of them doesn't > > belong in syntax-propertize. > Well, they are used to set syntax information, so syntax-propertize is a > much better place for them, conceptually, than font-lock. They (that is, the c-is-sws and c-in-sws properties) mark syntactic whitespace. They're set during calls to c-forward-syntactic-ws and c-backward-syntactic-ws, which are used all over the place, just as much in the indentation engine, and the commands, as in font lock. They're intended to mark CPP structures and, especially, massive comments, such as are frequently found at the beginning of source files. They're intended to speed up the skipping of WS. > > Maybe it will, maybe it won't. `syntax-propertize' has the disadvantage > > of inefficiency; at any buffer change, all syntax-table text properties > > after the position of the change are effectively wiped out, even where > > (as is usual) this isn't necessary. > If it's a actually a problem, maybe you need to be able to use a custom > invalidation strategy. Aside from the strategy itself, this shouldn't be > too hard to implement. It's already implemented and running. :-) The syntax-table properties in the vicinity of a buffer change are removed and re-applied with tender loving care. [ ... ] > >> Hmm. My current workaround is to use a temporary syntax table that > >> inherits from c++-mode-syntax-table (but has angle brackets in the > >> 'paren' class). Sounds like it might also create a conflict, if maybe a > >> more subtle one. > > Any reason you don't use the current syntax table as the base to add the > > descriptors for < and > to rather than creating a new, blank one? You > > could use `copy-syntax-table'. > Is that much different from what I described above? I do > (with-syntax-table (make-syntax-table (syntax-table) > ...) No it's not. Apologies. I hadn't read your email properly. -- Alan Mackenzie (Nuremberg, Germany). From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 27 06:22:02 2014 Received: (at 18826) by debbugs.gnu.org; 27 Oct 2014 10:22:02 +0000 Received: from localhost ([127.0.0.1]:36395 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XihR3-0000YS-BG for submit@debbugs.gnu.org; Mon, 27 Oct 2014 06:22:01 -0400 Received: from mail-pd0-f180.google.com ([209.85.192.180]:61901) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XihR0-0000YB-Bi for 18826@debbugs.gnu.org; Mon, 27 Oct 2014 06:21:58 -0400 Received: by mail-pd0-f180.google.com with SMTP id ft15so3448174pdb.39 for <18826@debbugs.gnu.org>; Mon, 27 Oct 2014 03:21:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=PVWJQni8P5H2SoQRVYPmbsebmCpUbqigugbcTOKX4xE=; b=xDv94r560eNszpiF63uheE05v9iUNDT4BO+szuwMIlL8YFWTgCfecOyJmUQxPMzVwW OXltvDq0Xh9/ZevwJZNEoLjURbU3ZtZKDcSy7P3fRO5wL7NieU3qPXmUl88cThzXHjFj zzkuxRP2UWdry2+S/PZpJ0faUR1t6ZidFBhzNmlviWbzygQUH7QdsVDTZfPzFOh3r/Tp 0vkOyfG1hgZu/hyISFB1gsfVpGGlxKrdvOg7eK2BVXE51LAEvKiLQH9qXyk28FDw0loT PgJZGMrNLZJ0Xp5jjARZ2MvcTg85AG1efyGGu4Dz++bhdVxE9npo1GlnkyNnZA+Fe70L CEIg== X-Received: by 10.67.22.1 with SMTP id ho1mr23774381pad.4.1414405312022; Mon, 27 Oct 2014 03:21:52 -0700 (PDT) Received: from [192.168.2.52] ([113.160.248.69]) by mx.google.com with ESMTPSA id cq3sm9299730pbc.28.2014.10.27.03.21.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Oct 2014 03:21:51 -0700 (PDT) Message-ID: <544E1CBC.4000206@yandex.ru> Date: Mon, 27 Oct 2014 17:21:48 +0700 From: Dmitry Gutov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: Alan Mackenzie Subject: Re: bug#18826: 24.3.94; c++-mode bad indentation after programmatic insert with locally changed syntax table References: <20141026173849.82988.qmail@mail.muc.de> <544D9AA6.5@yandex.ru> <20141027085328.GA2771@acm.acm> In-Reply-To: <20141027085328.GA2771@acm.acm> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 18826 Cc: 18826@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) On 10/27/2014 03:53 PM, Alan Mackenzie wrote: > They (that is, the c-is-sws and c-in-sws properties) mark syntactic > whitespace. They're set during calls to c-forward-syntactic-ws and > c-backward-syntactic-ws, which are used all over the place, just as much > in the indentation engine, and the commands, as in font lock. They're > intended to mark CPP structures and, especially, massive comments, such > as are frequently found at the beginning of source files. They're > intended to speed up the skipping of WS. It sounds like it can be implemented in syntax-propertize-function without much trouble. Adding such props in movement commands sounds counter-intuitive, although I can see how this can be useful from the performance perspective. > It's already implemented and running. :-) The syntax-table properties > in the vicinity of a buffer change are removed and re-applied with tender > loving care. Cool. It'll require a patch to syntax.el in the trunk, right? > No it's not. Apologies. I hadn't read your email properly. That's good. I'll take that to mean that < and > having belonging to paren class won't stop them from being propertized in the before/after-change hooks like you described. Then I'll keep the code as-is, thanks! From unknown Mon Aug 18 17:58:36 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Mon, 24 Nov 2014 12:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator