From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Konstantin Kharlamov Newsgroups: gmane.emacs.bugs Subject: bug#46400: Sporadically breaking newline-indentation in c-mode Date: Tue, 09 Feb 2021 15:45:42 +0300 Message-ID: <55f73bef46901e7c23de9161e3ba938cd2803d4b.camel@yandex.ru> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3236"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Evolution 3.38.3 To: 46400@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Feb 09 13:47:29 2021 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 1l9SQR-0000fD-Aa for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 09 Feb 2021 13:47:27 +0100 Original-Received: from localhost ([::1]:54006 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9SQQ-0007y1-Br for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 09 Feb 2021 07:47:26 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54434) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9SQ2-0007xm-BZ for bug-gnu-emacs@gnu.org; Tue, 09 Feb 2021 07:47:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:41305) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l9SQ2-0002Ly-3K for bug-gnu-emacs@gnu.org; Tue, 09 Feb 2021 07:47:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l9SQ2-0005mh-23 for bug-gnu-emacs@gnu.org; Tue, 09 Feb 2021 07:47:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Konstantin Kharlamov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 09 Feb 2021 12:47:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 46400 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.161287477322175 (code B ref -1); Tue, 09 Feb 2021 12:47:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 9 Feb 2021 12:46:13 +0000 Original-Received: from localhost ([127.0.0.1]:52850 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l9SPE-0005lb-I1 for submit@debbugs.gnu.org; Tue, 09 Feb 2021 07:46:13 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:55612) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l9SPA-0005lQ-4j for submit@debbugs.gnu.org; Tue, 09 Feb 2021 07:46:10 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54314) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9SP9-0007u7-C8 for bug-gnu-emacs@gnu.org; Tue, 09 Feb 2021 07:46:07 -0500 Original-Received: from forward104o.mail.yandex.net ([2a02:6b8:0:1a2d::607]:52060) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9SP1-0001uD-2F for bug-gnu-emacs@gnu.org; Tue, 09 Feb 2021 07:46:05 -0500 Original-Received: from sas1-d4a7cb224acf.qloud-c.yandex.net (sas1-d4a7cb224acf.qloud-c.yandex.net [IPv6:2a02:6b8:c14:494:0:640:d4a7:cb22]) by forward104o.mail.yandex.net (Yandex) with ESMTP id 6F79B9403A1 for ; Tue, 9 Feb 2021 15:45:43 +0300 (MSK) Original-Received: from sas1-37da021029ee.qloud-c.yandex.net (sas1-37da021029ee.qloud-c.yandex.net [2a02:6b8:c08:1612:0:640:37da:210]) by sas1-d4a7cb224acf.qloud-c.yandex.net (mxback/Yandex) with ESMTP id 4eh8ut516V-jhIOLx4s; Tue, 09 Feb 2021 15:45:43 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1612874743; bh=BFDjcv6KSMKpUBUUz2u8g2yog1v8xqNgsaJuLvzVGiM=; h=To:From:Subject:Message-ID:Date; b=gKdpQXY1M0Lo7Mp3C36E8CQqXylM5Ie76QoQ9YArfPCGrkobl7W+NyVQjqXeXkakB zgyHkpVck8WpLv/+1/mhuJO3Dx5uHL9sCf/SVRqLYT/G+CV8vkVzTNggMwk1Ud3IW4 qP6AliI4XVxEWpYD9Y+EUC62lBhWJdzACRa2Mgz8= Authentication-Results: sas1-d4a7cb224acf.qloud-c.yandex.net; dkim=pass header.i=@yandex.ru Original-Received: by sas1-37da021029ee.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id wcmqDb5WQ1-jgn8UM2S; Tue, 09 Feb 2021 15:45:42 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) Received-SPF: pass client-ip=2a02:6b8:0:1a2d::607; envelope-from=hi-angel@yandex.ru; helo=forward104o.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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" Xref: news.gmane.io gmane.emacs.bugs:199686 Archived-At: This is a regression, but I'm not sure when it was introduced. Upon pressing RET, sometimes indentation gets inserted and you get the caret is on top of indentation; other times no indentation is inserted and the caret ends up at the beginning of a new line. There is not pattern, and both cases may happen many times in the row upon pressing RET. It is worth noting that this only happens in certain syntax parts of c-code. To reproduce the problem you basically put the caret at certain location in text, and spam RET and undo till some "RET" results in no indentation inserted (indentation seems expected by default, so it's not expected bahavior). # Steps to reproduce 1. Create /tmp/.emacs file with the following content: (defun test () (let ((i 0) (searching t)) (while (and (< i 10) searching) (setq i (+ i 1)) (call-interactively 'newline) (if (eq (line-beginning-position) (point)) (setq searching nil) (call-interactively 'undo)) ) (format "exiting with i = %d" i))) 2. Create `test.c` file with the following content: void foo() { if (-1 == dest) { bar("Couldn't open %s", to); goto exit; } } 3. Run emacs as `env HOME=/tmp/ emacs test.c` 4. Put caret at the end of `bar("Couldn't open %s", to);` text, right after the semicolon 5. Evaluate (test) NOTE: to make this work I had to evaluate the 5-th step twice. The reason is that `undo` in here behaves oddly: often it just refuses to undo with "No further undo unformation", thus making function evaluation stop. I'm not sure what to do about that problem; however repeating the call second time seems to always reproduce the problem for me. ## Expected Whenever `(test)` completes, the text is unchanged. ## Actual At some point you end up with caret being at the beginning of a new line (i.e. no indentation on that line) # Version Latest Emacs build: GNU Emacs 28.0.50 (build 12, x86_64-pc-linux-gnu, GTK+ Version 3.24.24, cairo version 1.17.4) of 2021-02-09 Also tested on a build from a few weeks ago, commit 9503f8d96c