From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ergus via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#61541: 30.0.50; Wrong indentarion in csharp-mode Date: Sun, 19 Feb 2023 02:58:42 +0100 Message-ID: <20230219015842.rp2m7n5df4fcp2ug@Ergus> References: <87k00i7hko.fsf.ref@aol.com> <87k00i7hko.fsf@aol.com> <87a61cozw8.fsf@thornhill.no> <305e7060-58cc-344a-ae1a-98c82510aa88@secure.kjonigsen.net> <20230217214346.dr6d54yxk2rr6ucj@Ergus> <87edqn6exf.fsf@thornhill.no> Reply-To: Ergus Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28456"; mail-complaints-to="usenet@ciao.gmane.io" Cc: jostein@kjonigsen.net, 61541@debbugs.gnu.org To: Theodor Thornhill Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Feb 19 02:59:19 2023 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 1pTYz0-0007Go-AN for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 19 Feb 2023 02:59:18 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pTYyn-00061M-DW; Sat, 18 Feb 2023 20:59:05 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pTYyk-00060s-7p for bug-gnu-emacs@gnu.org; Sat, 18 Feb 2023 20:59:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pTYyj-00085u-Oi for bug-gnu-emacs@gnu.org; Sat, 18 Feb 2023 20:59:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pTYyj-0001oE-HR for bug-gnu-emacs@gnu.org; Sat, 18 Feb 2023 20:59:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Ergus Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 19 Feb 2023 01:59:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61541 X-GNU-PR-Package: emacs Original-Received: via spool by 61541-submit@debbugs.gnu.org id=B61541.16767719386943 (code B ref 61541); Sun, 19 Feb 2023 01:59:01 +0000 Original-Received: (at 61541) by debbugs.gnu.org; 19 Feb 2023 01:58:58 +0000 Original-Received: from localhost ([127.0.0.1]:45271 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pTYyf-0001nv-UJ for submit@debbugs.gnu.org; Sat, 18 Feb 2023 20:58:58 -0500 Original-Received: from sonic304-10.consmr.mail.bf2.yahoo.com ([74.6.128.33]:43970) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pTYyc-0001nd-Po for 61541@debbugs.gnu.org; Sat, 18 Feb 2023 20:58:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1676771927; bh=Plf6PYXuKVlZSnd8wuly03drvM6KRMTc41UDsOeao7c=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From:Subject:Reply-To; b=XnZqccMy2D439pOhpCEKWgdWKuPJ/UUq5KHiFCLn7XyOlKxo5+gzMb3HRAu8rjkLNVvinU5jcjSy1HbbhopUrNforU3kPYH4MObn41uWpGHB2e7QIU5w7SNGRKCYWE1HNipFz3bdNousmA1oMztKIF/Qdot65q0FBuunkkpyf1kjgxTPP2S5cSfBZHrHqn3nO87z7uipIy4PAjteYg310z4G9MD9VohGgj8Hv92+iEBlBJzLYEl1PeeO8nYrGVGiGIkVs57p4zgincUd23wEDsaQknnG9945VweW2zhD7rBlWPYmcq06wt8+V/p6cvbivyeH+jkEaBtxvJpQVAJm0Q== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1676771927; bh=dM4MmDW63JrKAIiLS+SHro0OiltOWzfJlT4BxDBUOul=; h=X-Sonic-MF:Date:From:To:Subject:From:Subject; b=EaSZu2QWu4K0gc4SXb7tS//uwIyVIc8XS5RdLP46WMIH+Fic2/cNVZuQNwEUGUtldd0FTQBYJsxVxUW+0b5E1Qq9i2j4atmft841DDn/k3BPXNR7tocmbse5+FuZCt1OXndcViODVkqkHlNHpFn0coc8w/BUTjFgVyfpBb9qO2Ln8SkEaztd5jo0Ng1jsWbOKUGvzA3KyJdFAsfv88JKND7fBO4blVw2y7iXFeZV3YErkpE8kP5x6N4yJLtd29GjbR1NqeN7HrSk2IRyT1X5H5wPDK8QRq+jc8+iV2q9gZYUGecQ8JnFwrn9jJ1zLISK/B5AwcvnDXl+68NQwImwcw== X-YMail-OSG: NXGyn8UVM1nB.N6WN9uGiqGci.CyUgJ2sIxtwKqvfNBpLySXTxdpMVVF7ziHC9K gGxZwkOciU4WPgOAPg51.I7FUTVhYLPl4OX7k5j1CxGhZ2oq986oVUtqI3g_YdCxNPcG7e_BWeCD w1MszDdkYumuWKiNCA0tlIQ..mdEpadI9kFn1y1Ugdyt67YyalqSn49jhtEHSI0HCouAtMDfO8D9 ZtgKKycsH7Jwjvw.D8BDBAvKbKnrNKpRD3kjIPmizSflOtKzdeqN3Y0gNx7zsygY33ZO_MlFT8i8 sgXR0Mk07jtpKk6BLs_ptZbTgV.ThLCIf4N5UAP7kTXpTClI7wHMOfp_Z5FZWfDAezNAZgLqli0G pLMI1uzLOHeFo69pCW1ZpvZx.nr805v.hAVkE6yf7pgGxH9Ab3ZfVEvLqODS_8AUQa5FgA3GM1mU dIBwjc0XByl36Rl4cjEFcSZwCnnYfCSMEU8RflEb6moln0bCO_2U3th71tOr3PpTqzjJBXMHQXEZ NE2u3iQqBAQt0r_rzYLpgbh4ShBCB8fYdHwLKeMQIcOKXzakIv4DJpmsGUnMxdP7kPsVHA2ahekW YGuvhgxx1BMG6o0P9J4N_IwUTNrY3bZDcFXr8kf6Kj0CGTZqeeZg9EYKF2pJ7mj.NXBlESAsmIuU 9b49G4jxIXl7zPdNbq7l0vUod9X5AHYJl.Mad.bJzDuAAoL5bSgwr7FxMgObjzTk0mqstRC97B5L .IXT9AAiEj8qm3GxV1d5tOB1gxmO4xqzA3bO2j0SylXi5pVrkgrS0Oh6TIlbGgOhEXXUQZkudKfJ LujYp3EpMIVkNy_lNIVEL.3woiJRQ8Soo0X6Vg4W3N X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic304.consmr.mail.bf2.yahoo.com with HTTP; Sun, 19 Feb 2023 01:58:47 +0000 Original-Received: by hermes--production-ir2-65c64dfd66-fhq4t (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 2b3b87d367da09b657634a27a021ec1f; Sun, 19 Feb 2023 01:58:45 +0000 (UTC) Content-Disposition: inline In-Reply-To: <87edqn6exf.fsf@thornhill.no> X-Mailer: WebService/1.1.21183 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.aol 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:256013 Archived-At: Hi Theo: I think this works... I will try it a bit more tomorrow. Thanks, Ergus On Sat, Feb 18, 2023 at 12:38:20AM +0100, Theodor Thornhill wrote: >Ergus writes: > >> On Fri, Feb 17, 2023 at 10:06:50PM +0100, Jostein Kj�nigsen wrote: >>>2/17/23 20:28, Theodor Thornhill wrote: >>>>Ergus writes: >>>> >>>>>Hi: >>>>> >>>>>I just found that this indentations are wrong in csharp mode: >>>>> >>>>>// wrong >>>>>new myNamespace.myClass >>>>>{ >>>>> Name1 = x.Value, // defun-block-intro >>>>> var2 = 2 // statement-cont >>>>> } // statement-cont >>>>> >>>>> >>>>>The problem seems to be related with the dot (.) in the new, because >>>>>this variant indents correctly: >>>>> >>>>>// right >>>>>new myClass >>>>>{ >>>>> Name1 = x.Value, // brace-list-intro >>>>> var2 = 2 // brace-list-entry >>>>>} // brace-list-close >>>>> >>>>> >>>>>csharp-ts-mode is doing it right BTW. >>>>> >>>>Hi! >>>> >>>>Yeah, this is one of the harder issues iirc, and one of the ones that >>>>made us move to tree-sitter in csharp-mode in the first place. >>>> >>>>What do you think Jostein? >>>> >>>>Patches welcome! >>>> >>>>Theo >>>> >>>First of all: Thanks for a detailed bug-report. >>> >>>Then for the bad news: I may be missing something here. I'm on the >>>latest revision of the emacs-29 branch, and I really can't reproduce >>>at all. >>> >>>I've tried typing out the concrete code-samples above, and I've tried >>>copy-pasting them. >>> >>>No matter what I do, I cannot reproduce the behaviour outlined above. >>> >>>Ergus: Could you come up with a even more complete example? >>> >>>I mean... If I can't reproduce, I definitely won't be able to come up >>>with a patch. >>> >>>-- >>>Jostein >>> >> >> Hi Jostein: >> >> I just do: >> >> emacs -Q /tmp/main.cs >> >> Then pasted (or write) the code snippet shown in the example, and >> re-indent the buffer: >> >> I get this: >> >> new myNamespace.myClass >> { >> Name1 = 1, >> Name2 =2 >> } >> >> Exactly like in the example C-c C-o shows the same than in the >> example. Even the fontification is wrong. >> >> If I remove the dot like this myNamespacemyClass the fontification and >> indentation is fixed immediately. >> >> I am using the master branch (emacs-version = 30.0.50) tomorrow I can >> try to reproduce the issue on emacs-29 branch, but I have to build it. >> >> Best, >> Ergus > > >Try this, Ergus and Jostein. What do you think? > >diff --git a/lisp/progmodes/csharp-mode.el b/lisp/progmodes/csharp-mode.el >index b6b842d7fd..293a910081 100644 >--- a/lisp/progmodes/csharp-mode.el >+++ b/lisp/progmodes/csharp-mode.el >@@ -474,28 +474,37 @@ csharp-guess-basic-syntax > (and (eq (char-before) ?\]) > (not (eq (char-after) ?\;)))))) > `((annotation-top-cont ,(c-point 'iopl)))) >- > ((and > ;; Heuristics to find object initializers > (save-excursion > ;; Next non-whitespace character should be '{' > (goto-char (c-point 'boi)) >- (eq (char-after) ?{)) >- (save-excursion >- ;; 'new' should be part of the line >- (goto-char (c-point 'iopl)) >- (looking-at ".*new.*")) >+ (unless (eq (char-after) ?{) >+ (backward-up-list 1 t t)) >+ (save-excursion >+ ;; 'new' should be part of the line >+ (goto-char (c-point 'iopl)) >+ (looking-at ".*new.*"))) > ;; Line should not already be terminated > (save-excursion > (goto-char (c-point 'eopl)) > (or (not (eq (char-before) ?\;)) > (not (eq (char-before) ?\{))))) >- (if (save-excursion >- ;; if we have a hanging brace on line before >- (goto-char (c-point 'eopl)) >- (eq (char-before) ?\{)) >- `((brace-list-intro ,(c-point 'iopl))) >- `((block-open) (statement ,(c-point 'iopl))))) >+ (cond >+ ((save-excursion >+ ;; if we have a hanging brace on line before >+ (goto-char (c-point 'eopl)) >+ (eq (char-before) ?\{)) >+ `((brace-list-intro ,(c-point 'iopl)))) >+ ((save-excursion >+ ;; if we have a hanging brace on line before >+ (goto-char (c-point 'boi)) >+ (and (eq (char-after) ?\}) >+ `((brace-list-close ,(save-excursion >+ (backward-up-list 1 t t) >+ (point))))))) >+ (t >+ `((block-open) (statement ,(c-point 'iopl)))))) > (t > (apply orig-fun args)))) >