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: Fri, 10 May 2019 23:12:06 -0400 Message-ID: <871s15k7ll.fsf@gmail.com> References: <87ftqms9db.fsf@secretsauce.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="120546"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) Cc: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= , 35254@debbugs.gnu.org To: Dima Kogan Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat May 11 05:13:16 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 1hPIRn-000VF6-Q1 for geb-bug-gnu-emacs@m.gmane.org; Sat, 11 May 2019 05:13:16 +0200 Original-Received: from localhost ([127.0.0.1]:53058 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hPIRm-0002Wc-Kw for geb-bug-gnu-emacs@m.gmane.org; Fri, 10 May 2019 23:13:14 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:35716) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hPIRd-0002WX-Df for bug-gnu-emacs@gnu.org; Fri, 10 May 2019 23:13:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hPIRc-000713-7T for bug-gnu-emacs@gnu.org; Fri, 10 May 2019 23:13:05 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:54264) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hPIRa-0006wR-25; Fri, 10 May 2019 23:13:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hPIRZ-0005bl-Ou; Fri, 10 May 2019 23:13:01 -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: Sat, 11 May 2019 03:13: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.155754433721493 (code B ref 35254); Sat, 11 May 2019 03:13:01 +0000 Original-Received: (at 35254) by debbugs.gnu.org; 11 May 2019 03:12:17 +0000 Original-Received: from localhost ([127.0.0.1]:39575 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hPIQq-0005aa-Lh for submit@debbugs.gnu.org; Fri, 10 May 2019 23:12:16 -0400 Original-Received: from mail-it1-f172.google.com ([209.85.166.172]:50818) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hPIQp-0005aO-60 for 35254@debbugs.gnu.org; Fri, 10 May 2019 23:12:15 -0400 Original-Received: by mail-it1-f172.google.com with SMTP id i10so8580442ite.0 for <35254@debbugs.gnu.org>; Fri, 10 May 2019 20:12:15 -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; bh=yIOuduZhdnq7zbKn0mrRVOjt0CeZRtg3ZvYxlx4vNMo=; b=mdUXyL43H6epV1WMnqZALhj+Dc2/67slJOrSV1kDToSKyH2ovC/hXJnbotdsdv3wqf b+LHnqePrJGMXvg2pgTcgT2rkujwbFK6qVArFUwB273bPpniLOlVT9wEPZNOcZpNDYQE bl1VsxTHQ0tBz/0lKFVKDjDFJgOx/cKv/BHQW9/PFGQ70RiDZWI5PAAo0zgl7oi4QbiU xHICSZjKf6HnJbw97XdXFWO0ggL6qCjMZGBmb8xI4PlK777cLgS00zmenWgb3u2NsQPg /DhEQJa4hurjSTSA1PslRLgWVET749T11cLUv7124I81/K9gPdSVzjDI/ZZ2ESdELgV3 bifQ== 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; bh=yIOuduZhdnq7zbKn0mrRVOjt0CeZRtg3ZvYxlx4vNMo=; b=dfUsiNwlYYR+BDWmtwuFlExrAect4o0rK8ynU3dCZL/INqDYdIlOCuMbGJodCMzjJj 6nA2+L499IUSEhtnkPkXRNgFyH+LKMMA7gQPtalukjO+pZYA8QaXzKWFRsWr0vC++J9N vp0XRwsvVeIirDZzZKNmt1JOG23948/mskjSGs8/qCa9m//p0s/5NFgfr/6g97RJpP/K OP7Ewo7Q3NcQ6PS4cCxpN2B1UKK1CEM49osHpHheV4aGWRRIQQyAWiY/QiWogCnkLri4 L7jkJ3nRQ/6MymWpRpUPcockk3yRuOZa9MvbBk+XA5j0HXqTjZpORNeyiUALMyt/GdW6 p4Iw== X-Gm-Message-State: APjAAAU+JZvG0c6XOj7q3fF0zkuo+FwFIMFS3U4TEnqcRVTdfSKtC2Y8 8EhVgWbEk5sUGR2tahAX6cQ= X-Google-Smtp-Source: APXvYqxQtyAieyRCqJ7wLGqPsTaiy8tb7WCL0GCiNSiRvtBRt0zy+HPyorFIc0w8kHkgAQHboPBXsw== X-Received: by 2002:a24:1455:: with SMTP id 82mr9165534itg.59.1557544329596; Fri, 10 May 2019 20:12:09 -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 v1sm2629962iob.56.2019.05.10.20.12.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 10 May 2019 20:12:08 -0700 (PDT) In-Reply-To: <87ftqms9db.fsf@secretsauce.net> (Dima Kogan's message of "Fri, 12 Apr 2019 23:32:48 -0700") 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:159065 Archived-At: --=-=-= Content-Type: text/plain Dima Kogan writes: > Hi. > > I'm seeing a regression introduced in 2019/01 by an update meant to make > electric-pair-mode and electric-layout-mode play nicely: > > http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=fd943124439b7644392919bca8bc2a77e6316d92 > > Recipe: > > 1. 'emacs -Q' with any emacs more recent than that patch > > 2. Open up tst.c that contains this: > > int main(int argc, char* argv[]) > { > return 0; > } > > > 3. Move the point to the beginning of the line containing "return 0" > > 4. RET RET RET RET RET > > Now there're a bunch of new lines between the { and the "return 0", as > expected. But these lines aren't empty: they contain the initial > indentation whitespace. This whitespace shouldn't be there; and it > wasn't there prior to this patch. Right, the problem is that electric-indent-inhibit only partially disables electric indent, and the commit you reference changes which parts. The patch below disables it more completely. Note however, that this makes RET not do any electric indentation at all, just like in the good old days of Emacs 24.3. Possibly c-mode should rebind RET to a c-electric-return command or something. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Inhibit-electric-indent-completely-in-cc-mode-buffer.patch Content-Description: patch >From 1103fdfbf2be55d68d44151498c2598fd622ac08 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Fri, 10 May 2019 16:40:27 -0400 Subject: [PATCH] Inhibit electric indent completely in cc mode buffers (Bug#35254) 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. * lisp/progmodes/cc-mode.el (c-electric-indent-mode-function): New function. (c-basic-common-init): Add it to electric-indent-functions to disable electric indent completely (while still letting the electric-indent-mode command/setting to control c-electric-flag as before). --- lisp/progmodes/cc-mode.el | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el index bd62fc754a..e41f1101d0 100644 --- a/lisp/progmodes/cc-mode.el +++ b/lisp/progmodes/cc-mode.el @@ -634,6 +634,7 @@ (defun c-basic-common-init (mode default-style) ;; messing up CC Mode's, and set `c-electric-flag' if `electric-indent-mode' ;; has been called by the user. (when (boundp 'electric-indent-inhibit) (setq electric-indent-inhibit t)) + (add-hook 'electric-indent-functions 'c-electric-indent-mode-function nil t) ;; CC-mode should obey Emacs's generic preferences, tho only do it if ;; Emacs's generic preferences can be set per-buffer (Emacs>=24.4). (when (fboundp 'electric-indent-local-mode) @@ -2143,6 +2144,10 @@ (defun c-electric-indent-local-mode-hook () (setq c-electric-flag electric-indent-mode) (c-update-modeline))) +(defun c-electric-indent-mode-function (char) + ;; We never want `electric-indent-mode' to do anything. + 'no-indent) + ;; Support for C -- 2.11.0 --=-=-=--