From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie 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: Tue, 14 May 2019 09:27:35 +0000 Message-ID: <20190514092735.GB4231__10924.7567526594$1557826217$gmane$org@ACM> References: <87ftqms9db.fsf@secretsauce.net> <871s15k7ll.fsf@gmail.com> <20190513195323.GB5525@ACM> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="220466"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.10.1 (2018-07-13) Cc: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= , Dima Kogan , 35254@debbugs.gnu.org, Noam Postavsky To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue May 14 11:30:12 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 1hQTlE-000vEN-1J for geb-bug-gnu-emacs@m.gmane.org; Tue, 14 May 2019 11:30:12 +0200 Original-Received: from localhost ([127.0.0.1]:44078 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQTlC-0001zW-Qr for geb-bug-gnu-emacs@m.gmane.org; Tue, 14 May 2019 05:30:10 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:37723) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQTj9-0008Do-DR for bug-gnu-emacs@gnu.org; Tue, 14 May 2019 05:28:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hQTj8-0003LW-5Q for bug-gnu-emacs@gnu.org; Tue, 14 May 2019 05:28:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:33777) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hQTj8-0003Kz-1I; Tue, 14 May 2019 05:28:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hQTj7-0004OY-SP; Tue, 14 May 2019 05:28:01 -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: Tue, 14 May 2019 09:28:01 +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.155782606416856 (code B ref 35254); Tue, 14 May 2019 09:28:01 +0000 Original-Received: (at 35254) by debbugs.gnu.org; 14 May 2019 09:27:44 +0000 Original-Received: from localhost ([127.0.0.1]:47321 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hQTip-0004Nm-AG for submit@debbugs.gnu.org; Tue, 14 May 2019 05:27:43 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:39338 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1hQTim-0004NU-JF for 35254@debbugs.gnu.org; Tue, 14 May 2019 05:27:41 -0400 Original-Received: (qmail 4372 invoked by uid 3782); 14 May 2019 09:27:38 -0000 Original-Received: from acm.muc.de (p4FE15CA2.dip0.t-ipconnect.de [79.225.92.162]) by colin.muc.de (tmda-ofmipd) with ESMTP; Tue, 14 May 2019 11:27:35 +0200 Original-Received: (qmail 9573 invoked by uid 1000); 14 May 2019 09:27:35 -0000 Content-Disposition: inline In-Reply-To: X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de 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:159263 Archived-At: Hello, Stefan. On Mon, May 13, 2019 at 19:32:49 -0400, Stefan Monnier wrote: > >> 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). > Note that `newline` itself already does some subset of 2 (before running > electric-indent's post-self-insert hook). > > 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: > I haven't followed enough of the discussion to understand why that might > cause a bug. The bug is, type lots of s in a row; the indentation WS isn't getting removed from the blank lines. Currently electric-indent-inhibit is inhibiting this removal. > > 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-reindent) > > + ;; 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 > I don't understand why you distinguish > electric-indent-inhibit > from > (memq indent-line-function > electric-indent-functions-without-reindent) It was quite late when I worked out the patch. I just did it mechanically, to get the discussion moving. > When I introduced these, electric-indent-functions-without-reindent was > only meant to paper over those pre-existing cases that don't set > electric-indent-inhibit. > So, I'd suggest an even simpler patch which just closes the `unless` > earlier. Would that work? Probably. Maybe Joćo should check this, once he's fully back with us. > Stefan > diff --git a/lisp/electric.el b/lisp/electric.el > index 07da2f1d9e..beb3348755 100644 > --- a/lisp/electric.el > +++ b/lisp/electric.el > @@ -281,7 +281,7 @@ electric-indent-post-self-insert-function > (goto-char before) > (condition-case-unless-debug () > (indent-according-to-mode) > - (error (throw 'indent-error nil))) > + (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. > @@ -290,7 +290,7 @@ electric-indent-post-self-insert-function > ;; to `indent-according-to-mode' but after we may > ;; not be (Bug#15767). > (when (and (eolp)) > - (delete-horizontal-space t)))))) > + (delete-horizontal-space t))))) > (unless (and electric-indent-inhibit > (not at-newline)) > (condition-case-unless-debug () -- Alan Mackenzie (Nuremberg, Germany).