From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#35254: 27.0.50; cc-mode/electric-pair-mode/electric-layout-mode: bad trailing whitespace behavior in cc-mode Date: Mon, 13 May 2019 19:38:48 -0400 Message-ID: <87a7fphqlz.fsf@gmail.com> References: <87ftqms9db.fsf@secretsauce.net> <871s15k7ll.fsf@gmail.com> <20190513195323.GB5525@ACM> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="72218"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) Cc: Alan Mackenzie , Stefan Monnier , 35254@debbugs.gnu.org, Dima Kogan To: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue May 14 02:03:11 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hQKuV-000Iet-2J for geb-bug-gnu-emacs@m.gmane.org; Tue, 14 May 2019 02:03:11 +0200 Original-Received: from localhost ([127.0.0.1]:36551 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQKuT-00015a-S0 for geb-bug-gnu-emacs@m.gmane.org; Mon, 13 May 2019 20:03:09 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:35211) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQKu2-0000aT-HD for bug-gnu-emacs@gnu.org; Mon, 13 May 2019 20:03:03 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hQKXM-0006sO-9l for bug-gnu-emacs@gnu.org; Mon, 13 May 2019 19:41:58 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:33080) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hQKX8-0006dk-LA; Mon, 13 May 2019 19:39:05 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hQKX8-0004bx-ES; Mon, 13 May 2019 19:39:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Mon, 13 May 2019 23:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35254 X-GNU-PR-Package: emacs,cc-mode Original-Received: via spool by 35254-submit@debbugs.gnu.org id=B35254.155779073817715 (code B ref 35254); Mon, 13 May 2019 23:39:02 +0000 Original-Received: (at 35254) by debbugs.gnu.org; 13 May 2019 23:38:58 +0000 Original-Received: from localhost ([127.0.0.1]:46624 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hQKX4-0004bf-BJ for submit@debbugs.gnu.org; Mon, 13 May 2019 19:38:58 -0400 Original-Received: from mail-it1-f196.google.com ([209.85.166.196]:40187) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hQKX2-0004bP-9G for 35254@debbugs.gnu.org; Mon, 13 May 2019 19:38:57 -0400 Original-Received: by mail-it1-f196.google.com with SMTP id g71so1860055ita.5 for <35254@debbugs.gnu.org>; Mon, 13 May 2019 16:38:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=ZOatsqOauSXXQ3hWi1T3ou1R98NaqfG1+HvP4Sb5P6M=; b=lWyakmlry4/lD9a4EEG4UQ1muzg6k7H2u8qUe2SPfrJCeMwdAjNHqucFRy05AxHQei JpY2UUEAz/BkuMX07LeDgHLZFXP+tdNmXTYETceTTraW4km8sl3VbxeQs71qjtLA0Chj yIx/zTRNLZf/IGcDBXeVo1Y8j1nD456xYo2iYGM3y+s3BIDD60ZD2zWQb6o8DTs2pgGR P92N3Xx3mzTL1PL7YpG36/SHsJ0w7C47ZhbnK2rncXHoSSNFLch9iJem1DmrIUDiAOBX c1xMRM4CEKvFbmIw1lqP6aczdXI+D2WfsLXCI6BaZRDrG+QHeC09DOQhphj4bJxJNxvG fgtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=ZOatsqOauSXXQ3hWi1T3ou1R98NaqfG1+HvP4Sb5P6M=; b=XNJR4STXm4kdapS7zekBpGM1EYbosGG/nXDvoammKqB08rRFva1JOW4xnCPmb3lt9p PbeRMifbPqblMHEEzifF/q6VcFsmnhNHUM+JPCPWeUaVcopRcEcvOU1NFqHbti6NTGkG L7rLQD8Jt6zTvgmacde/EwPKWjWzikM28BdP5OmcdEgf4x7YMUVP/j5uy7DXjmsz2CJW POHWs7baj0tbxKLlVuRmL1liF7VSvgV/3CCKdVh9ReM6ulYrcnNIHez3eFmhmEDtRHK6 ZXbmfnO0p05NDcGqzNgdO7p3guwSMvf21eWzdh4QRxQwjnS6ilHZzCKQAillfE/GYSSw HrQQ== X-Gm-Message-State: APjAAAUZ2Zxvj4RSGVWD/8MQMBt+55V7BpaKfGFbqA15HNCI1cAAcGOY N2HXihKd6HL9+NZrOkYoXE8= X-Google-Smtp-Source: APXvYqzi/GVPtpxKaRmXUkLBZWknTj+1jgncUA1+Kc0kTiulle45vN6TbqYL5ktfpuajfZy0rl+SGw== X-Received: by 2002:a02:a812:: with SMTP id f18mr21402501jaj.31.1557790730340; Mon, 13 May 2019 16:38:50 -0700 (PDT) Original-Received: from minid (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.gmail.com with ESMTPSA id b1sm466847itd.12.2019.05.13.16.38.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 13 May 2019 16:38:49 -0700 (PDT) In-Reply-To: ("=?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?="'s message of "Mon, 13 May 2019 23:39:33 +0100") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.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" Xref: news.gmane.org gmane.emacs.bugs:159229 Archived-At: Jo=C3=A3o T=C3=A1vora writes: >> > Electric indent mode's post-self-insert hook entry has 3 effects: >> >> > 1. Indent the previous line. >> > 2. Remove trailing whitespace from the previous line. >> > 3. Indent the current line (when at beginning of line). >> >> > The change from 2019-01-22 "electric-layout-mode kicks in before >> > electric-pair-mode", makes 'electric-indent-inhibit' inhibit 1 and 2, >> > whereas before then it inhibited only 1. While cc mode provides its >> > own electric commands and therefore sets 'electric-indent-inhibit', it >> > doesn't implement an electric newline command. So if only one of >> > effects 2 and 3 from Electric indent mode occur, then hitting RET will >> > leave trailing whitespace. >> >> I interpret the problem a little differently. >> electric-indent-post-self-insert-function, when electric-indent-inhibit >> is set, is inhibiting actions which are not really part of electric >> indentation, in particular action 2 (above). This is the heart of the >> bug. The following patch fixes the bug. It would need tidying up before >> being committed: >> >> >> >> diff --git a/lisp/electric.el b/lisp/electric.el >> index 07da2f1d9e..15a42930c1 100644 >> --- a/lisp/electric.el >> +++ b/lisp/electric.el >> @@ -282,9 +282,15 @@ electric-indent-post-self-insert-function >> (condition-case-unless-debug () >> (indent-according-to-mode) >> (error (throw 'indent-error nil))) >> - ;; The goal here will be to remove the trailing >> - ;; whitespace after reindentation of the previous line >> - ;; because that may have (re)introduced it. >> + ) >> + (unless (memq indent-line-function >> + electric-indent-functions-without-reinden= t) >> + ;; The goal here will be to remove the indentation >> + ;; whitespace from an otherwise blank line after >> + ;; typing twice in succession. Also to remove >> + ;; trailing whitespace after reindentation of the >> + ;; previous line because that may have >> + ;; (re)introduced it. >> (goto-char before) >> ;; We were at EOL in marker `before' before the call >> ;; to `indent-according-to-mode' but after we may >> >> >> Jo=C3=A3o and Noam, what're your views on this proposed patch? > 1. Does it fix the reported problem (assuming it is a problem, and not > an otherwise potentially desirable change in behaviour)? It does fix the problem. > 2. Do any of you have suspicions that it might introduce problems > elsewhere? I'm unsure. It seems to be undoing a small part of [fd94312443] 2019-01-22 "electric-layout-mode kicks in before electric-pair-mode", so I guess it might rebreak whatever that commit is fixing. But I don't quite understand what that commit is fixing (in particular, where the commit message says "which can be a problem in some modes", which modes are those? What is "a problem"?). > 3. Does it pass the automated test suite? No, it breaks 3 tests in tests/lisp/electric.el: 3 unexpected results: FAILED electric-layout-int-main-kernel-style FAILED electric-layout-plainer-c-mode-use-c-style FAILED electric-modes-int-main-allman-style In each case, the reason for failure is that the expected result has trailing whitespace that the actual result misses. I guess electric-layout does want to put trailing whitespace in certain cases?